Skip to content

Commit

Permalink
Add section about exported data to the DllCall page.
Browse files Browse the repository at this point in the history
  • Loading branch information
Uberi committed Feb 10, 2012
1 parent 1e01111 commit e005907
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion en/_posts/2011-11-24-DllCalls.markdown
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: Working with Windows API
title: Working with external functionality
layout: post
permalink: /en/DllCalls.html
---
Expand Down Expand Up @@ -105,3 +105,21 @@ IDCANCEL := 2 ; define the constant as pointed out on msdn
if (result == IDCANCEL)
MsgBox You canceled.
{% endhighlight %}

### Exported data
Rarely, DLLs may export variables in addition to functions; for example, the Raydium Game Engine DLL. Although it is not possible to retrieve or store values to this variable directly using DllCall(), it is possible to use the [GetProcAddress()](http://msdn.microsoft.com/en-us/library/windows/desktop/ms683212.aspx) WinAPI function to do so:
{% highlight ahk linenos %}; any AutoHotkey version

;load the library that contains the exported variable
hModule := DllCall("LoadLibrary","Str","Raydium.dll")

;obtain the address of the variable "raydium_joy_x"
pJoystickX := DllCall("GetProcAddress","UPtr",hModule,"AStr","raydium_joy_x")

;retrieve a float value from the address
JoyStickX := NumGet(pJoystickX + 0,0,"Float")
MsgBox, The joystick position in the x-axis is currently %JoystickX%.

;store a float value in the memory location pointed to by the address
NumPut(0.8,pJoystickX + 0,0,"Float") ;store 0.8 as the value
{% endhighlight %}

0 comments on commit e005907

Please sign in to comment.