Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

_RAS: accessing information using Mprapi.dll

Please tell me what is wrong with my code, below is the how I have coded.

You can give me solution or suggestions on my code below.

step 1: DECLARE functions

Declare Function MprAdminServerConnect Lib "Mprapi.dll" ( _

ByVal lpwsServerName As String, _

ByRef phMprServer As Long) As Long

Declare Function MprAdminServerGetInfo Lib "Mprapi.dll" ( _

ByVal hMprServer As Long, _

dwLevel As Long, _

ByRef lplpbBuffer As Long) As Long

Type MPR_SERVER_0

fLanOnlyMode As Boolean

dwUpTime As Long

dwTotalPorts As Long

dwPortsInUse As Long
End Type

Step2: Write code to access RAS information

Dim intPortsInUse As Long
Dim intTotalPorts As Long
Dim lngRetCode As Long
Dim str SvrUNIC As String 'Used to store UNICODE string
Dim lngPtrMprServer As Long
Dim lngPtrServer As Long
Dim typMprServer As MPR_SERVER_0
Dim lngLevel As Long

intTotalPorts = 0
intPortsInUse = 0
lngLevel = 0

strSvrUNIC = StrConv(RASServer & vbNullChar, vbUnicode)

lngRetCode = MprAdminServerConnect(strSvrUNIC, lngPtrMprServer)
'--Note: the return code is 0 and the LastDllError is 997 (ERROR_IO_PENDING - Overlapped I/O operation is in progress.)

lngRetCode = MprAdminServerGetInfo(lngPtrMprServer, lngLevel, lngPtrServer)
'----Note: the return cod is 1722 and the LastDllError is 997 (RPC_S_SERVER_UNAVAILABLE - The RPC server is unavailable)

'----Note:below is the code that hasnt been tested. It will probably crash my program.
CopyMemory typMprServer, ByVal lngPtrServer, LenB(typMprServer)
With typMprServer
debut.Print .fLanOnlyMode & "; " & .dwUpTime & "; " & .dwTotalPorts & "; " & .dwPortsInUse & vbCr
[1871 byte] By [jubhele] at [2007-11-11 10:30:27]