diff --git a/en/_posts/2011-11-24-DllCalls.markdown b/en/_posts/2011-11-24-DllCalls.markdown index 40e7c43..161daac 100644 --- a/en/_posts/2011-11-24-DllCalls.markdown +++ b/en/_posts/2011-11-24-DllCalls.markdown @@ -1,5 +1,5 @@ --- -title: Working with Windows API +title: Working with external functionality layout: post permalink: /en/DllCalls.html --- @@ -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 %} \ No newline at end of file