User Guide
Ruby Component
This is the name of the function you want to call. It must be exactly as it is written in the dll and is case sensitive.
inTypes
This defines the number of inputs to the function and their types. Each parameter is represented by a single character. You can use a Ruby
array with each element as a character ( e.g. ['I','n','c'] ) or you can use a string ( e.g. “inc” ).
The types you can use are as follows:
I or i - integer
L or l - long
P or p - pointer (including char* buffers)
S or s - string (const char* only)
V or v - void
For constant strings use 'S'. For string buffers that might be modified by the function call use 'P'.
outType
This defines the output type. This is a single character and can be any of those shown above including 'v' (upper or lowercase) to represent a
void return value.
As an example we're going to use the GetCursorPos function in user32.dll so our Win32API object would be created as follows:
getCursorPos = Win32API.new("user32", "GetCursorPos", ['P'], 'V')
Making the Call
Once you have your object you are ready to make your function call. To do this we use the Win32API method call and pass it a set of
parameters that match the ones we supplied when we created the object.
If your function call modifies the input data passed to it then you need to allocate the memory for that data before passing it to the function.
In the example we've chosen the GetCursorPos function takes an LPPOINT which is 8 bytes. So we need to create a string with 8 characters
to allocate this memory. We can then unpack this after the call has been made to extract the x and y coordinates we're after.
Here's how everything looks when it's put together:
We added a Tick25 so that we can watch the coordinates change as we move the mouse.
Here's another example:
160 of 212