Starstar Posted November 15, 2014 Share Posted November 15, 2014 (edited) expandcollapse popup#include <WinAPI.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 Local Const $DNLEN =15 Global Enum $RASCS_OpenPort = 0, $RASCS_PortOpened, $RASCS_ConnectDevice, $RASCS_DeviceConnected, $RASCS_AllDevicesConnected, _ $RASCS_Authenticate, $RASCS_AuthNotify, $RASCS_AuthRetry, $RASCS_AuthCallback, $RASCS_AuthChangePassword, $RASCS_AuthProject, _ $RASCS_AuthLinkSpeed, $RASCS_AuthAck, $RASCS_ReAuthenticate, $RASCS_Authenticated, $RASCS_PrepareForCallback, _ $RASCS_WaitForModemReset, $RASCS_WaitForCallback, $RASCS_Projected, _ $RASCS_StartAuthentication, _ $RASCS_CallbackComplete, _ $RASCS_LogonNetwork, _ $RASCS_SubEntryConnected, _ $RASCS_SubEntryDisconnected, _ $RASCS_ApplySettings, _ $RASCS_Interactive = 0x1000, _ $RASCS_RetryAuthentication, _ $RASCS_CallbackSetByCaller, _ $RASCS_PasswordExpired, _ $RASCS_InvokeEapUI, _ $RASCS_Connected = 0x2000, _ $RASCS_Disconnected Func RasDialFunc1($hrasconn, $iMsg, $rasconnstate, $dwError, $dwExtendedError) If $dwError Then Local $aRet = DllCall("Rasapi32.dll", "dword", "RasGetErrorStringW", "uint", $dwError, "wstr", "", "dword", 256) Sleep(100) ConsoleWrite("!" & $aRet[2] & @CRLF) EndIf Switch $rasconnstate Case $RASCS_OpenPort ConsoleWrite("Opening port..." & @CRLF) Case $RASCS_PortOpened ConsoleWrite("Port Opened..." & @CRLF) Case $RASCS_ConnectDevice ConsoleWrite("Connecting device..." & @CRLF) Case $RASCS_DeviceConnected ConsoleWrite("Device connected..." & @CRLF) Case $RASCS_AllDevicesConnected ConsoleWrite("All devices connected..." & @CRLF) Case $RASCS_Authenticate ConsoleWrite("Authenticating..." & @CRLF) Case $RASCS_AuthNotify ConsoleWrite("Authentication notify..." & @CRLF) Case $RASCS_AuthRetry ConsoleWrite("Retrying authentication..." & @CRLF) Case $RASCS_AuthCallback ConsoleWrite("Authentication callback..." & @CRLF) Case $RASCS_AuthChangePassword ConsoleWrite("Change password..." & @CRLF) Case $RASCS_AuthProject ConsoleWrite("Projection phase started..." & @CRLF) Case $RASCS_AuthLinkSpeed ConsoleWrite("Negotiating speed..." & @CRLF) Case $RASCS_AuthAck ConsoleWrite("Authentication acknowledge..." & @CRLF) Case $RASCS_ReAuthenticate ConsoleWrite("Retrying Authentication..." & @CRLF) Case $RASCS_Authenticated ConsoleWrite("Authentication complete..." & @CRLF) Case $RASCS_PrepareForCallback ConsoleWrite("Preparing for callback..." & @CRLF) Case $RASCS_WaitForModemReset ConsoleWrite("Waiting for modem reset..." & @CRLF) Case $RASCS_WaitForCallback ConsoleWrite("Waiting for callback..." & @CRLF) Case $RASCS_Projected ConsoleWrite("Projection completed..." & @CRLF) Case $RASCS_StartAuthentication ConsoleWrite("Starting authentication..." & @CRLF) Case $RASCS_CallbackComplete ConsoleWrite("Callback complete..." & @CRLF) Case $RASCS_LogonNetwork ConsoleWrite("Logon to the network..." & @CRLF) Case $RASCS_SubEntryConnected ConsoleWrite("Subentry connected..." & @CRLF) Case $RASCS_SubEntryDisconnected ConsoleWrite("Subentry disconnected..." & @CRLF) Case $RASCS_Connected ConsoleWrite("Connection completed." & @CRLF) Case $RASCS_Disconnected ConsoleWrite("Disconnecting..." & @CRLF) Case Else ConsoleWrite("Unknown Status = " & $rasconnstate & @CRLF) EndSwitch EndFunc ;==>RasDialFunc Global $tagRASCONNSTATUS = "dword dwSize;dword rasconnstate;wchar szDeviceType[" & $RAS_MaxDeviceType & "];wchar szDeviceName[" & $RAS_MaxDeviceName & "];" & _ "wchar szPhoneNumber[" & $RAS_MaxPhoneNumber & "];dword localEndPoint;byte[16];word[8];dword remoteEndPoint;byte[16];word[8];dword rasconnsubstate" Global Const $tagRASDIALPARAMS = "dword dwSize;wchar szEntryName["& $RAS_MaxDnsSuffix +1 &"];wchar szPhoneNumber["& $RAS_MaxDeviceName +1 &"];wchar szCallbackNumber["& $RAS_MaxDeviceName +1 & "];wchar szUserName[" & $RAS_MaxDnsSuffix +1 & "];wchar szPassword["& $RAS_MaxDnsSuffix + 1 & "];wchar szDomain["&$DNLEN +1 &"];dword dwSubEntry;ULONG_PTR dwCallbackId;dword dwIfIndex" Local $tRASDIALPARAMS = DllStructCreate($tagRASDIALPARAMS) $tRASDIALPARAMS.dwSize = DllStructGetSize($tRASDIALPARAMS) DllStructSetData($tRASDIALPARAMS, "szEntryName", "DM-LINK") DllStructSetData($tRASDIALPARAMS, "szPhoneNumber", "") DllStructSetData($tRASDIALPARAMS, "szCallbackNumber", "") DllStructSetData($tRASDIALPARAMS, "szUserName", "PPP455") DllStructSetData($tRASDIALPARAMS, "szPassword", "455") DllStructSetData($tRASDIALPARAMS, "szDomain", "") Local $FilePath=@AppDataDir & "\Microsoft\Network\Connections\Pbk\rasphone.pbk" Local $hHandle = DllCallbackRegister("RasDialFunc1", "none", "HANDLE*;UINT;lparam;wparam;wparam") Local $iRet = DllCall("Rasapi32.dll", "dword", "RasDialW", "ptr", 0,"wstr",$FilePath, "ptr",DllStructGetPtr($tRASDIALPARAMS), "dword", 1, "ptr", DllCallbackGetPtr($hHandle), "handle*", NULL) Sleep(150) MsgBox(0,"Function Return","RasDial : "&$iRet[0]) Sleep(300) DllCallbackFree($hHandle) Function is not receiving $dwError. Why? i could not know. Please Help me. Edited November 15, 2014 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...
Danyfirex Posted November 15, 2014 Share Posted November 15, 2014 (edited) Don't put Sleep In the Callback. Your Code is connecting to rasdial correctly? Saludos PD:I lost my USB where I had the example. If I have time. I'll rewrite the example. Edited November 15, 2014 by Danyfirex 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 November 15, 2014 Author Share Posted November 15, 2014 Don't put Sleep In the Callback. Your Code is connecting to rasdial correctly? Saludos PD:I lost my USB where I had the example. If I have time. I'll rewrite the example. ok and thanks i shall remove sleep() from dll. 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 November 15, 2014 Share Posted November 15, 2014 (edited) your code dial-up Correctly? Edit: my code was base on this take a look. Saludos Edited November 15, 2014 by Danyfirex 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 November 15, 2014 Author Share Posted November 15, 2014 (edited) your code dial-up Correctly? Edit: my code was base on this take a look. Saludos yes bro i know it is dial -up correctly but whenever some problem etc.. server is not available occurred script was close and dialing modem Jam at connecting.error was not occurred while it was. Edited November 15, 2014 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...
Danyfirex Posted November 15, 2014 Share Posted November 15, 2014 You need to create the event. check the status and set the event state. Look the C++ example above. 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...
Starstar Posted November 15, 2014 Author Share Posted November 15, 2014 You need to create the event. check the status and set the event state. Look the C++ example above. Saludos Thanks for hint........now i am going to trying WINAPI CreateEvent() Function. 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 November 15, 2014 Share Posted November 15, 2014 any doubt ask for... Saludos 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 November 15, 2014 Author Share Posted November 15, 2014 Global Const $RAS_MaxDeviceType = 16 Global Const $RAS_MaxDeviceName = 128 Global Const $RAS_MaxPhoneNumber = 128 Global $RASCONNSTATUS = "dword dwSize;dword rasconnstate;dword DwError;wchar szDeviceType[" & $RAS_MaxDeviceType +1 & "];wchar szDeviceName[" & $RAS_MaxDeviceName +1 & "];" & _ "wchar szPhoneNumber[" & $RAS_MaxPhoneNumber +1 & "];dword localEndPoint;byte[16];word[8];dword remoteEndPoint;byte[16];word[8];dword rasconnsubstate" Local $tRASStatus = DllStructCreate($RASCONNSTATUS) Local $iRas = DllCall("Rasapi32.dll", "dword", "RasGetConnectStatusW","handle*", "*lphRasConn","ptr",$tRASStatus) MsgBox(0,"Return",$iRas[0]) i am trying to get rasconnection status but i got error 87 ERROR_INVALID_PARAMETER. 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 November 15, 2014 Share Posted November 15, 2014 Your API call is wrong. Should be so: Local $iRas = DllCall("Rasapi32.dll", "dword", "RasGetConnectStatusW","handle",$yourhandle,"ptr",DllStructGetPtr($tRASStatus)) Remember set the dwSize before the call. 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...
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