Jump to content

Where Am i wrong?DllCall


 Share

Recommended Posts

DllCall("Rasapi32.dll","ERROR_SUCCESS","RasSetEntryDialParams","szEntryName","InT-LINK","szUserName","aaa","szPassword","111")

Please Guide Me..........Please

http://msdn.microsoft.com/en-us/library/windows/desktop/aa377821%28v=vs.85%29.aspx

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

Link to comment
Share on other sites

Hello.
 
I don't know, whether a typo or not, but you need to input the variables (e.g. $szEntryName) and not their names into the DllCall function.
 
The return variable of the RasSetEntryDialParams function is a dword variable, the "ERROR_SUCCESS" is one possible value of it. (when everything went ok, this is the return value)
 
The second parameter of the RasSetEntryDialParams function is a pointer to a RASDIALPARAMS structure, so you have to create it before calling the function.
 

I encourage you to browse the following Autoit Help topics:
(don't get me wrong, if I misjudged your Autoit and programming skills...)

 

That's what I can help you.

May the experts answer your post, and direct you to the good direction.
 
Best regards. CiV

I know that my code is ugly. But it works. Mostly.

Link to comment
Share on other sites

 

Hello.
 

I encourage you to browse the following Autoit Help topics:
(don't get me wrong, if I misjudged your Autoit and programming skills...)

 

That's what I can help you.

May the experts answer your post, and direct you to the good direction.
 
Best regards. CiV

 

No No you are not on misjudge you are on welljudge. i am not professional i am a student. And i am realy thanks for all of you.

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

Your call should end up looking something like this.

DllCall("Rasapi32.dll", "dword", "RasSetEntryDialParams", "wstr", $lpszPhonebook, "ptr", DllStructGetPtr($rasdialparams), "bool", $fRemovePassword)

$rasdialparams is a structure which can be built by studying it here.

Edited by JohnOne

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

$lpszPhonebook = @AppDataDir& "\Microsoft\Network\Connections\Pbk\rasphone.pbk"
$szEntryName="HM-LINK"
$szUserName="AAa"
$szPassword="wadf"
Local Const $tagSTRUCT1 = "struct;int dwSize;CHAR szEntryName[RAS_MaxEntryName + 1];CHAR szUserName[UNLEN + 1];CHAR szPassword[PWLEN + 1];CHAR; endstruct"
$rasdialparams = DllStructCreate($tagSTRUCT1)
DllCall("Rasapi32.dll", "dword", "RasSetEntryDialParams", "wstr", $lpszPhonebook, "ptr", DllStructGetPtr($rasdialparams),"CHAR",  $szEntryName, "CHAR", $szUserName, "CHAR", $szPassword)
If @error Then
    MsgBox(0,"","Error in DllCall "&@error)
    EndIf

i am trying like this But i could not success.......Please Help Me. If anyone Knows about 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."

Link to comment
Share on other sites

Well, I don't know about the windows dialing API, but your structure is badly defined for sure.

It should be something like this:

Local Const $tagSTRUCT1 = "struct;int dwSize;CHAR szEntryName["&$RAS_MaxEntryName + 1&"];CHAR szUserName["&$UNLEN + 1&"];CHAR szPassword["&$PWLEN + 1&"];CHAR; endstruct"

You should to find out by yourself, how to get $RAS_MaxEntryName (maybe the count of current items in hold);

$UNLEN may be StringLen($szUserName) or the maximum accepted name length, or something else;

so as $PWLEN.





			
		

I know that my code is ugly. But it works. Mostly.

Link to comment
Share on other sites

$fun=_SetUserNamePassword(@AppDataDir& "\Microsoft\Network\Connections\Pbk\rasphone.pbk","HM-LINK","Asd", "HGj")
If Not @error Then
    MsgBox(0,"OK","Done")
ElseIf @error Then
    MsgBox(0,"Error","Error is "&@error)
EndIf

Func _SetUserNamePassword($lpszPhonebook, $szEntryName, $szUserName, $szPassword, $fRemovePassword = False)
    Local Const $tagRASDialParams = "struct;dword dwSize;char szEntryName[256];char szPhoneNumber[256];char szCallbackNumber[256];char szUserName[256];char szPassword[256];char szDomain[256];dword dwSubEntry;ulong_ptr dwCallbackId;dword dwIfIndex;endstruct"
#cs
typedef struct _RASDIALPARAMS {
  DWORD     dwSize;
  TCHAR     szEntryName[RAS_MaxEntryName + 1];
  TCHAR     szPhoneNumber[RAS_MaxPhoneNumber + 1];
  TCHAR     szCallbackNumber[RAS_MaxCallbackNumber + 1];
  TCHAR     szUserName[UNLEN + 1];
  TCHAR     szPassword[PWLEN + 1];
  TCHAR     szDomain[DNLEN + 1];
  DWORD     dwSubEntry;
  ULONG_PTR dwCallbackId;
  DWORD     dwIfIndex;
} RASDIALPARAMS, *PRASDIALPARAMS;
#ce

    Local $tInfo = DllStructCreate($tagRASDialParams)
    DllStructSetData($tInfo, "Size", DllStructGetSize($tInfo))
    DllStructSetData($tInfo, "szEntryName", $szEntryName)
    DllStructSetData($tInfo, "szPhoneNumber", '')
    DllStructSetData($tInfo, "szCallbackNumber", '')
    DllStructSetData($tInfo, "szUserName", $szUserName)
    DllStructSetData($tInfo, "szPassword", $szPassword)
    DllStructSetData($tInfo, "szDomain", '')
    DllStructSetData($tInfo, "dwSubEntry", 1) ; ? 0-all
    DllStructSetData($tInfo, "dwCallbackId", 0) ; ?
    DllStructSetData($tInfo, "dwIfIndex", 0) ; ?

    Local $aResult = DllCall("Rasapi32.dll", "dword", "RasSetEntryDialParams", "wstr", $lpszPhonebook, "struct*", $tInfo, "bool",  $fRemovePassword)
EndFunc

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...