DTNGUYEN Posted May 18, 2010 Posted May 18, 2010 I have a structure in C++ like this. Please help me to create a structure for this. struct structAutomobile ( int flags;/ / -1: all elements of the structure are used / 0xE0 (0b11100000), then only the elements corresponding to the bits of value 1 will be used: nVerbose, strVerboseFile and nStandalone. int nVerbose;/ / 0: verbose off, 1: verbose is char * strVerboseFile;/ / Output file (path included) traces (verbose) int nStandalone;/ / 0: throw srvcomm, 1: do not throw srvcomm bool bActiveTrace;/ / False: trace inactive true: active track bool bNoAction;/ / False: The DLL functions are running, true: the DLL functions and does not run API should return Fonction_OK char * strUserProjectPath;/ / Directory Project padding1 tank; padding2 tank; ) I try this but autoit return ">Exit code: -1073741819" $str = "int flags; int nVerbose; char strVerboseFile[256]; int nStandalone; byte bActiveTrace; byte bNoAction; char strUserProjectPath[256]"; $a = DllStructCreate($str) DllStructSetData($a, 1, -1) DllStructSetData($a, 2, 0) DllStructSetData($a, 3, "c:\Documents and Settings\dungnt\My Documents\DiamuxV5Data") DllStructSetData($a, 4, 1) DllStructSetData($a, 5, 0) DllStructSetData($a, 6, 1) DllStructSetData($a, 7, "c:\Documents and Settings\dungnt\My Documents\DiamuxV5Data") ConsoleWrite("flags: " & DllStructGetData($a,"flags") & @crlf) ConsoleWrite("nVerbose: " & DllStructGetData($a,"nVerbose") & @crlf) ConsoleWrite("strVerboseFile: " & DllStructGetData($a,"strVerboseFile") & @crlf) ConsoleWrite("nStandalone: " & DllStructGetData($a,"nStandalone") & @crlf) ConsoleWrite("bActiveTrace: " & DllStructGetData($a,"bActiveTrace") & @crlf) ConsoleWrite("bNoAction: " & DllStructGetData($a,"bNoAction") & @crlf) ConsoleWrite("strUserProjectPath: " & DllStructGetData($a,"strUserProjectPath") & @crlf) $rp = DllStructGetPtr($a) ConsoleWrite($rp & @crlf) $rc = DllCall($libDiamuxDll, "str", "ConfigureDiamux", "ptr", $rp) ConsoleWrite($rc & @crlf) Thank you very much !
trancexx Posted May 18, 2010 Posted May 18, 2010 Try something like this:; Input data $sVerboseFile = "c:\Documents and Settings\dungnt\My Documents\DiamuxV5Data" $sUserProjectPath = "c:\Documents and Settings\dungnt\My Documents\DiamuxV5Data" ; Structure definition $tAutomobile = DllStructCreate("int Flags;" & _ "int Verbose;" & _ "ptr VerboseFile;" & _ "int Standalone;" & _ "bool ActiveTrace;" & _ "bool NoAction;" & _ "ptr UserProjectPath") ; Fill the structure DllStructSetData($tAutomobile, "Flags", -1) DllStructSetData($tAutomobile, "Verbose", 0) $tVerboseFile = DllStructCreate("char[256]") ; or maybe in size of the data (+1) DllStructSetData($tAutomobile, "VerboseFile", DllStructGetPtr($tVerboseFile)) DllStructSetData($tAutomobile, "Standalone", 1) DllStructSetData($tAutomobile, "ActiveTrace", 0) DllStructSetData($tAutomobile, "NoAction", 1) $tUserProjectPath = DllStructCreate("char[256]") ; same comment as above DllStructSetData($tAutomobile, "UserProjectPath", DllStructGetPtr($tUserProjectPath)) ; Set those two DllStructSetData($tVerboseFile, 1, $sVerboseFile) DllStructSetData($tUserProjectPath, 1, $sUserProjectPath) ; Call...Btw, there is difference between bool and boolean. ♡♡♡ . eMyvnE
DTNGUYEN Posted May 18, 2010 Author Posted May 18, 2010 Try something like this: ; Input data $sVerboseFile = "c:\Documents and Settings\dungnt\My Documents\DiamuxV5Data" $sUserProjectPath = "c:\Documents and Settings\dungnt\My Documents\DiamuxV5Data" ; Structure definition $tAutomobile = DllStructCreate("int Flags;" & _ "int Verbose;" & _ "ptr VerboseFile;" & _ "int Standalone;" & _ "bool ActiveTrace;" & _ "bool NoAction;" & _ "ptr UserProjectPath") ; Fill the structure DllStructSetData($tAutomobile, "Flags", -1) DllStructSetData($tAutomobile, "Verbose", 0) $tVerboseFile = DllStructCreate("char[256]") ; or maybe in size of the data (+1) DllStructSetData($tAutomobile, "VerboseFile", DllStructGetPtr($tVerboseFile)) DllStructSetData($tAutomobile, "Standalone", 1) DllStructSetData($tAutomobile, "ActiveTrace", 0) DllStructSetData($tAutomobile, "NoAction", 1) $tUserProjectPath = DllStructCreate("char[256]") ; same comment as above DllStructSetData($tAutomobile, "UserProjectPath", DllStructGetPtr($tUserProjectPath)) ; Set those two DllStructSetData($tVerboseFile, 1, $sVerboseFile) DllStructSetData($tUserProjectPath, 1, $sUserProjectPath) ; Call... Btw, there is difference between bool and boolean. Thanks for help. I try your code add using the code below ConsoleWrite("flags: " & DllStructGetData($tAutomobile,"flags") & @crlf) ConsoleWrite("nVerbose: " & DllStructGetData($tAutomobile,"nVerbose") & @crlf) ConsoleWrite("strVerboseFile: " & DllStructGetData($tAutomobile,"strVerboseFile") & @crlf) ConsoleWrite("nStandalone: " & DllStructGetData($tAutomobile,"nStandalone") & @crlf) ConsoleWrite("bActiveTrace: " & DllStructGetData($tAutomobile,"bActiveTrace") & @crlf) ConsoleWrite("bNoAction: " & DllStructGetData($tAutomobile,"bNoAction") & @crlf) ConsoleWrite("strUserProjectPath: " & DllStructGetData($tAutomobile,"strUserProjectPath") & @crlf) ConsoleWrite("padding: " & DllStructGetData($tAutomobile,"padding") & @crlf) $rp = DllStructGetPtr($tAutomobile) ConsoleWrite($rp & @crlf) It returns flags: 0 nVerbose: 0 strVerboseFile: 0 nStandalone: 0 bActiveTrace: 0 bNoAction: 0 strUserProjectPath: 0 padding: 0 0
trancexx Posted May 18, 2010 Posted May 18, 2010 (edited) Of course it does. Elements of the structure were renamed. You missed that? It's not "nVerbose" but "Verbose", etc... edit: plus that, your AutoIt is outdated. New releases are made for good reasons. Edited May 18, 2010 by trancexx ♡♡♡ . eMyvnE
DTNGUYEN Posted May 20, 2010 Author Posted May 20, 2010 Of course it does. Elements of the structure were renamed. You missed that?It's not "nVerbose" but "Verbose", etc...edit: plus that, your AutoIt is outdated. New releases are made for good reasons.Thank you very much for your help.
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