替换其中的_RasEnumConnections函数:
Func _RasEnumConnections()
Local $aResult[1][7], $tBuffer, $pBuffer, $iBufferSize, $iResult
If @AutoItX64 Then
$tBuffer = DllStructCreate($tagRAS_CONNECTION_X64)
Else
$tBuffer = DllStructCreate($tagRAS_CONNECTION_X86)
EndIf
$pBuffer = DllStructGetPtr($tBuffer)
$iBufferSize = DllStructGetSize($tBuffer)
DllStructSetData($tBuffer, "Size", $iBufferSize)
$iResult = DllCall($RAS_DllHandle, "dword", "RasEnumConnectionsW", "ptr", $pBuffer, _
"dword*", $iBufferSize, "dword*", 0)
$tBuffer = 0
$pBuffer = _RasAllocHeap($iResult[3] * $iBufferSize)
If @AutoItX64 Then
$tBuffer = DllStructCreate($tagRAS_CONNECTION_X64, $pBuffer)
Else
$tBuffer = DllStructCreate($tagRAS_CONNECTION_X86, $pBuffer)
EndIf
DllStructSetData($tBuffer, "Size", $iBufferSize)
$iResult = DllCall($RAS_DllHandle, "dword", "RasEnumConnectionsW", "ptr", $pBuffer, _
"dword*", $iBufferSize * $iResult[3], "dword*", 0)
If ($iResult[0]) Then
_RasFreeVar($tBuffer, 0, _RasFreeHeap($pBuffer))
Return SetError($iResult[0], 0, $aResult)
EndIf
$aResult[0][0] = $iResult[3]
Redim $aResult[$iResult[3] + 1][7]
For $i = 1 To $iResult[3]
$aResult[$i][0] = DllStructGetData($tBuffer, "RasConnection")
$aResult[$i][1] = DllStructGetData($tBuffer, "EntryName")
$aResult[$i][2] = DllStructGetData($tBuffer, "DeviceType")
$aResult[$i][3] = DllStructGetData($tBuffer, "DeviceName")
$aResult[$i][4] = DllStructGetData($tBuffer, "Pnebook")
$aResult[$i][5] = DllStructGetData($tBuffer, "SubEntry")
$aResult[$i][6] = DllStructGetData($tBuffer, "Flags")
$tBuffer = 0
If @AutoItX64 Then
$tBuffer = DllStructCreate($tagRAS_CONNECTION_X64, $pBuffer + ($i * $iBufferSize))
Else
$tBuffer = DllStructCreate($tagRAS_CONNECTION_X86, $pBuffer + ($i * $iBufferSize))
EndIf
Next
_RasFreeVar($tBuffer, 0, _RasFreeHeap($pBuffer))
Return $aResult
EndFunc ;==>_RasEnumConnections
函数用到的两个数据结构如下 ——
Const $tagRAS_CONNECTION_X86 = "dword Size;hWnd RasConnection;wchar EntryName[257];wchar DeviceType[17];wchar DeviceName[129];wchar Pnebook[260];dword SubEntry;byte GuidEntry[16];dword Flags;dword Luid[2]" ; ubyte GuidCorrelationId[16]"
Const $tagRAS_CONNECTION_X64 = "dword Size;hWnd RasConnection;wchar EntryName[257];wchar DeviceType[17];wchar DeviceName[129];wchar Pnebook[260];dword SubEntry;byte GuidEntry[16];dword Flags;dword Luid[2];ubyte GuidCorrelationId[16]"
|