Sign in to follow this  
Followers 0
Starstar

I am trying Rasdial() DLL function

28 posts in this topic

#1 ·  Posted (edited)

Local Const $UNLEN=256
Local Const $PWLEN = 256
Local Const $ENLEN = 256
Local Const $PHLEN = 256
Local Const $CBLEN = 256
Local Const $CNLEN =15
Local Const $DNLEN =$CNLEN

  Local Const $MAX_PATH = 260
    Local Const $RAS_MaxDeviceType = 16
    Local Const $RAS_MaxEntryName = 256
    Local Const $RAS_MaxDeviceName = 128
$phnbook ="C:\Users\Adnan\AppData\Roaming\Microsoft\Network\Connections\Pbk\rasphone.pbk"
$entry ="HM-LINK"
$sTagRASCREDENTIALS = "struct;dword dwSize;wcahr szEntryName["&$ENLEN+1 &"]; wchar szPhoneNumber["&$PHLEN+1 &"];wcahr szCallBackNumber["&$CBLEN+1&"]; wchar szUserName[" & $UNLEN+1 & "];wchar szPassword["& $PWLEN+1 & "];wchar szDomain[" & $DNLEN+1 &"];DWORD szSabEntry; ULONG_PTR dwCallbackId;Doword dwIfIndex; endstruct"
Local $tTRASCREDENTIALS=DllStructCreate($sTagRASCREDENTIALS)
$noti = DllStructCreate("doword")
 $tRASCONN = DllStructCreate("dword dwSize;hwnd hRasConn;char szEntryName[" & $RAS_MaxEntryName + 1 & "];" & _
                                "char szDeviceType[" & $RAS_MaxDeviceType + 1 & "];" & _
                                "char szDeviceName[" & $RAS_MaxDeviceName + 1 & "];" & _
                                "char szPhonebook["  & $MAX_PATH & "];" & _
                                "dword dwSubEntry;byte guidEntry[16];dword dwFlags;byte luid[8]")
DllStructSetData($tTRASCREDENTIALS,"dwSize",DllStructGetSize($tTRASCREDENTIALS))
DllStructSetData($tTRASCREDENTIALS,"szEntryName",$entry)
DllStructSetData($tTRASCREDENTIALS,"szPhoneNumber","")
DllStructSetData($tTRASCREDENTIALS,"szCallBackNumber","")
DllStructSetData($tTRASCREDENTIALS,"szUserName","asdas")
DllStructSetData($tTRASCREDENTIALS,"szPassword","atest02")
DllStructSetData($tTRASCREDENTIALS,"szDomain","")
DllStructSetData($tTRASCREDENTIALS,"szSabEntry","")
DllStructSetData($tTRASCREDENTIALS,"dwCallbackId","")
DllStructSetData($tTRASCREDENTIALS,"dwIfIndex","")

$msg = DllCall("Rasapi32.dll","DWORD","RasDial","","NULL","str",$phnbook,"struct*",$tTRASCREDENTIALS,"","NULL","hwnd", DllStructGetData($tRASCONN, "hRasConn"))

There is a problem with this script.......Please Guide me......

Edit::

Function Link.

Edited 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."

Share this post


Link to post
Share on other sites



#3 ·  Posted (edited)

Care to at least outline it?

Hmmm

Edited 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."

Share this post


Link to post
Share on other sites

Fair enough.

ha ha ha................


Life is like a coin. You can spend it Anyway as you wish and for your kind information. "you can spend it only once."

Share this post


Link to post
Share on other sites

Should be something like this:

$msg = DllCall("Rasapi32.dll","DWORD","RasDial","ptr",0,"str",$phnbook,"struct*",$tTRASCREDENTIALS,"ptr",0,"hwnd", 0,"hwnd*",0)

$hrasconn=$msg[6]

saludos

1 person likes this

 

venezuela.png Would you like to say thank to Danyfirex using a warmy way?  offer me a cup of coffee... coffee.png

autoit_scripter_blue_userbar.png

       AutoIt...

 

 

Share this post


Link to post
Share on other sites

Should be something like this:

$msg = DllCall("Rasapi32.dll","DWORD","RasDial","ptr",0,"str",$phnbook,"struct*",$tTRASCREDENTIALS,"ptr",0,"hwnd", 0,"hwnd*",0)

$hrasconn=$msg[6]

saludos

ok thank.........


Life is like a coin. You can spend it Anyway as you wish and for your kind information. "you can spend it only once."

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

#include <MsgBoxConstants.au3>
#include <GUIConstantsEx.au3>

Local Const $UNLEN=256
Local Const $PWLEN = 256
Local Const $ENLEN = 256
Local Const $PHLEN = 256
Local Const $CBLEN = 256
Local Const $CNLEN =15
Local Const $DNLEN =$CNLEN

  Local Const $MAX_PATH = 260
    Local Const $RAS_MaxDeviceType = 16
    Local Const $RAS_MaxEntryName = 256
    Local Const $RAS_MaxDeviceName = 128
$phnbook ="C:\Users\Adnan\AppData\Roaming\Microsoft\Network\Connections\Pbk\rasphone.pbk"
$entry ="HM-LINK"
$sTagRASCREDENTIALS = "struct;dword dwSize;wcahr szEntryName["&$ENLEN+1 &"]; wchar szPhoneNumber["&$PHLEN+1 &"];wcahr szCallBackNumber["&$CBLEN+1&"]; wchar szUserName[" & $UNLEN+1 & "];wchar szPassword["& $PWLEN+1 & "];wchar szDomain[" & $DNLEN+1 &"];DWORD szSabEntry; ULONG_PTR dwCallbackId;Doword dwIfIndex; endstruct"
Local $tTRASCREDENTIALS=DllStructCreate($sTagRASCREDENTIALS)
 $tRASCONN = DllStructCreate("dword dwSize;hwnd hRasConn;char szEntryName[" & $RAS_MaxEntryName + 1 & "];" & _
                                "char szDeviceType[" & $RAS_MaxDeviceType + 1 & "];" & _
                                "char szDeviceName[" & $RAS_MaxDeviceName + 1 & "];" & _
                                "char szPhonebook["  & $MAX_PATH & "];" & _
                                "dword dwSubEntry;byte guidEntry[16];dword dwFlags;byte luid[8]")

                                $tRAS_Noti = DllStructCreate("dword dwSize;dword dwBytesXmited;dword dwBytesRcved;dword dwFramesXmited;" & _
                                  "dword dwFramesRcved;dword dwCrcErr;dword dwTimeoutErr;dword dwAlignmentErr;" & _
                                  "dword dwHardwareOverrunErr;dword dwFramingErr;dword dwBufferOverrunErr;" & _
                                  "dword dwCompressionRatioIn;dword dwCompressionRatioOut;dword dwBps;dword dwConnectDuration")


DllStructSetData($tTRASCREDENTIALS,"dwSize",DllStructGetSize($tTRASCREDENTIALS))
DllStructSetData($tRAS_Noti, "dwSize", DllStructGetSize($tRAS_Noti))
DllStructSetData($tRASCONN, "dwSize", DllStructGetSize($tRASCONN))
DllStructSetData($tTRASCREDENTIALS,"szEntryName",$entry)
DllStructSetData($tTRASCREDENTIALS,"szPhoneNumber","")
DllStructSetData($tTRASCREDENTIALS,"szCallBackNumber","")
DllStructSetData($tTRASCREDENTIALS,"szUserName","asdas")
DllStructSetData($tTRASCREDENTIALS,"szPassword","atest02")
DllStructSetData($tTRASCREDENTIALS,"szDomain","")
DllStructSetData($tTRASCREDENTIALS,"szSabEntry","")
Local $hHandle = DllCallbackRegister("_lpvNotifier","","unMsg; rasconnstate; dwError")
DllStructSetData($tTRASCREDENTIALS,"dwCallbackId","")
DllStructSetData($tTRASCREDENTIALS,"dwIfIndex","")
$noti = DllStructCreate("dword")

$msg32 = DllCall("Rasapi32.dll","dword","RasDial","ptr",0,"str",$phnbook,"struct*",$tTRASCREDENTIALS,"doword",0,"ptr", DllCallbackGetPtr($hHandle),"hwnd",0)

DllCallbackFree($hHandle)




$GUi = GUICreate("HM",200,150,-1,-1)
$label = GUICtrlCreateLabel("",10,10,180,130)
GUISetState(@SW_SHOW)
While 1
    $gMsg = GUIGetMsg()
    GUICtrlSetData($label, $msg32[2])
    Switch $gMsg
        Case $GUI_Event_Close
            ExitLoop
            Exit
EndSwitch
WEnd

i think this function should be something like this. Please Tell me where am i wrong?

Edited 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."

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

DllCallbackRegister should look like this:

Local $hHandle = DllCallbackRegister("_lpvNotifier","none","UINT;DWORD;DWORD")

look the dllcallbackregister help.

Create the _lpvNotifier Functions, and look if it's working all right.

Be carefull in dllcall it's dword not doword.

 

Saludos

Edited by Danyfirex
1 person likes this

 

venezuela.png Would you like to say thank to Danyfirex using a warmy way?  offer me a cup of coffee... coffee.png

autoit_scripter_blue_userbar.png

       AutoIt...

 

 

Share this post


Link to post
Share on other sites

#10 ·  Posted

#include <WinAPI.au3>

_RasDial("HM-LINK","UserName","Pass",'','','',0,'C:\Users\Adnan\AppData\Roaming\Microsoft\Network\Connections\Pbk\rasphone.pbk','',0)

Func _RasDial($sConnectName,$sUserName,$sPassword,$sDomain='',$sPhoneNumber='',$sCallbackNumber='',$vRasDialExtensions=0,$sPhonebook='',$vNotifierType='',$hNotifier=0)
    Local Const $MAX_PATH              = 260
    Local Const $RAS_MaxEntryName      = 256
    Local Const $RAS_MaxPhoneNumber    = 128
    Local Const $RAS_MaxCallbackNumber = 128
    Local Const $UNLEN                 = 128
    Local Const $PWLEN                 = 128
    Local Const $DNLEN                 = 128
    Local Const $RAS_MaxDeviceType     = 16
    Local Const $RAS_MaxDeviceName     = 128

    Local $tRASDIALPARAMS=DllStructCreate( _
    'dword dwSize;' & _
    'char szEntryName['      & $RAS_MaxEntryName      + 1 &'];' & _
    'char szPhoneNumber['    & $RAS_MaxPhoneNumber    + 1 &'];' & _
    'char szCallbackNumber[' & $RAS_MaxCallbackNumber + 1 &'];' & _
    'char szUserName['       & $UNLEN                 + 1 &'];' & _
    'char szPassword['       & $PWLEN                 + 1 &'];' & _
    'char szDomain['         & $DNLEN                 + 1 &'];' & _
    'dword dwSubEntry;' & _
    'ulong_ptr dwCallbackId;' & _
    'dword dwIfIndex')

   DllStructSetData($tRASDIALPARAMS,'dwSize',          DllStructGetSize($tRASDIALPARAMS))
   DllStructSetData($tRASDIALPARAMS,'szEntryName'     ,$sConnectName)
   DllStructSetData($tRASDIALPARAMS,'szPhoneNumber'   ,$sPhoneNumber)
   DllStructSetData($tRASDIALPARAMS,'szCallbackNumber',$sCallbackNumber)
   DllStructSetData($tRASDIALPARAMS,'szUserName',      $sUserName)
   DllStructSetData($tRASDIALPARAMS,'szPassword',      $sPassword)
   DllStructSetData($tRASDIALPARAMS,'szDomain',        $sDomain)
   DllStructSetData($tRASDIALPARAMS,'dwSubEntry',      0)
   DllStructSetData($tRASDIALPARAMS,'dwCallbackId',    0)
   DllStructSetData($tRASDIALPARAMS,'dwIfIndex',       0)

    Local $tRASCONN = DllStructCreate( _
    'dword dwSize;hwnd hRasConn;' & _
    'char szEntryName[' & $RAS_MaxEntryName  +1 &'];' & _
    'char szDeviceType['& $RAS_MaxDeviceType +1 &'];' & _
    'char szDeviceName['& $RAS_MaxDeviceName +1 &'];' & _
    'char szPhonebook[' & $MAX_PATH &'];' & _
    'dword dwSubEntry;byte guidEntry[16];dword dwFlags;byte luid[8]')

    Local $pRASDIALPARAMS = DllStructGetPtr($tRASDIALPARAMS)
    Local $pRASCONN       = DllStructGetPtr($tRASCONN)

    Local $aRet = DllCall('rasapi32.dll', 'int', 'RasDialW', 'ptr',$vRasDialExtensions,'str',$sPhonebook,'ptr',$pRASDIALPARAMS,'int',$vNotifierType,'hwnd', $hNotifier,'ptr',$pRASCONN)


    ConsoleWrite(DllStructGetData($tRASDIALPARAMS,1) & @CRLF)
    ConsoleWrite(DllStructGetData($tRASDIALPARAMS,2)& @CRLF)
    ConsoleWrite(DllStructGetData($tRASDIALPARAMS,5)& @CRLF)
    ConsoleWrite(DllStructGetData($tRASDIALPARAMS,6)& @CRLF)
    ConsoleWrite($aRet[0]& @CRLF)

    Local $hRasConn =  DllStructGetData($tRASCONN,'hRasConn')
    Return SetError(_WinAPI_GetLastError(), 0, $hRasConn)
EndFunc

i got return array of function "632"(Incorrect structure size).How can i solve it? Please guide me.


Life is like a coin. You can spend it Anyway as you wish and for your kind information. "you can spend it only once."

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

if you gonna use unicode API Call. use unicode string wstr. for structures wchar.

Saludos

Edited by Danyfirex

 

venezuela.png Would you like to say thank to Danyfirex using a warmy way?  offer me a cup of coffee... coffee.png

autoit_scripter_blue_userbar.png

       AutoIt...

 

 

Share this post


Link to post
Share on other sites

#12 ·  Posted

if you gonna use unicode API Call. use unicode string wstr. for structures wchar.

Saludos

i also tried like this..........But error is same 632.

#include <WinAPI.au3>

_RasDial("HM-LINK","UserName","Pass",'','','',0,'C:\Users\Adnan\AppData\Roaming\Microsoft\Network\Connections\Pbk\rasphone.pbk','',0)

Func _RasDial($sConnectName,$sUserName,$sPassword,$sDomain='',$sPhoneNumber='',$sCallbackNumber='',$vRasDialExtensions=0,$sPhonebook='',$vNotifierType='',$hNotifier=0)
    Local Const $MAX_PATH              = 256
    Local Const $RAS_MaxEntryName      = 256
    Local Const $RAS_MaxPhoneNumber    = 256
    Local Const $RAS_MaxCallbackNumber = 256
    Local Const $USLEN                 = 256
    Local Const $PWLEN                 = 256
    Local Const $DNLEN                 = 256
    Local Const $RAS_MaxDeviceType     = 256
    Local Const $RAS_MaxDeviceName     = 256

    Local $tRASDIALPARAMS=DllStructCreate( _
    'dword dwSize;' & _
    'wchar szEntryName['      & $RAS_MaxEntryName      + 1 &'];' & _
    'wchar szPhoneNumber['    & $RAS_MaxPhoneNumber    + 1 &'];' & _
    'wchar szCallbackNumber[' & $RAS_MaxCallbackNumber + 1 &'];' & _
    'wchar szUserName['       & $USLEN                 + 1 &'];' & _
    'wchar szPassword['       & $PWLEN                 + 1 &'];' & _
    'wchar szDomain['         & $DNLEN                 + 1 &'];' & _
    'dword dwSubEntry;' & _
    'ulong_ptr dwCallbackId;' & _
    'dword dwIfIndex')

   DllStructSetData($tRASDIALPARAMS,'dwSize',          DllStructGetSize($tRASDIALPARAMS))
   DllStructSetData($tRASDIALPARAMS,'szEntryName'     ,$sConnectName)
   DllStructSetData($tRASDIALPARAMS,'szPhoneNumber'   ,$sPhoneNumber)
   DllStructSetData($tRASDIALPARAMS,'szCallbackNumber',$sCallbackNumber)
   DllStructSetData($tRASDIALPARAMS,'szUserName',      $sUserName)
   DllStructSetData($tRASDIALPARAMS,'szPassword',      $sPassword)
   DllStructSetData($tRASDIALPARAMS,'szDomain',        $sDomain)
   DllStructSetData($tRASDIALPARAMS,'dwSubEntry',      0)
   DllStructSetData($tRASDIALPARAMS,'dwCallbackId',    0)
   DllStructSetData($tRASDIALPARAMS,'dwIfIndex',       0)

    Local $tRASCONN = DllStructCreate( _
    'dword dwSize; hwnd hRasConn;' & _
    'wchar szEntryName[' & $RAS_MaxEntryName  +1 &'];' & _
    'wchar szDeviceType['& $RAS_MaxDeviceType +1 &'];' & _
    'wchar szDeviceName['& $RAS_MaxDeviceName +1 &'];' & _
    'wchar szPhonebook[' & $MAX_PATH &'];' & _
    'dword dwSubEntry;byte guidEntry[16];dword dwFlags;byte luid[8]')

    Local $pRASDIALPARAMS = DllStructGetPtr($tRASDIALPARAMS)
    Local $pRASCONN       = DllStructGetPtr($tRASCONN)

    Local $aRet = DllCall('rasapi32.dll', 'dword', 'RasDialW', 'ptr',$vRasDialExtensions,'wstr',$sPhonebook,'ptr',$pRASDIALPARAMS,'dword',$vNotifierType,'hwnd', $hNotifier,'ptr',$pRASCONN)




    ConsoleWrite(DllStructGetData($tRASDIALPARAMS,1) & @CRLF)
    ConsoleWrite(DllStructGetData($tRASDIALPARAMS,2)& @CRLF)
    ConsoleWrite(DllStructGetData($tRASDIALPARAMS,5)& @CRLF)
    ConsoleWrite(DllStructGetData($tRASDIALPARAMS,6)& @CRLF)
    $as=DllStructGetSize($tRASDIALPARAMS)
    ConsoleWrite($aRet[0]& @CRLF&"Size: " &$as& @CRLF)

    Local $hRasConn =  DllStructGetData($tRASCONN,'hRasConn')
    Return SetError(_WinAPI_GetLastError(), 0, $hRasConn)
EndFunc

Life is like a coin. You can spend it Anyway as you wish and for your kind information. "you can spend it only once."

Share this post


Link to post
Share on other sites

#13 ·  Posted

Really I don't have time to test right now. but look this C++ example: http://bcbjournal.org/articles/vol3/9903/Using_RAS__part_1.htm?PHPSESSID=615cdf1808b8147b2e52d1cb980787a9

Saludos


 

venezuela.png Would you like to say thank to Danyfirex using a warmy way?  offer me a cup of coffee... coffee.png

autoit_scripter_blue_userbar.png

       AutoIt...

 

 

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

I think you RASCONN structure should have 11 elements. Yours has 10.

look the example above, also look this example. If you want can go first with the ANSI. if all is right, then pass it to unicode.

Also: I think the last parameter of RasDial is not a pointer to a  RASCONN structure. I think msdn says to a handle data type hrasconn. 

so should be so:

Local $pRASCONN       = DllStructGetPtr($tRASCONN,"hRasConn")

or You can try as I saw some message above

$msg = DllCall("Rasapi32.dll","DWORD","RasDial","ptr",0,"str",$phnbook,"struct*",$tTRASCREDENTIALS,"ptr",0,"hwnd", 0,"hwnd*",0) $hrasconn=$msg[6]

Saludos

Edited by Danyfirex
1 person likes this

 

venezuela.png Would you like to say thank to Danyfirex using a warmy way?  offer me a cup of coffee... coffee.png

autoit_scripter_blue_userbar.png

       AutoIt...

 

 

Share this post


Link to post
Share on other sites

Local Const $UNLEN=256
Local Const $PHLEN=256
Local Const $CBLEN=256
Local Const $ENLEN=256
Local Const $PWLEN = 256
Local Const $CNLEN =15
Local Const $DNLEN =$CNLEN
$entry = "HM-LINK"
$phnbook =@AppDataDir & "\Microsoft\Network\Connections\Pbk\rasphone.pbk"

$sTagRASCREDENTIALS = "struct;dword dwSize;wchar szEntryName[" & $ENLEN+1 & "];wchar szPhoneNumber[" & $PHLEN+1 & "];wchar szCallbackNumber[" & $CBLEN+1 & "];wchar szUserName[" & $UNLEN+1 & "];wchar szPassword["& $PWLEN+1 & "];wchar szDomain[" & $DNLEN+1 &"];dword dwSubEntry; ULONG_PTR dwCallbackId; DWORD dwIfIndex; endstruct"
Local $tTRASCREDENTIALS=DllStructCreate($sTagRASCREDENTIALS)
DllStructSetData($tTRASCREDENTIALS,"dwSize",DllStructGetSize($tTRASCREDENTIALS))
DllStructSetData($tTRASCREDENTIALS,"szEntryName",$entry)
DllStructSetData($tTRASCREDENTIALS,"szPhoneNumber","")
DllStructSetData($tTRASCREDENTIALS,"szCallbackNumber","")
DllStructSetData($tTRASCREDENTIALS,"szUserName","test")
DllStructSetData($tTRASCREDENTIALS,"szPassword","test")
DllStructSetData($tTRASCREDENTIALS,"szDomain","")
DllStructSetData($tTRASCREDENTIALS,"dwSubEntry","")
DllStructSetData($tTRASCREDENTIALS,"dwCallbackId",DllStructGetPtr($tTRASCREDENTIALS,"dwCallbackId"))
DllStructSetData($tTRASCREDENTIALS,"dwIfIndex","")
$msg = DllCall("Rasapi32.dll","DWORD","RasdialW",Null,"wstr",$phnbook,"struct*",$tTRASCREDENTIALS,Null,Null)
MsgBox(0,"",@error)

I got Error 4 bad number of parameters.


Life is like a coin. You can spend it Anyway as you wish and for your kind information. "you can spend it only once."

Share this post


Link to post
Share on other sites

Try this Code check the return.

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 $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[256];wchar szPhoneNumber[128];wchar szCallbackNumber[128];wchar szUserName[256];wchar szPassword[256];wchar szDomain[15];dword dwSubEntry;ULONG_PTR dwCallbackId;dword dwIfIndex"
Local $tRASDIALPARAMS = DllStructCreate($tagRASDIALPARAMS)
$tRASDIALPARAMS.dwSize = DllStructGetSize($tRASDIALPARAMS)


DllStructSetData($tRASDIALPARAMS, "szEntryName", "HM-LINK")
DllStructSetData($tRASDIALPARAMS, "szPhoneNumber", "")
DllStructSetData($tRASDIALPARAMS, "szUserName", "")
DllStructSetData($tRASDIALPARAMS, "szPassword", "")
DllStructSetData($tRASDIALPARAMS, "szDomain", "")




Local $FilePath=@AppDataDir & "\Microsoft\Network\Connections\Pbk\rasphone.pbk"

Local $iRet = DllCall("Rasapi32.dll", "dword", "RasDialW", "ptr", 0,"wstr",$FilePath, "ptr", DllStructGetPtr($tRASDIALPARAMS), "dword", 0, "ptr", Null, "handle*", NULL)

MsgBox(0,"",$iRet[0])

If $iRet[0] Then
    Local $Ret = DllCall("Rasapi32.dll", "dword", "RasGetErrorStringW", "uint", $iRet[0], "wstr", NULL, "dword", 256)
    ConsoleWrite( $Ret[2] & @CRLF)
    $hConection = $iRet[6]
Else
    ConsoleWrite("Rasdial OK" & @CRLF)
    $hConection = $iRet[6]
EndIf

Saludos

1 person likes this

 

venezuela.png Would you like to say thank to Danyfirex using a warmy way?  offer me a cup of coffee... coffee.png

autoit_scripter_blue_userbar.png

       AutoIt...

 

 

Share this post


Link to post
Share on other sites

Try this Code check the return.

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 $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[256];wchar szPhoneNumber[128];wchar szCallbackNumber[128];wchar szUserName[256];wchar szPassword[256];wchar szDomain[15];dword dwSubEntry;ULONG_PTR dwCallbackId;dword dwIfIndex"
Local $tRASDIALPARAMS = DllStructCreate($tagRASDIALPARAMS)
$tRASDIALPARAMS.dwSize = DllStructGetSize($tRASDIALPARAMS)


DllStructSetData($tRASDIALPARAMS, "szEntryName", "HM-LINK")
DllStructSetData($tRASDIALPARAMS, "szPhoneNumber", "")
DllStructSetData($tRASDIALPARAMS, "szUserName", "")
DllStructSetData($tRASDIALPARAMS, "szPassword", "")
DllStructSetData($tRASDIALPARAMS, "szDomain", "")




Local $FilePath=@AppDataDir & "\Microsoft\Network\Connections\Pbk\rasphone.pbk"

Local $iRet = DllCall("Rasapi32.dll", "dword", "RasDialW", "ptr", 0,"wstr",$FilePath, "ptr", DllStructGetPtr($tRASDIALPARAMS), "dword", 0, "ptr", Null, "handle*", NULL)

MsgBox(0,"",$iRet[0])

If $iRet[0] Then
    Local $Ret = DllCall("Rasapi32.dll", "dword", "RasGetErrorStringW", "uint", $iRet[0], "wstr", NULL, "dword", 256)
    ConsoleWrite( $Ret[2] & @CRLF)
    $hConection = $iRet[6]
Else
    ConsoleWrite("Rasdial OK" & @CRLF)
    $hConection = $iRet[6]
EndIf

Saludos

i got Error 651.


Life is like a coin. You can spend it Anyway as you wish and for your kind information. "you can spend it only once."

Share this post


Link to post
Share on other sites

That means Your modem (or other connecting device) has reported an error.

conect the modem manually and check that it works corretly. then try rasdial call again.

Saludos

1 person likes this

 

venezuela.png Would you like to say thank to Danyfirex using a warmy way?  offer me a cup of coffee... coffee.png

autoit_scripter_blue_userbar.png

       AutoIt...

 

 

Share this post


Link to post
Share on other sites

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 $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[256];wchar szPhoneNumber[128];wchar szCallbackNumber[128];wchar szUserName[256];wchar szPassword[256];wchar szDomain[15];dword dwSubEntry;ULONG_PTR dwCallbackId;dword dwIfIndex"
Local $tRASDIALPARAMS = DllStructCreate($tagRASDIALPARAMS)
$tRASDIALPARAMS.dwSize = DllStructGetSize($tRASDIALPARAMS)


DllStructSetData($tRASDIALPARAMS, "szEntryName", "HM-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 $iRet = DllCall("Rasapi32.dll", "dword", "RasDialW", "ptr", 0,"wstr",$FilePath, "ptr", DllStructGetPtr($tRASDIALPARAMS), "dword", 0, "ptr", Null, "handle*", NULL)

MsgBox(0,"",$iRet[0])

If $iRet[0] Then
    Local $Ret = DllCall("Rasapi32.dll", "dword", "RasGetErrorStringW", "uint", $iRet[0], "wstr", NULL, "dword", 256)
    ConsoleWrite( $Ret[2] & @CRLF)
    $hConection = $iRet[6]
Else
    ConsoleWrite("Rasdial OK" & @CRLF)
    $hConection = $iRet[6]
EndIf

When i run script after few seconds i got error 691. But after dialing manually script run correctly and i got 0.

Special Thanks to Danyfirex. 


Life is like a coin. You can spend it Anyway as you wish and for your kind information. "you can spend it only once."

Share this post


Link to post
Share on other sites

#20 ·  Posted (edited)

;Danyfirex
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
;Danyfirex

Local Const $DNLEN =15;Danyfirex

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";Danyfirex



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" ; Only structure By Starstar;Danyfirex
Local $tRASDIALPARAMS = DllStructCreate($tagRASDIALPARAMS)
$tRASDIALPARAMS.dwSize = DllStructGetSize($tRASDIALPARAMS)


DllStructSetData($tRASDIALPARAMS, "szEntryName", "HM-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 $iRet = DllCall("Rasapi32.dll", "dword", "RasDialW", "ptr", 0,"wstr",$FilePath, "ptr",DllStructGetPtr($tRASDIALPARAMS), "dword", 0, "ptr", Null, "handle*", NULL)

MsgBox(0,"",$iRet[0])

If $iRet[0] Then
    Local $Ret = DllCall("Rasapi32.dll", "dword", "RasGetErrorStringW", "uint", $iRet[0], "wstr", NULL, "dword", 256)
    ConsoleWrite( $Ret[2] & @CRLF)
    $hConection = $iRet[6]
Else
    ConsoleWrite("Rasdial OK" & @CRLF)
    $hConection = $iRet[6]
EndIf;Danyfirex

Special Thanks to Danyfirex. I could never solve it without your help Danyfirex...........Thanks a lot of you. May God Bless you....

Edited by Starstar
1 person likes this

Life is like a coin. You can spend it Anyway as you wish and for your kind information. "you can spend it only once."

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0