|
-
October 21st, 1999, 02:10 AM
#1
How to properly use dll in VB6
Hi,
My application is using VB6. I want to check if
the PC is connect to internet.
My code is:
Public Declare Function InternetGetConnectedState Lib "wininet.dll" (lpdwFlags
as Long, byval dwReserved as Long) as Boolean
Dim ll as long
Dim ret as Boolean
ret = InternetGetConnectedState(ll, 0)
Msgbox INTERNET_CONNECTION_LAN
ret is always False.
and more I want to see what value INTERNET_CONNECTION_LAN is.
Msgbox INTERNET_CONNECTION_LAN
display nothing. Then I try this
Public Declare Function InternetAttemptConnect _
Lib "wininet" (ByVal dwReserved As Integer) As Integer
dim ss
ss=InternetAttemptConnect(0),
it return nothing too. If I need include some others?
Thanks
zys
-
October 21st, 1999, 03:29 AM
#2
Re: How to properly use dll in VB6
DOcs say InternetAttemptConnect returns ERROR_SUCCESS on success. i.e Non-zero return value means Error, while 0 is success. {IN WinError.h ERROR_SUCCESS is #def to zero.}
RK
-
October 21st, 1999, 03:51 AM
#3
Re: How to properly use dll in VB6
the following code has been tested in NT 4 , VB 6
option Explicit
private Declare Function InternetGetConnectedState Lib "wininet" _
(byref lState as Long, byval lRes as Long) as Long
Const INTERNET_CONNECTION_MODEM = 1
Const INTERNET_CONNECTION_LAN = 2
Const INTERNET_CONNECTION_PROXY = 4
Const INTERNET_CONNECTION_MODEM_BUSY = 8
private Sub Command1_Click()
Dim lState as Long
Dim l as Long
l = InternetGetConnectedState(lState, 0&)
If l <> 0 then
' connected
If lState And INTERNET_CONNECTION_PROXY then
MsgBox "connected via proxy"
End If
End If
End Sub
-
October 21st, 1999, 05:18 AM
#4
Re: How to properly use dll in VB6
Hi,
Thanks
I copy your code to my app in Win95.
l = InternetGetConnectedState(lState, 0&)
return value l is always <> 0 whatever I plug LAN line in or out.
So I'm fail to check if user is online(even if he doesn't
open browser).
Maybe the concept of connection to internet is different?
What I mean PC not connect to internet is user is not turn on
his Modem or plug out his LAN line.
Thanks again.
yansong
-
October 21st, 1999, 05:29 AM
#5
Re: How to properly use dll in VB6
Hi,
Dim lState As Long
Dim l As Long
l = InternetGetConnectedState(lState, 0&)
If l <> 0 Then
MsgBox "on line:" + CStr(l)
' connected
If lState And INTERNET_CONNECTION_PROXY Then
MsgBox "connected via proxy"
End If
If lState And INTERNET_CONNECTION_LAN Then
MsgBox "connected via LAN"
End If
Else
MsgBox "off line"
End If
Result is
online:1
But I do disconnect internet and use LAN not
MODEM. Why?
yansong
-
October 21st, 1999, 06:05 AM
#6
Re: How to properly use dll in VB6
I'm note sure what you are trying to accomplish.
Facts are:
- InternetGetConnectedState does not give you reliable information whether you are connected to the Internet or not
- the only way that I know of to check if you have access to the internet is by retrieving a page from the internet. This can be done via the internet transfer control and its OpenURL method
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|