Jump to content

How can i create Dllstructure??


Go to solution Solved by Starstar,

Recommended Posts

How to use "DllStructCreate"? Any hint will be appreciated and thanks in advance........

Edit::

i had also see autoit help file many times and other related topic but i couldn't learn it properly.

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

Why do you think you need to use this function? What are you going to be doing with it once you learn how to use it?

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

Thanks BrewManNH there are many function that can i call using Dllcall(like Connecting a vpn without using operating system function)but every time dllstructure  becomes me crazy..................

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

typedef struct {
  DWORD dwSize;
  DWORD dwMask;
  TCHAR szUserName[UNLEN + 1];
  TCHAR szPassword[PWLEN + 1];
  TCHAR szDomain[DNLEN + 1];
} RASCREDENTIALS, *LPRASCREDENTIALS;

How can i create this structure in autoit? what can i put at the place of dwSize and dwMask?
and what does mean of [uNLEN+1]&[PWAN+1]?
Microsoft structure Link...  and dll function link in witch this structure used  

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

Thanks a lot of you all.................Please take a glance at my first structure and told me where am i wrong.................... thanks in advance..

Local Const $tagSTRUCT1 = "struct;DWORD var1[100];DWORD var2[100];WCHAR var3[128]; WCHAR var4[128]; WCHAR var5[100]; endstruct"
$rasdialstruct =DllStructCreate($tagSTRUCT1)
DllStructSetData($rasdialstruct,"var1","500")
DllStructSetData($rasdialstruct,"var2","10")
DllStructSetData($rasdialstruct,"var3","as5555")
$fnd=DllStructSetData($rasdialstruct,"var4","Df4456")
DllStructSetData($rasdialstruct,"var5","0")
$Size=DllStructGetSize($rasdialstruct)
MsgBox(0,"",$Size&" Fnd is = "&$fnd)

Happy land ....

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

@Starstar You can specificate your structure by name index(no using just var string) could be better. somthing like this:

Local $iUserlen=Stringlen("username")
Local $iUserPass=StringLen("userpass")
Local $iDomLen=StringLen("Domain")
$sTagRASCREDENTIALS = "dword dwSize;dword dwMask;wchar szUserName[" & $iUserlen+1 & "];wchar szPassword["& $iUserPass+1 & "];wchar szDomain[" & $iDomLen+1 &"]"

saludos

Edited by Danyfirex
Link to comment
Share on other sites

This is very usefully for me :)

[color=rgb(51,51,51);] [url=[/color]http://www.reductan.com[color=rgb(51,51,51);]][/color]fast weight loss pills[color=rgb(51,51,51);][/url],[/color] [color=rgb(51,51,51);][url=[/color]http://www.reductan.com[color=rgb(51,51,51);]][/color]how to lose weight[color=rgb(51,51,51);][/url][/color][color=rgb(51,51,51);], [/color][color=rgb(51,51,51);][url=[/color]http://www.reductan.com[color=rgb(51,51,51);]][/color]slimming pills[color=rgb(51,51,51);][/url][/color]

Link to comment
Share on other sites

@Starstar You can specificate your structure by name index(no using just var string) could be better. somthing like this:

Local $iUserlen=Stringlen("username")
Local $iUserPass=StringLen("userpass")
Local $iDomLen=StringLen("Domain")
$sTagRASCREDENTIALS = "dword dwSize;dword dwMask;wchar szUserName[" & $iUserlen+1 & "];wchar szPassword["& $iUserPass+1 & "];wchar szDomain[" & $iDomLen+1 &"]"

saludos

very very useful............

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

Onother thing.

When You set data to the structure:

Local $iUserlen=Stringlen("username")
Local $iUserPass=StringLen("userpass")
Local $iDomLen=StringLen("Domain")
$sTagRASCREDENTIALS = "dword dwSize;dword dwMask;wchar szUserName[" & $iUserlen+1 & "];wchar szPassword["& $iUserPass+1 & "];wchar szDomain[" & $iDomLen+1 &"]"

Local $tTRASCREDENTIALS=DllStructCreate($sTagRASCREDENTIALS)



DllStructSetData($tTRASCREDENTIALS,"dwSize",DllStructGetSize($tTRASCREDENTIALS))
;or
$tTRASCREDENTIALS.dwSize=DllStructGetSize($tTRASCREDENTIALS)

;No need pass the number so "10", just 10
DllStructSetData($tTRASCREDENTIALS,"dwMask",10)
;or
$tTRASCREDENTIALS.dwMask=10
Edited by Danyfirex
Link to comment
Share on other sites

Link to comment
Share on other sites

#define UNLEN       256                 // Maximum user name length
#define PWLEN       256                 // Maximum password length

You can not just change the size of a structure! The size has to be constant. Use the values 256 as defined in Lmcons.h !

 

Edit:

#define CNLEN       15                  // Computer name length
#define DNLEN       CNLEN               // Maximum domain name length
Edited by funkey

Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs, and the Universe
trying to produce bigger and better idiots.
So far, the Universe is winning.

Link to comment
Share on other sites

@funkey I did'nt search that constants. Thank you

Fixed code:

Local Const $UNLEN=256                  ;// Maximum user name length
Local Const $PWLEN = 256                ;// Maximum password length
Local Const $CNLEN =15                  ;// Computer name length
Local Const $DNLEN =$CNLEN              ;// Maximum domain name length

$sTagRASCREDENTIALS = "dword dwSize;dword dwMask;wchar szUserName[" & $UNLEN+1 & "];wchar szPassword["& $PWLEN+1 & "];wchar szDomain[" & $DNLEN+1 &"]"

Local $tTRASCREDENTIALS=DllStructCreate($sTagRASCREDENTIALS)



DllStructSetData($tTRASCREDENTIALS,"dwSize",DllStructGetSize($tTRASCREDENTIALS))
;or
$tTRASCREDENTIALS.dwSize=DllStructGetSize($tTRASCREDENTIALS)

;No need pass the number so "10", just 10
DllStructSetData($tTRASCREDENTIALS,"dwMask",10)
;or
$tTRASCREDENTIALS.dwMask=10

Saludos

Edited by Danyfirex
Link to comment
Share on other sites

@funkey I did'nt search that constants. Thank you

Fixed code:

Local Const $UNLEN=256                  ;// Maximum user name length
Local Const $PWLEN = 256                ;// Maximum password length
Local Const $CNLEN =15                  ;// Computer name length
Local Const $DNLEN =$CNLEN              ;// Maximum domain name length

$sTagRASCREDENTIALS = "dword dwSize;dword dwMask;wchar szUserName[" & $UNLEN+1 & "];wchar szPassword["& $PWLEN+1 & "];wchar szDomain[" & $DNLEN+1 &"]"

Local $tTRASCREDENTIALS=DllStructCreate($sTagRASCREDENTIALS)



DllStructSetData($tTRASCREDENTIALS,"dwSize",DllStructGetSize($tTRASCREDENTIALS))
;or
$tTRASCREDENTIALS.dwSize=DllStructGetSize($tTRASCREDENTIALS)

;No need pass the number so "10", just 10
DllStructSetData($tTRASCREDENTIALS,"dwMask",10)
;or
$tTRASCREDENTIALS.dwMask=10

Saludos

Good.........

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

i am trying to calling a dll function but error 5(bad parameter) comes.

Local Const $UNLEN=256
Local Const $PWLEN = 256
Local Const $CNLEN =15
Local Const $DNLEN =$CNLEN

$sTagRASCREDENTIALS = "dword dwSize;dword dwMask;wchar szUserName[" & $UNLEN+1 & "];wchar szPassword["& $PWLEN+1 & "];wchar szDomain[" & $DNLEN+1 &"]"
Local $tTRASCREDENTIALS=DllStructCreate($sTagRASCREDENTIALS)
DllStructSetData($tTRASCREDENTIALS,"dwSize",DllStructGetSize($tTRASCREDENTIALS))
DllStructSetData($tTRASCREDENTIALS,"dwMask",10)
DllStructSetData($tTRASCREDENTIALS,"szUserName","gh1010")
DllStructSetData($tTRASCREDENTIALS,"szPassword","aghh0")
DllStructSetData($tTRASCREDENTIALS,"szDomain","")
$phnbook ="C:\Users\Adnan\AppData\Roaming\Microsoft\Network\Connections\Pbk\rasphone.pbk"
$entry ="hm"
$msg = DllCall("Rasapi32.dll","DWORD","RasSetCredentialsW","wstr",$phnbook,"wstr",$entry,"ptr",DllStructGetPtr($tTRASCREDENTIALS),"BOOl","fClearCredentials")
MsgBox(0,"",$msg[0])

Now What can i do? thanks in advance...........

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

fClearCredentials should be 'TRUE' or 'FALSE' but no string 'fClearCredentials'.
 

Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs, and the Universe
trying to produce bigger and better idiots.
So far, the Universe is winning.

Link to comment
Share on other sites

fClearCredentials should be 'TRUE' or 'FALSE' but no string 'fClearCredentials'.

 

i have also tried like this but result is same..........i always get error 5.

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

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