Click to See Complete Forum and Search --> : detect if dial up is idle


tolisss
April 24th, 2001, 03:09 PM
how can i do that?

cksiow
April 24th, 2001, 07:26 PM
not sure whether this is the best, but it work for me.


Declare Function RasEnumConnections Lib "rasapi32.dll" Alias "RasEnumConnectionsA" (lprasconn as Any, lpcb as Long, lpcConnections as Long) as Long

public Type RASCONN
dwSize as Long
hRasConn as Long
szEntryName as string * RAS_MaxEntryName
szDeviceType as string * RAS_MaxDeviceType
szDeviceName as string * RAS_MaxDeviceName
End Type

public Function IsDialUpIdle() as Long
Dim conn(255) as RASCONN
Dim bufferSize as Long
Dim noOfConn as Long

bufferSize = 105472 '256 * 412

conn(0).dwSize = 412

vbDLLErrorCode = RasEnumConnections(conn(0), bufferSize, noOfConn)

If vbDLLErrorCode = ERROR_SUCCESS And noOfConn = 0 then

IsDialUpIdle = VB_TRUE 'yap, it's idle

ElseIf vbDLLErrorCode = 0 then

IsDialUpIdle = VB_FALSE 'got connection

else

IsDialUpIdle = VB_DLL_ERROR 'RasEnumConnections error

End If

End Function





HTH

cksiow
http://vblib.virtualave.net - share our codes