#include <Array.au3>
Func _RasEnumConnections()
Local $tBuffer, $pBuffer, $iSizeofBuffer, $tRasConn, $iResult, $aResult[1][7]
Local Const $tagRAS_CONNECTION = "dword Size;hWnd RasConnection;char EntryName[257];" & _
"char DeviceType[17];char DeviceName[129];char Pnebk[260];" & _
"dword SubEntry;byte EntryGuid[16];dword Flags;int Luid;ptr Correlation"
$tBuffer = DllStructCreate($tagRAS_CONNECTION)
$pBuffer = DllStructGetPtr($tBuffer)
$iSizeofBuffer = DllStructGetSize($tBuffer)
DllStructSetData($tBuffer, "Size", $iSizeofBuffer)
$iResult = DllCall("Rasapi32.dll", "dword", "RasEnumConnections", _
"ptr", $pBuffer, "dword*", $iSizeofBuffer, "dword*", 0)
$tBuffer = 0
If ($iResult[3] < 1) Then Return SetError(@error, 0, $aResult)
If ($iResult[3] = 1) Then
$tBuffer = DllStructCreate($tagRAS_CONNECTION)
Else
$tBuffer = DllStructCreate($tagRAS_CONNECTION & ";byte Data[" & ($iResult[3] - 1) *
$iSizeofBuffer & "]")
EndIf
DllStructSetData($tBuffer, "Size", $iSizeofBuffer)
$iResult = DllCall("Rasapi32.dll", "dword", "RasEnumConnections", _
"ptr", $pBuffer, "dword*", $iSizeofBuffer * $iResult[3], "dword*", 0)
If ($iResult[0]) Then Return SetError($iResult[0], 0, $aResult)
$aResult[0][0] = $iResult[3]
Redim $aResult[$iResult[3] + 1][7]
For $i = 1 To $iResult[3]
$tRasConn = DllStructCreate($tagRAS_CONNECTION, $pBuffer)
$aResult[$i][0] = DllStructGetData($tRasConn, "RasConnection")
$aResult[$i][1] = DllStructGetData($tRasConn, "EntryName")
$aResult[$i][2] = DllStructGetData($tRasConn, "DeviceType")
$aResult[$i][3] = DllStructGetData($tRasConn, "DeviceName")
$aResult[$i][4] = DllStructGetData($tRasConn, "Pnebk")
$aResult[$i][5] = DllStructGetData($tRasConn, "SubEntry")
$aResult[$i][6] = DllStructGetData($tRasConn, "Flags")
$pBuffer += $iSizeofBuffer
Next
$tBuffer = 0
Return $aResult
EndFunc ;==>_RasEnumConnections
$aConnection = _RasEnumConnections()
_Arraydisplay($aConnection, @error)
|