SumTingWong Posted February 4, 2005 Posted February 4, 2005 Can anyone tell me what the buffer size is for string params passed by DllCall? I am trying to return some values via a string but I keep getting access violation errors when exceeding a certain size. Thanks.
Lazycat Posted February 4, 2005 Posted February 4, 2005 For now it's limited by 65536 bytes. Koda homepage ([s]Outdated Koda homepage[/s]) (Bug Tracker)My Autoit script page ([s]Outdated mirror[/s])
SumTingWong Posted February 4, 2005 Author Posted February 4, 2005 For now it's limited by 65536 bytes.<{POST_SNAPBACK}>DOH!
Administrators Jon Posted February 4, 2005 Administrators Posted February 4, 2005 I was thinking for a "str:size" possibility but for now the only workaround is to make the variable you use big enough to hold the data. Then instead of using a 64KB limit autoit allows you to return something bigger. $mybigstring = "jkj" ; Do something to $mybigstring to make it large enough to hold your return string ... ... ... then: DllCall(..... "str", $mybigstring, ....) Deployment Blog: https://www.autoitconsulting.com/site/blog/ SCCM SDK Programming: https://www.autoitconsulting.com/site/sccm-sdk/
SumTingWong Posted February 4, 2005 Author Posted February 4, 2005 I was thinking for a "str:size" possibility but for now the only workaround is to make the variable you use big enough to hold the data. Then instead of using a 64KB limit autoit allows you to return something bigger.$mybigstring = "jkj"; Do something to $mybigstring to make it large enough to hold your return string.........then:DllCall(..... "str", $mybigstring, ....)<{POST_SNAPBACK}>Thanks, that's useful to know.
erebus Posted December 9, 2007 Posted December 9, 2007 Ok, I have found this very old topic because I have a similar problem here. I have to use a DllCall which returns its data in "str". Although I have no errors, when the data are less than 65536 characters, they are delivered in whole. When they exceed this limit, they are delivered only up to this limit (the rest are gone). Can somebody help me with this? I want to believe that there must be a trick... Thank you,
piccaso Posted December 9, 2007 Posted December 9, 2007 No trick, Just Create a buffer large enough to hold your data with DllStructCreate and pass a pointer CoProc Multi Process Helper libraryTrashBin.nfshost.com store your AutoIt related files here!AutoIt User Map
Valik Posted December 9, 2007 Posted December 9, 2007 64KB is the size of the internal buffer when you use the "str" type. As piccaso said, if you're working with data larger than that, use DllStructCreate() to allocate a buffer size of your own choosing.
erebus Posted December 9, 2007 Posted December 9, 2007 Thank you very much for your answers. However I am not that experienced with DLLs, so some guidance would be appreciated. Here is my code so far: $dll = DllOpen("7-zip32.dll") $check = DllCall($dll, "int", "SevenZip", "hwnd", 0, "str", "l " & Chr(34) & "just-an-archive.7z" & Chr(34), "str", "", "int", 65535) DllClose($dll) MsgBox(0, "", $check[3]) So, as you can see, the limitation applies to the third parameter. How would I use DllStructCreate with this? I haven't done it before...
piccaso Posted December 9, 2007 Posted December 9, 2007 (edited) I assumed that the last parameter is the buffer size... $vBuff = DllStructCreate("char[1048576]") ; Size in bytes $dll = DllOpen("7-zip32.dll") $check = DllCall($dll, "int", "SevenZip", "hwnd", 0, _ "str", "l " & Chr(34) & "just-an-archive.7z" & Chr(34), _ "ptr", DllStructGetPtr($vBuff), _ ; Pass a pointer instead of 'str' "int", DllStructGetSize($vBuff)) ; the size of the buffer? DllClose($dll) MsgBox(0, "", DllStructGetData($vBuff,1)) Edited December 9, 2007 by piccaso CoProc Multi Process Helper libraryTrashBin.nfshost.com store your AutoIt related files here!AutoIt User Map
erebus Posted December 9, 2007 Posted December 9, 2007 picasso, you are _always_ a lifesaver. This is not the first time that I bow to your superior knowledge. Thank you mate, it works just fine! I still can't understand very well the use of pointers and structs and I strongly believe that AU3's documentation lacks much information regarding the use of DLLs in general. I am not an experienced programmer in general, but I consider myself experienced with AutoIT. I believe that in the documentation/forum should exist some tutorials and more detailed examples, so the use of DLLs will not be limited to people with experience from other programming languages. I know that Google is always our friend, however no matter how much information I find there, I cannot always connect the dots when trying to migrate the information to AutoIT code... Please consider it. Thank you once again, I really appreciate it!
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