I see in the wininet.dll there are the three functions as stated in the
subject. None of them behave as I would expect them to.
Public Declare Function InternetGetConnectedState Lib "wininet.dll" _
(ByRef lpdwFlags As Long, ByVal dwReserved As Long) As Boolean
++>This returns True no matter what, and the lpdwFlags contains 18. This is
regardless of any dial up connections configured. And also if I have the
network connected or not.
Public Declare Function InternetCheckConnection Lib "wininet.dll" Alias
"InternetCheckConnectionA" _
(ByVal lpszUrl As String, ByVal dwFlags As Long, ByVal dwReserved As Long)
As Boolean
++>This returns False every time. I've tried an IP address, a URL address
such as http://www.microsoft.com
I've tried http://xxx.xx.xxx.xxx also with no luck. Always False.
Public Declare Function InternetAttemptConnect Lib "wininet.dll" _
(ByVal dwReserved As Long) As Long
++>This always returns 0 (ERROR_SUCCESS) regardless of what I do.
I presume I am doing something wrong, the question is what?
Which one of these functions do I use? And more precisely how do I use it?
Any help would be appreciated.
--
Alex
Software Developer
"My mind not only wanders,
sometimes it leaves completely."
You should have mentioned that you were using Internet Explorer 5.
Anyways, for the first function, InternetGetConnectedState returns true
if the computer has the capability to connect to the Internet, not if it is
connected to the internet. The flags that you are getting back, 18, can
only come from one combination, which is INTERNET_RAS_INSTALLED and
INTERNET_CONNECTION_LAN. Is this the case? Are you connected over a lan
and have RAS installed as well?
For the InternetCheckConnection, the documentation states that it
attempts to ping the server that you specify. I dont know about the other
servers that you have tried, but www.microsoft.com does not respond to ping
requests, so the function would return false. If you are finding that the
servers that you are trying to check are honoring ping requests, then you
might want to pass the flag FLAG_ICC_FORCE_CONNECTION,
InternetCheckConnection will not force a new connection if one doesn't
exist.
InternetAttemptConnect tries to connect to the Internet for you. If you
have a LAN, then this is pointless, because an IP address is assigned to
you, and it sees that as a connection to the Internet, and given the
response from the call to the InternetGetConnectedState function, it seems
as if this is the case.
However, I think that you don't need to do any of this. In your call to
InternetOpen, pass the INTERNET_OPEN_TYPE_PRECONFIG flag in to the
dwAccessType parameter. The WinInet libraries will take care of the rest
for you. If the user has a connection through the LAN, then it will use
that, if it is through a dial up connection, it will use that. It already
knows.
Hope this helps.
--
- Nicholas Paldino
- nicholas...@exisconsulting.com
I appreciate the help, but I think I may have to include other API's in
addition to the wininet.
--
Alex
Software Developer
"My mind not only wanders,
sometimes it leaves completely."
Nicholas Paldino <nicholas...@exisconsulting.com> wrote in message
news:#vnBC1TJ$GA.253@cppssbbsa05...
My experience is that InternetGetConnectedState()
will return TRUE or FALSE depending on when it
last refreshed its internal info.
For example, if you unplug your network cable it
will continue to report true until you actually
fail to connect to something. Then it will report
false. If you plug the cable back in, it will
report false until you try another connection.
Does InternetCheckConnection work through a proxy?