'
' UrlCanonicalize -
'
' Author: Joe Strazzere
'
dim ptr1 as unsigned
dim ptr2 as unsigned
dim ptr3 as unsigned
dim URL_ESCAPE_PERCENT as unsigned
dim URL_ESCAPE_SPACES_ONLY as unsigned
dim URL_DONT_SIMPLIFY as unsigned
dim URL_UNESCAPE as unsigned
dim URL_ESCAPE_UNSAFE as unsigned
dim URL_PLUGGABLE_PROTOCOL as unsigned
ptr1=allocate(255)
ptr2=allocate(260)
ptr3=allocate(4)
'Private Const MAX_PATH As Long = 260
'Private Const ERROR_SUCCESS As Long = 0
'Convert any occurrence of '%' to
'its escape sequence.
URL_ESCAPE_PERCENT = 4096 '&H1000
'Replace only spaces with escape
'sequences. This flag takes precedence
'over URL_ESCAPE_UNSAFE, but does not
'apply to opaque URLs.
URL_ESCAPE_SPACES_ONLY = 67108864 '&H4000000
'Treat '/./' and '/../' in a URL string
'as literal characters, not as shorthand
'for navigation.
URL_DONT_SIMPLIFY = 134217728 '&H8000000
'Unescape any escape sequences that
'the URLs contain, with two exceptions.
'The escape sequences for '?' and '#'
'will not be unescaped. If one of the
'URL_ESCAPE_XXX flags is also set, the
'two URLs will unescaped, then combined,
'then escaped.
URL_UNESCAPE = 268435456 '&H10000000
'Replace unsafe values with their
'escape sequences. This flag applies
'to all URLs, including opaque URLs.
URL_ESCAPE_UNSAFE = 536870912 '&H20000000
'Combine URLs with client-defined
'pluggable protocols, according to
'the W3C specification. This flag
'does not apply to standard protocols
'such as ftp, http, gopher, and so on.
'If this flag is set, UrlCombine will
'not simplify URLs, so there is no need
'to also set URL_DONT_SIMPLIFY.
URL_PLUGGABLE_PROTOCOL = 1073741824 '&H40000000
' Private Declare Function UrlCanonicalize Lib "shlwapi" _
' Alias "UrlCanonicalizeA" _
' (ByVal pszURL As String, _
' ByVal pszCanonicalized As String, _
' pcchCanonicalized As Long, _
' ByVal dwFlags As Long) As Long
'mystring$="http://www.wintast.com/index.htm?this is a test"
mystring$="This is a test for me."
pokestring(ptr1,mystring$,1)
pokestring(ptr2," ",1)
pokeinteger(ptr3,260,4)
ret=External("shlwapi.dll", "UrlCanonicalizeA", ptr1, ptr2, ptr3, URL_ESCAPE_SPACES_ONLY)
var$=peekstring$(ptr2)
msgbox(var$,,"UrlCanonicalize")