Btang11111
February 19th, 2000, 01:44 PM
Hi,
With Webbrowser Events Control of VB we can monitor DownloadBegin/Complete events etc, BUT how can we monitor if there is an EXISTING INTERNET MODEM CONNECTION?
With WININET.DLL there is an
INTERNETGETCONNECTEDSTATE(INTERNET_CONNECTION_MODEM, 0)
which returns Boolean results,
BUT this is not registrable as ACTIVE-X, IS THERE A SIMPLE WAY TO CHECK THE SAME THING IN VB Components??
OR, how do we incorporate the above WININET codes into VB??
Thanks in advance.
Aaron Young
February 19th, 2000, 02:56 PM
Try this:
'In a Module..
private Declare Function RegOpenKey Lib "advapi32.dll" Alias "RegOpenKeyA" (byval hKey as Long, byval lpSubKey as string, phkResult as Long) as Long
private Declare Function RegQueryValueEx Lib "advapi32.dll" Alias "RegQueryValueExA" (byval hKey as Long, byval lpValueName as string, byval lpReserved as Long, lpType as Long, lpData as Any, lpcbData as Long) as Long ' Note that if you declare the lpData parameter as string, you must pass it By Value.
private Declare Function RegCloseKey Lib "advapi32.dll" (byval hKey as Long) as Long
private Const HKEY_LOCAL_MACHINE = &H80000002
public Function IsConnected() as Boolean
Dim lRegKey as Long
Dim bData(3) as Byte
If RegOpenKey(HKEY_LOCAL_MACHINE, "System\CurrentControlSet\Services\RemoteAccess", lRegKey) = 0 then
'Opened RegKey Successfully..
If RegQueryValueEx(lRegKey, "Remote Connection", 0&, 1&, bData(0), 4) = 0 then
'Query the Value of "Remote Connection" 1 - Connected, 0 - Not Connected
IsConnected = bData(0)
else
'Counldn't find the Value, assume no Connection
IsConnected = false
End If
'Close the Registry Key
Call RegCloseKey(lRegKey)
End If
End Function
Aaron Young
Analyst Programmer
ajyoung@pressenter.com
aarony@redwingsoftware.com
Certified AllExperts Expert: http://www.allexperts.com/displayExpert.asp?Expert=11884
Btang11111
February 20th, 2000, 02:55 AM
Thanks for the good registry method.
Could you give the codes necessary to use Declare INCLUDE LIB method to use WinInet.Dll in VB??