Sign in to follow this  
Followers 0
cppman

DLLCall with Structures

4 posts in this topic

Hi everyone. I have been curious for a while now, how would it be possible for me to call a dll function that does not take a pointer to a structure? For example, I am trying to call the WindowFromPoint function. However it's prototype is like this.

HWND WindowFromPoint(POINT Point);

As you can see it isn't LPPOINT so setting the type to "ptr" is out of the question..

So far I can make this out to be:

$hWnd = DLLCall("user32.dll", "hWnd", "WindowFromPoint", "what goes here?", "the structure goes here")

Any ideas?

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Well, if it's not a ptr, then try to pass the point coordinates directly:

$hWnd = DLLCall("user32.dll", "hwnd", "WindowFromPoint", "long", $x, "long", $y)

Edited by Siao

"be smart, drink your wine"

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

O RLY?

$x = 10
$y = 10
Run("notepad.exe", "", @SW_MAXIMIZE)
WinWaitActive("Untitled - Notepad")
$hwnd1 = WinGetHandle("Untitled - Notepad")
$ret = DLLCall("user32.dll", "hwnd", "WindowFromPoint", "long", $x, "long", $y)
$hwnd2 = $ret[0]
MsgBox(0, '', $hwnd1 & @CRLF & $hwnd2)
WinClose("Untitled - Notepad")
Edited by Siao

"be smart, drink your wine"

Share this post


Link to post
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
Sign in to follow this  
Followers 0