Starstar Posted May 9, 2015 Share Posted May 9, 2015 (edited) Global Const $RAS_MaxAreaCode = 10 Global Const $RAS_MaxPhoneNumber = 128 Global Const $RAS_MaxDeviceType = 16 Global Const $RAS_MaxDeviceName = 128 Global Const $RAS_MaxPadType = 32 Global Const $RAS_MaxX25Address = 200 Global Const $RAS_MaxFacilities = $RAS_MaxX25Address Global Const $RAS_MaxUserData = $RAS_MaxFacilities Global Const $RAS_MaxDnsSuffix = 256 Global Const $RAS_MaxEntryName = 256 Global Const $WM_RASDIALEVENT = 0xCCCD Global Const $RASCS_DONE = 0x2000 Global Const $WAIT_OBJECT_0 = 0 Global $hConection = 0 Global Const $MAX_PATH = 256 Global Const $tagRASDIALPARAMS = "dword dwSize;handle hrasconn;wchar szEntryName["& $RAS_MaxEntryName +1 &"];wchar szDeviceType["&$RAS_MaxDeviceType + 1&"];wchar szDeviceName["&$RAS_MaxDeviceName + 1&"];wchar szPhonebook["&$MAX_PATH &"];DWORD dwSubEntry;GUID guidEntry;DWORD dwFlags; LUID luid;GUID guidCorrelationId" Local $tRASDIALPARAMS = DllStructCreate($tagRASDIALPARAMS) Sleep(100) DllStructSetData($tagRASDIALPARAMS,"dwSize", DllStructGetSize($tRASDIALPARAMS)) $lpcb = DllStructGetSize($tRASDIALPARAMS) Local $iRet = DllCall("Rasapi32.dll", "dword", "RasEnumConnectionsW", "ptr",$tRASDIALPARAMS,"dword",$lpcb, "ptr",$tRASDIALPARAMS) MsgBox(0,"",$iRet[0]) I got error 87(The parameter is incorrect)......if you can help me i shall be very grateful to you. Edited May 9, 2015 by Starstar Life is like a coin. You can spend it Anyway as you wish and for your kind information. "you can spend it only once." Link to comment Share on other sites More sharing options...
bernd670 Posted May 9, 2015 Share Posted May 9, 2015 (edited) Hello,the error 87 is rightly ... 1. the data type GUID and LUID does not exist. These are own Structures.2. the parameters for RasEnumConnections are all of type pointer and must be passed so3. with a null pointer call you get the buffer size needed....Try times so I could not test!expandcollapse popup#include <Array.au3> Global Const $RAS_MaxAreaCode = 10 Global Const $RAS_MaxPhoneNumber = 128 Global Const $RAS_MaxDeviceType = 16 Global Const $RAS_MaxDeviceName = 128 Global Const $RAS_MaxPadType = 32 Global Const $RAS_MaxX25Address = 200 Global Const $RAS_MaxFacilities = $RAS_MaxX25Address Global Const $RAS_MaxUserData = $RAS_MaxFacilities Global Const $RAS_MaxDnsSuffix = 256 Global Const $RAS_MaxEntryName = 256 Global Const $WM_RASDIALEVENT = 0xCCCD Global Const $RASCS_DONE = 0x2000 Global Const $WAIT_OBJECT_0 = 0 Global $hConection = 0 Global Const $MAX_PATH = 256 Global Const $tagGUID = "struct;DWORD GUID_Data1;WORD GUID_Data2;WORD GUID_Data3;BYTE GUID_Data[8];endstruct" Global Const $tagLUID = "struct;DWORD LUID_LowPart;LONG LUID_HighPart;endstruct" Global Const $tagRASCONN = "struct;dword dwSize;handle hrasconn;wchar szEntryName[" & $RAS_MaxEntryName + 1 & "];wchar szDeviceType[" & $RAS_MaxDeviceType + 1 & "];wchar szDeviceName[" & $RAS_MaxDeviceName + 1 & "];wchar szPhonebook[" & $MAX_PATH & "];DWORD dwSubEntry;" & $tagGUID & ";DWORD dwFlags;" & $tagLUID & ";" & $tagGUID & ";endstruct" Global Const $tagREC_lpcb = "dword lpcb" Global Const $tagRec_lpcConns = "dword lpcConns" Local $tREC_lpcb = DllStructCreate($tagREC_lpcb) Local $tREC_lpcConns = DllStructCreate($tagRec_lpcConns) Sleep(100) ; get the required buffer size DllStructSetData($tREC_lpcb, "lpcb", 0) DllStructSetData($tREC_lpcConns, "lpcConns", 0) Local $aRet = DllCall("Rasapi32.dll", "dword", "RasEnumConnections", "ptr", Null, "ptr", DllStructGetPtr($tREC_lpcb), "ptr", DllStructGetPtr($tREC_lpcConns)) MsgBox(0, "get buffer size", $aRet[0]) ConsoleWrite("required buffer size: " & DllStructGetData($tREC_lpcb, "lpcb") & @CRLF) ; the required buffer size ConsoleWrite("Number of RASCON Structures: " & DllStructGetData($tREC_lpcConns, "lpConns") & @CRLF) ; mumber of RASCON Structures If $aRet[0] = 603 Then ; ERROR_BUFFER_TOO_SMALL $iConns = DllStructGetData($tREC_lpcConns, "lpConns") $tagRASCONNS = "" For $iStructs = 1 To $iConns $tagRASCONNS &= StringRegExpReplace($tagRASCONN, "\s+(.*?);", " RC" & $iStructs & "_$1" &";") & ";" Next ;~ ConsoleWrite($tagRASCONNS & @CRLF) $tRASCONNS = DllStructCreate($tagRASCONNS) $iRASCONN_size = DllStructGetSize(DllStructCreate($tagRASCONN)) ;~ ConsoleWrite($iRASCONN_size & @CRLF) For $iStructs = 1 To $iConns DllStructSetData($tRASCONNS, "RC" & $iStructs & "_dwSize", $iRASCONN_size) Next DllStructSetData($tREC_lpcb, "lpcb", DllStructGetSize($tRASCONNS)) $aRet = DllCall("Rasapi32.dll", "dword", "RasEnumConnections", "ptr",DllStructGetPtr($tRASCONNS),"ptr",DllStructGetPtr($tREC_lpcb), "ptr",DllStructGetPtr($tREC_lpcConns)) MsgBox(0, "get data", $aRet[0]) For $iStructs = 1 To $iConns ConsoleWrite("EntryName of Conn " & $iStructs & ": " & DllStructGetData($tRASCONNS, "RC" & $iStructs & "_szEntryName") & @CRLF) Next EndIf Edited May 10, 2015 by bernd670 Correct Code Starstar 1 greetingsbernd I hacked 127.0.0.1 -> Link to comment Share on other sites More sharing options...
Starstar Posted May 9, 2015 Author Share Posted May 9, 2015 Thanks bernd670 i am going to try it...... Life is like a coin. You can spend it Anyway as you wish and for your kind information. "you can spend it only once." Link to comment Share on other sites More sharing options...
Starstar Posted May 10, 2015 Author Share Posted May 10, 2015 Hello,the error 87 is rightly ... 1. the data type GUID and LUID does not exist. These are own Structures.2. the parameters for RasEnumConnections are all of type pointer and must be passed so3. with a null pointer call you get the buffer size needed....Try times so I could not test!Hidden Content Bro it is not working...... Life is like a coin. You can spend it Anyway as you wish and for your kind information. "you can spend it only once." Link to comment Share on other sites More sharing options...
bernd670 Posted May 10, 2015 Share Posted May 10, 2015 Hello,which values are to be returned?Oh I see now I forgot index in the following lineIf $aRet = 603 Then ; ERROR_BUFFER_TOO_SMALLcorrect is If $aRet[0] = 603 Then ; ERROR_BUFFER_TOO_SMALL Starstar 1 greetingsbernd I hacked 127.0.0.1 -> Link to comment Share on other sites More sharing options...
Danyfirex Posted May 10, 2015 Share Posted May 10, 2015 hi mate. trying with rasdial again. This should work. and should returns the buffer required size. Global Const $ERROR_SUCCESS = 0x0 Global Const $RAS_MaxAreaCode = 10 Global Const $RAS_MaxPhoneNumber = 128 Global Const $RAS_MaxDeviceType = 16 Global Const $RAS_MaxDeviceName = 128 Global Const $RAS_MaxPadType = 32 Global Const $RAS_MaxX25Address = 200 Global Const $RAS_MaxFacilities = $RAS_MaxX25Address Global Const $RAS_MaxUserData = $RAS_MaxFacilities Global Const $RAS_MaxDnsSuffix = 256 Global Const $RAS_MaxEntryName = 256 Global Const $WM_RASDIALEVENT = 0xCCCD Global Const $RASCS_DONE = 0x2000 Global Const $WAIT_OBJECT_0 = 0 Global $hConection = 0 Global Const $MAX_PATH = 256 Global Const $tagRASDIALPARAMS = "dword dwSize;handle hrasconn;wchar szEntryName[" & $RAS_MaxEntryName + 1 & "];wchar szDeviceType[" & $RAS_MaxDeviceType + 1 & "];wchar szDeviceName[" & $RAS_MaxDeviceName + 1 & "];wchar szPhonebook[" & $MAX_PATH & "];DWORD dwSubEntry;GUID guidEntry;DWORD dwFlags; LUID luid;GUID guidCorrelationId" Local $tRASDIALPARAMS = DllStructCreate($tagRASDIALPARAMS) Sleep(100) DllStructSetData($tagRASDIALPARAMS, "dwSize", DllStructGetSize($tRASDIALPARAMS)) $lpcb = DllStructGetSize($tRASDIALPARAMS) Local $iRet = DllCall("Rasapi32.dll", "dword", "RasEnumConnectionsW", "ptr", 0, "dword*", Null, "ptr*", 0) If Not ($iRet[0] = $ERROR_SUCCESS) Then Local $tpcbSize = $iRet[2] MsgBox(0, "required buffer size", $tpcbSize) Else MsgBox(0, "There are no active RAS connections", $tpcbSize) EndIfSaludos Starstar 1 Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut Link to comment Share on other sites More sharing options...
Starstar Posted May 10, 2015 Author Share Posted May 10, 2015 (edited) Hello,which values are to be returned?Oh I see now I forgot index in the following lineIf $aRet = 603 Then ; ERROR_BUFFER_TOO_SMALLcorrect is If $aRet[0] = 603 Then ; ERROR_BUFFER_TOO_SMALL But the error remain same 603(buffer is too small) Edited May 10, 2015 by Starstar Life is like a coin. You can spend it Anyway as you wish and for your kind information. "you can spend it only once." Link to comment Share on other sites More sharing options...
Starstar Posted May 10, 2015 Author Share Posted May 10, 2015 hi mate. trying with rasdial again. This should work. and should returns the buffer required size. Global Const $ERROR_SUCCESS = 0x0 Global Const $RAS_MaxAreaCode = 10 Global Const $RAS_MaxPhoneNumber = 128 Global Const $RAS_MaxDeviceType = 16 Global Const $RAS_MaxDeviceName = 128 Global Const $RAS_MaxPadType = 32 Global Const $RAS_MaxX25Address = 200 Global Const $RAS_MaxFacilities = $RAS_MaxX25Address Global Const $RAS_MaxUserData = $RAS_MaxFacilities Global Const $RAS_MaxDnsSuffix = 256 Global Const $RAS_MaxEntryName = 256 Global Const $WM_RASDIALEVENT = 0xCCCD Global Const $RASCS_DONE = 0x2000 Global Const $WAIT_OBJECT_0 = 0 Global $hConection = 0 Global Const $MAX_PATH = 256 Global Const $tagRASDIALPARAMS = "dword dwSize;handle hrasconn;wchar szEntryName[" & $RAS_MaxEntryName + 1 & "];wchar szDeviceType[" & $RAS_MaxDeviceType + 1 & "];wchar szDeviceName[" & $RAS_MaxDeviceName + 1 & "];wchar szPhonebook[" & $MAX_PATH & "];DWORD dwSubEntry;GUID guidEntry;DWORD dwFlags; LUID luid;GUID guidCorrelationId" Local $tRASDIALPARAMS = DllStructCreate($tagRASDIALPARAMS) Sleep(100) DllStructSetData($tagRASDIALPARAMS, "dwSize", DllStructGetSize($tRASDIALPARAMS)) $lpcb = DllStructGetSize($tRASDIALPARAMS) Local $iRet = DllCall("Rasapi32.dll", "dword", "RasEnumConnectionsW", "ptr", 0, "dword*", Null, "ptr*", 0) If Not ($iRet[0] = $ERROR_SUCCESS) Then Local $tpcbSize = $iRet[2] MsgBox(0, "required buffer size", $tpcbSize) Else MsgBox(0, "There are no active RAS connections", $tpcbSize) EndIf SaludosMy dear error Remain same 603(buffer is to small)::: required buffer is 1384 in this on my pc....... Life is like a coin. You can spend it Anyway as you wish and for your kind information. "you can spend it only once." Link to comment Share on other sites More sharing options...
Danyfirex Posted May 10, 2015 Share Posted May 10, 2015 (edited) Simply use $tpcSize to allocate memory. $tpcSize I wanted to mean this: Local $iRet = DllCall("Rasapi32.dll", "dword", "RasEnumConnectionsW", "ptr", 0, "dword*", Null, "ptr*", 0) If $iRet[0] = $ERROR_BUFFER_TOO_SMALL Then Local $tpcbSize = $iRet[2] MsgBox(0, "required buffer size", $tpcbSize) Local $tBuffer=DllStructCreate("byte[" & $tpcbSize & "]") ;then call RasEnumConnectionsW again Else MsgBox(0, "There are no active RAS connections", $tpcbSize) EndIfSaludos Edited May 10, 2015 by Danyfirex Starstar 1 Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut Link to comment Share on other sites More sharing options...
bernd670 Posted May 10, 2015 Share Posted May 10, 2015 (edited) Hello,I have a mistake, I can try not unfortunately, sorry!in the following line is missing a 'c', therefore can not determine the required buffer size!$iConns = DllStructGetData($tREC_lpcConns, "lpConns")change to$iConns = DllStructGetData($tREC_lpcConns, "lpcConns")sorry Edited May 10, 2015 by bernd670 Starstar 1 greetingsbernd I hacked 127.0.0.1 -> Link to comment Share on other sites More sharing options...
Starstar Posted May 10, 2015 Author Share Posted May 10, 2015 expandcollapse popup#include <Array.au3> Global Const $RAS_MaxAreaCode = 10 Global Const $RAS_MaxPhoneNumber = 128 Global Const $RAS_MaxDeviceType = 16 Global Const $RAS_MaxDeviceName = 128 Global Const $RAS_MaxPadType = 32 Global Const $RAS_MaxX25Address = 200 Global Const $RAS_MaxFacilities = $RAS_MaxX25Address Global Const $RAS_MaxUserData = $RAS_MaxFacilities Global Const $RAS_MaxDnsSuffix = 256 Global Const $RAS_MaxEntryName = 256 Global Const $WM_RASDIALEVENT = 0xCCCD Global Const $RASCS_DONE = 0x2000 Global Const $WAIT_OBJECT_0 = 0 Global $hConection = 0 Global Const $MAX_PATH = 256 Global Const $tagGUID = "struct;DWORD GUID_Data1;USHORT GUID_Data2;USHORT GUID_Data3;BYTE GUID_Data[8];endstruct" Global Const $tagLUID = "struct;DWORD LUID_LowPart;LONG LUID_HighPart;endstruct" Global Const $tagRASCONN = "struct;dword dwSize;handle hrasconn;char szEntryName[" & $RAS_MaxEntryName + 1 & "];char szDeviceType[" & $RAS_MaxDeviceType + 1 & "];char szDeviceName[" & $RAS_MaxDeviceName + 1 & "];char szPhonebook[" & $MAX_PATH & "];DWORD dwSubEntry;" & $tagGUID & ";DWORD dwFlags;" & $tagLUID & ";" & $tagGUID & ";endstruct" Global Const $tagREC_lpcb = "dword lpcb" Global Const $tagRec_lpcConns = "dword lpcConns" Local $tREC_lpcb = DllStructCreate($tagREC_lpcb) Local $tREC_lpcConns = DllStructCreate($tagRec_lpcConns) Sleep(100) ; get the required buffer size DllStructSetData($tREC_lpcb, "lpcb", 0) DllStructSetData($tREC_lpcConns, "lpcConns", 0) Local $aRet = DllCall("Rasapi32.dll", "dword", "RasEnumConnections", "ptr", Null, "ptr", DllStructGetPtr($tREC_lpcb), "ptr", DllStructGetPtr($tREC_lpcConns)) MsgBox(0, "get buffer size", $aRet[0]) ConsoleWrite("required buffer size: " & DllStructGetData($tREC_lpcb, "lpcb") & @CRLF) ; the required buffer size ConsoleWrite("Number of RASCON Structures: " & DllStructGetData($tREC_lpcConns, "lpConns") & @CRLF) ; mumber of RASCON Structures If $aRet[0] = 603 Then ; ERROR_BUFFER_TOO_SMALL $iConns = DllStructGetData($tREC_lpcConns, "lpcConns") $tagRASCONNS = "" For $iStructs = 1 To $iConns $tagRASCONNS &= StringRegExpReplace($tagRASCONN, "\s+(.*?);", " RC" & $iStructs & "_$1" &";") & ";" Next ;~ ConsoleWrite($tagRASCONNS & @CRLF) $tRASCONNS = DllStructCreate($tagRASCONNS) $iRASCONN_size = DllStructGetSize(DllStructCreate($tagRASCONN)) ;~ ConsoleWrite($iRASCONN_size & @CRLF) For $iStructs = 1 To $iConns DllStructSetData($tRASCONNS, "RC" & $iStructs & "_dwSize", $iRASCONN_size) Next DllStructSetData($tREC_lpcb, "lpcb", DllStructGetSize($tRASCONNS)) $aRet = DllCall("Rasapi32.dll", "dword", "RasEnumConnections", "ptr",DllStructGetPtr($tRASCONNS),"ptr",DllStructGetPtr($tREC_lpcb), "ptr",DllStructGetPtr($tREC_lpcConns)) MsgBox(0, "get data", $aRet[0]) For $iStructs = 1 To $iConns ConsoleWrite("EntryName of Conn " & $iStructs & ": " & DllStructGetData($tRASCONNS, "RC" & $iStructs & "_szEntryName") & @CRLF) Next EndIfNow i got error 632 (The structure size is incorrect) Life is like a coin. You can spend it Anyway as you wish and for your kind information. "you can spend it only once." Link to comment Share on other sites More sharing options...
Danyfirex Posted May 10, 2015 Share Posted May 10, 2015 Let me see If I found my usb flash memory I think I have an example i write some time ago. Saludos Starstar 1 Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut Link to comment Share on other sites More sharing options...
Danyfirex Posted May 11, 2015 Share Posted May 11, 2015 (edited) I search in my work and house and I could no find my usb. so I write the example again. expandcollapse popup#include <Array.au3> Global Const $ERROR_SUCCESS = 0x0 Global Const $ERROR_BUFFER_TOO_SMALL = 603 Global Const $RAS_MaxAreaCode = 10 Global Const $RAS_MaxPhoneNumber = 128 Global Const $RAS_MaxDeviceType = 16 Global Const $RAS_MaxDeviceName = 128 Global Const $RAS_MaxPadType = 32 Global Const $RAS_MaxX25Address = 200 Global Const $RAS_MaxFacilities = $RAS_MaxX25Address Global Const $RAS_MaxUserData = $RAS_MaxFacilities Global Const $RAS_MaxDnsSuffix = 256 Global Const $RAS_MaxEntryName = 256 Global Const $WM_RASDIALEVENT = 0xCCCD Global Const $RASCS_DONE = 0x2000 Global Const $WAIT_OBJECT_0 = 0 Global $hConection = 0 Global Const $MAX_PATH = 256 Global Const $tagGUID = "struct;DWORD GUID_Data1;USHORT GUID_Data2;USHORT GUID_Data3;BYTE GUID_Data[8];endstruct" Global Const $tagLUID = "struct;DWORD LUID_LowPart;LONG LUID_HighPart;endstruct" ;Your $tagRASCONN was wrong (I think you're over window 7 or 8 you should see respective declaration using macros. I'll add you the C++ typedef at the end. Global Const $tagRASCONN = "struct;dword dwSize;handle hrasconn;wchar szEntryName[" & $RAS_MaxEntryName + 1 & "];wchar szDeviceType[" & $RAS_MaxDeviceType + 1 & "];wchar szDeviceName[" & $RAS_MaxDeviceName + 1 & "]" Local $iRet = DllCall("Rasapi32.dll", "dword", "RasEnumConnectionsW", "ptr", 0, "dword*", Null, "ptr*", 0) ;Call For get the required buffer size If $iRet[0] = $ERROR_BUFFER_TOO_SMALL Then Local $tpcbSize = $iRet[2] MsgBox(0, "required buffer size", $tpcbSize) Local $tBuffer = DllStructCreate("dword dwSize;byte[" & $tpcbSize - 4 & "]") ;create a Buffer this is the array of RASCONN Structures Local $tRASCONNSize = DllStructCreate($tagRASCONN);Just For Get The Size Local $iRASCONNSize = DllStructGetSize($tRASCONNSize) ;Just For Get The Size $tRASCONNSize = 0 ;Free $tBuffer.dwSize = $iRASCONNSize ;Fill the first dwSize of the array of RASCONN Structures $iRet = DllCall("Rasapi32.dll", "dword", "RasEnumConnectionsW", "ptr", DllStructGetPtr($tBuffer), "dword*", $tpcbSize, "dword*", 0) ;call For Get the Datas If $iRet[0] = $ERROR_SUCCESS Then Local $iConnections = $iRet[3] Local $atRasConn[$iConnections] ;Create an array of RASCONN Structures ;This is not the best way to do it :) (I gone fast) For $i = 1 To $iConnections $atRasConn[$i - 1] = DllStructCreate($tagRASCONN, DllStructGetPtr($tBuffer) + (($i - 1) * $iRASCONNSize)) ;Create the array of structure supplying the buffer Pointer using as index the RASCONN size MsgBox(0, "Conection " & $i, "szEntryName: " & $atRasConn[$i - 1].szEntryName) Next EndIf Else MsgBox(0, "", "There are no active RAS connections") EndIf ;then Free everything :)here is the type def for unicode.typedef struct tagRASCONNW { DWORD dwSize; HRASCONN hrasconn; WCHAR szEntryName[RAS_MaxEntryName + 1]; #if (WINVER >= 0x400) WCHAR szDeviceType[RAS_MaxDeviceType + 1]; WCHAR szDeviceName[RAS_MaxDeviceName + 1]; #endif #if (WINVER >= 0x401) WCHAR szPhonebook[MAX_PATH]; DWORD dwSubEntry; #endif #if (WINVER >= 0x500) GUID guidEntry; #endif #if (WINVER >= 0x501) DWORD dwFlags; LUID luid; #endif } RASCONNW, *LPRASCONNW; Saludos Edited May 11, 2015 by Danyfirex Starstar 1 Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut Link to comment Share on other sites More sharing options...
bernd670 Posted May 11, 2015 Share Posted May 11, 2015 (edited) There are apparently different definitions of struct RASCONN, thank Danyfirex.Moreover, the length of MAX_PATH was wrong.Stupid that I can not test it!expandcollapse popup#include <Array.au3> Global Const $RAS_MaxAreaCode = 10 Global Const $RAS_MaxPhoneNumber = 128 Global Const $RAS_MaxDeviceType = 16 Global Const $RAS_MaxDeviceName = 128 Global Const $RAS_MaxPadType = 32 Global Const $RAS_MaxX25Address = 200 Global Const $RAS_MaxFacilities = $RAS_MaxX25Address Global Const $RAS_MaxUserData = $RAS_MaxFacilities Global Const $RAS_MaxDnsSuffix = 256 Global Const $RAS_MaxEntryName = 256 Global Const $WM_RASDIALEVENT = 0xCCCD Global Const $RASCS_DONE = 0x2000 Global Const $WAIT_OBJECT_0 = 0 Global $hConection = 0 Global Const $MAX_PATH = 260 Global Const $tagGUID = "struct;DWORD GUID_Data1;WORD GUID_Data2;WORD GUID_Data3;BYTE GUID_Data[8];endstruct" Global Const $tagLUID = "struct;DWORD LUID_LowPart;LONG LUID_HighPart;endstruct" Global Const $tagRASCONN = "align 4;struct;dword dwSize;handle hrasconn;wchar szEntryName[" & $RAS_MaxEntryName + 1 & "];wchar szDeviceType[" & $RAS_MaxDeviceType + 1 & "];wchar szDeviceName[" & $RAS_MaxDeviceName + 1 & "];wchar szPhonebook[" & $MAX_PATH & "];DWORD dwSubEntry;" & $tagGUID; & ";DWORD dwFlags;" & $tagLUID & ";" & $tagGUID & ";endstruct" Global Const $tagREC_lpcb = "dword lpcb" Global Const $tagRec_lpcConns = "dword lpcConns" Local $tREC_lpcb = DllStructCreate($tagREC_lpcb) Local $tREC_lpcConns = DllStructCreate($tagRec_lpcConns) Sleep(100) ; get the required buffer size DllStructSetData($tREC_lpcb, "lpcb", 0) DllStructSetData($tREC_lpcConns, "lpcConns", 0) Local $aRet = DllCall("Rasapi32.dll", "dword", "RasEnumConnections", "ptr", Null, "ptr", DllStructGetPtr($tREC_lpcb), "ptr", DllStructGetPtr($tREC_lpcConns)) MsgBox(0, "get buffer size", "Error Code: " & $aRet[0] & @CRLF & "required buffer size: " & DllStructGetData($tREC_lpcb, "lpcb") & @CRLF & "number of RASCONN Structures: " & DllStructGetData($tREC_lpcConns, "lpcConns") & @CRLF ) ConsoleWrite("required buffer size: " & DllStructGetData($tREC_lpcb, "lpcb") & @CRLF) ; the required buffer size ConsoleWrite("Number of RASCON Structures: " & DllStructGetData($tREC_lpcConns, "lpcConns") & @CRLF) ; mumber of RASCON Structures If $aRet[0] = 603 Then ; ERROR_BUFFER_TOO_SMALL $iConns = DllStructGetData($tREC_lpcConns, "lpcConns") $tagRASCONNS = "" For $iStructs = 1 To $iConns $tagRASCONNS &= StringRegExpReplace($tagRASCONN, "\s+(.*?);", " RC" & $iStructs & "_$1" & ";") & ";" Next ;~ ConsoleWrite($tagRASCONNS & @CRLF) $tRASCONNS = DllStructCreate($tagRASCONNS) $iRASCONN_size = DllStructGetSize(DllStructCreate($tagRASCONN)) ;~ ConsoleWrite($iRASCONN_size & @CRLF) For $iStructs = 1 To $iConns DllStructSetData($tRASCONNS, "RC" & $iStructs & "_dwSize", $iRASCONN_size) Next ConsoleWrite("Size of Struct:" & DllStructGetSize($tRASCONNS) & @CRLF) DllStructSetData($tREC_lpcb, "lpcb", DllStructGetSize($tRASCONNS)) $aRet = DllCall("Rasapi32.dll", "dword", "RasEnumConnections", "ptr", DllStructGetPtr($tRASCONNS), "ptr", DllStructGetPtr($tREC_lpcb), "ptr", DllStructGetPtr($tREC_lpcConns)) MsgBox(0, "get data", "Error Code: " & $aRet[0] & @CRLF & "Size of Struct:" & DllStructGetSize($tRASCONNS) & @CRLF) For $iStructs = 1 To $iConns ConsoleWrite("EntryName of Conn " & $iStructs & ": " & DllStructGetData($tRASCONNS, "RC" & $iStructs & "_szEntryName") & @CRLF) Next EndIfEdit:In https://msdn.microsoft.com/en-us/library/windows/desktop/aa376725(v=vs.85).aspx is the following comment:Please add structure alignment 4 bytesIn x64, this structure should be aligned to 4 bytes. Otherwise the dwSize calculated by sizeof(RASCONN) is not accepted by RasEnumConnections(). Please add structure alignment 4 bytes.I have inserted also times in the struct Edited May 11, 2015 by bernd670 Starstar 1 greetingsbernd I hacked 127.0.0.1 -> Link to comment Share on other sites More sharing options...
Starstar Posted May 11, 2015 Author Share Posted May 11, 2015 (edited) Thanks to all(Who gave this platform) but special thanks goes to Danyfirex and bernd 670Danyfirex Your last code is working fine for me..........Thanks.bernd670; After changing wchar to char in $tagRASCONN structure your code is also work fine for me thanks. Edited May 11, 2015 by Starstar Life is like a coin. You can spend it Anyway as you wish and for your kind information. "you can spend it only once." Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now