January 1, 2005

WinTask - UrlGetPart

'
' UrlGetPart - Takes a URL string and returns a specified part
'

' Author: Joe Strazzere

'


dim ptr1 as unsigned
dim ptr2 as unsigned
dim ptr3 as unsigned

ptr1=allocate(255)
ptr2=allocate(255)
ptr3=allocate(4)

 

URL_PART_SCHEME  = 1
URL_PART_HOSTNAME  = 2
URL_PART_USERNAME  = 3
URL_PART_PASSWORD  = 4
URL_PART_PORT   = 5
URL_PART_QUERY   = 6

 

'mystring$="http://172.16.1.103/Scripts/CustomerReg.asp"
mystring$="http://joe:password@www.mysite.com:8080/dir/index.html?test=1"

'1 = URL_PART_SCHEME   = http
'2 = URL_PART_HOSTNAME = www.mysite.com
'3 = URL_PART_USERNAME = joe
'4 = URL_PART_PASSWORD = password
'5 = URL_PART_PORT     = 8080
'6 = URL_PART_QUERY    = test=1

 

pokestring(ptr1,mystring$,1)
pokestring(ptr2,"                                                                                              ",1)
pokeinteger(ptr3,94,4)

 

ret=External("shlwapi.dll", "UrlGetPartA", ptr1, ptr2, ptr3, URL_PART_HOSTNAME,0)

 

var$=peekstring$(ptr2)

 

msgbox(var$,,"UrlGetPart")