_RAS: accessing information using Mprapi.dll
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

