Jump to content

DllCall string buffer size?


Recommended Posts

  • Administrators

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

Link to comment
Share on other sites

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.
Link to comment
Share on other sites

  • 2 years later...

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,

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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 by piccaso
CoProc Multi Process Helper libraryTrashBin.nfshost.com store your AutoIt related files here!AutoIt User Map
Link to comment
Share on other sites

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!

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