lovesoo Posted November 27, 2012 Share Posted November 27, 2012 (edited) Does anyone can supply me a example for "passing char** in DllCall"?I looked at the DllStructCreate and DllStructGetPtr, but it seems doesn't work correctly.Code like that:$FNStruct = DllStructCreate("char fns[128];") DllStructSetData($FNStruct, "fns", "test123456") DllCall($dll, "int:cdecl","TestXXX", "ptr", DllStructGetPtr($FNStruct)) Edited November 27, 2012 by lovesoo Link to comment Share on other sites More sharing options...
lovesoo Posted November 27, 2012 Author Share Posted November 27, 2012 Does anyone can supply me a example for "passing char** in DllCall"? Thx a lot! Link to comment Share on other sites More sharing options...
BugFix Posted November 27, 2012 Share Posted November 27, 2012 (edited) What says the parameter description? May be, you need a nul-termination for this string: DllStructSetData($FNStruct, "fns", "test123456" & Chr(0)) Edited November 27, 2012 by BugFix Best Regards BugFix Link to comment Share on other sites More sharing options...
lovesoo Posted November 27, 2012 Author Share Posted November 27, 2012 (edited) Code is: $FNStruct = DllStructCreate("char fns[128];") DllStructSetData($FNStruct, "fns", "TestDWF01.txt") DllCall($dll, "int:cdecl","TestXXX", "ptr", DllStructGetPtr($FNStruct)) Through the DLL I saw the value is 't' not "TestDWF01.txt" , the value i gave it. use the code below, got the same result DllStructSetData($FNStruct, "fns", "TestDWF01.txt" & Chr(0)) Edited November 27, 2012 by lovesoo Link to comment Share on other sites More sharing options...
lovesoo Posted November 28, 2012 Author Share Posted November 28, 2012 $s = DllStructCreate("ptr ppfname;ptr pfname;char fname[200]") ; struct ptr { char fname[200]) ; p1 = address of fname $p1 = dllStructGetptr($s, 3) ; p1 = address of fname dllStructSetData($s, 2, $p1) ; set "address of fname" to pfname ;p2 = address of p1 $p2 = DllStructGetPtr($s, 2) dllStructSetData($s, 1, $p1) ConsoleWrite("p1 = " & $p1 & @CRLF) ConsoleWrite("p2 = " & $p2 & @CRLF) I'll try this at first Link to comment Share on other sites More sharing options...
JohnOne Posted November 28, 2012 Share Posted November 28, 2012 I'd try $str = "TestDWF01.txt" DllCall($dll, "int:cdecl","TestXXX", "str*", $str) "str" can be passed in meaning LPCSTR which is char*, so adding "*" to "Str" = "str*" might create char** And maybe it wont. Worth a pop though. 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 More sharing options...
Shaggi Posted November 28, 2012 Share Posted November 28, 2012 $text = dllstructcreate("char[128]") ;create buffer dllstructsetdata($text,1,"Hi") $ptr = dllstructcreate("ptr") ;create a pointer to the buffer. works like char * text = "hi"; dllstructsetdata($ptr,1,dllstructgetptr($text)) dllcall(..., "ptr", dllstructgetptr($ptr)) ; pass a pointer to the pointer. works like char** ;dllcall(..., "struct*", $ptr) ; might work too beware though, char** parameters is not unusual syntax for passing an array of strings in c. this will work like an 1-sized array with first index set as "hi". it could also be the function intends to change the text $ptr points too - you dont do double inderection without a reason (usually). Ever wanted to call functions in another process? ProcessCall UDFConsole stuff: Console UDFC Preprocessor for AutoIt OMG 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