Jump to content

DllCall returns nothing for Interger functions


Recommended Posts

I'm using autoit to call functions from my custom DLL.

But when calling functions that return Integers, i always get zeros.

I can actually see (in debugger) that the DLL returns integer 1 (and it gets stored in autoit's memory)

but the script keeps displaying 0's or empty strings.

I tries the same with a system DLL and got the same result!

Here's an example script:

MSGBox(0,"", DllCall("kernel32.dll", "int", "GetCurrentProcess"))
MsgBox(0,"",@error)

The same thing if i use 'long' or 'dword' or 'hwnd' instead of 'int'

Looks like is the same problem as Formatting API return result creates problems, Fixed 3.2.3.7

version 3.2.4.9

Edited by Vano
Link to comment
Share on other sites

  • Developers

Please post questions like this in the Supportforum first to ensure its not a pilot error :whistle:

DllCall returns an Array thus indeed will show nothing when used in a MsgBox()

Also the Second MsgBox() shos the @error generated by the first MsgBox() NOT the DllCall !

If the function call fails then @error is set to 1. Otherwise an array is returned that contains the function return value and a copy of all the parameters (including parameters that the function may have modified).

$return[0] = function return value

$return[1] = param1

$return[2] = param2

...

$return[n] = paramn

Edited by JdeB

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

If the function call fails then @error is set to 1. Otherwise an array is returned that contains the function return value and a copy of all the parameters (including parameters that the function may have modified).

$return[0] = function return value

...

Dammit. I've read the article for many times but somehow missed this very paragraph :whistle:
Link to comment
Share on other sites

Dammit. I've read the article for many times but somehow missed this very paragraph :whistle:

$ret = DllCall("kernel32.dll", "int", "GetCurrentProcess")
Msgbox(0,"",$ret[0])

Returns -1

$ret = DllCall("kernel32.dll", "hwnd", "GetCurrentProcess")
Msgbox(0,"",$ret[0])

Returns a handle

Link to comment
Share on other sites

DllCall returns an Array thus indeed will show nothing when used in a MsgBox()

Also the Second MsgBox() shos the @error generated by the first MsgBox() NOT the DllCall !

That's quite strange, however. If a variable contains a non-empty value, it should also evaluate to something non-empty when converted to string.
Link to comment
Share on other sites

  • Developers

That's quite strange, however. If a variable contains a non-empty value, it should also evaluate to something non-empty when converted to string.

No it is not ... any array variable will return EMPTY when referred to without the [x] behind it ....

Moving this thread to Support ....

:whistle:

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

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