 |
| View previous topic :: View next topic |
| Author |
Message |
Khaldoun baz Newbie
Joined: 12 Aug 2004 Posts: 1
|
Posted: Aug 12th, 2004 05:20 AM Post subject: Check if the URL is valid |
|
|
check if the url is valid
[vb:1:0bfb2b5918]Private Const S_FALSE = &H1
Private Const S_OK = &H0
'Only implemented as unicode...
Private Declare Function IsValidURL Lib "URLMON.DLL" (ByVal pbc As Long, ByVal szURL As String, ByVal dwReserved As Long) As Long
Private Sub Form_Load()
MsgBox "Is valid URL: " + CStr(IsGoodURL("http://www.google.com"))
MsgBox "Is valid URL: " + CStr(IsGoodURL("hxxp:/www.googlei.uhoh"))
End Sub
Public Function IsGoodURL(ByVal sURL As String) As Boolean
'The IsValidURL always expects a UNICODE string, but whenever
'VB calls an API function, it converts the strings to ANSI strings.
'That's why we're going to use a trick here. Before calling the function,
'We're going to convert the unicode string to unicode so we get a double
'unicode string.
'Before VB calls the API function, it converts our double unicode string
'to a normal unicode string; exactely what IsValidURL is expecting.
sURL = StrConv(sURL, vbUnicode)
'Now call the function
IsGoodURL = (IsValidURL(ByVal 0&, sURL, 0) = S_OK)
End Function[/vb:1:0bfb2b5918] |
|
| Back to top |
|
Avis Junior Poster

Joined: 07 Oct 2003 Posts: 510 Location: India
|
|
| Back to top |
|
Andir Centurion

Joined: 21 Dec 2003 Posts: 184 Location: Chicago Area
|
Posted: Aug 18th, 2004 02:05 AM Post subject: |
|
|
I think he's posting it for our reference in case we need code to check URLs.  _________________ If you happen to see little people sitting on your desk...don't tell anyone or they might think your crazy too. |
|
| Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|