I need to access a few functions of the win32 library in ruby. I have found extremely sparse information on the Win32API class online, so I'm asking here.
I know that you can do something like this:
function = Win32API.new('user32','MessageBox',['L', 'P', 'P', 'L'],'I')
But I can't seem to be able to call this function with the current win32 bindings:
http://msdn.microsoft.com/en-us/library/bb762108%28VS.85%29.aspx
The problem is in its prototype:
UINT_PTR SHAppBarMessage(
DWORD dwMessage,
PAPPBARDATA pData
);
I will be able to use the win32 ruby bindings to grab the return type and the first parameter, however, the second one expects a structure. The definition of the structure is as follows:
typedef struct _AppBarData {
DWORD cbSize;
HWND hWnd;
UINT uCallbackMessage;
UINT uEdge;
RECT rc;
LPARAM lParam;
} APPBARDATA, *PAPPBARDATA;
I tried to define this api method using both:
api = Win32API.new('shell32','SHAppBarMessage',['L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L'],'I')
and
api = Win32API.new('shell32','SHAppBarMessage',['L', 'LLLLLLLL'],'I')
but the first one segfaults during the "call" method and the second fails to run due to the wrong amount of arguments specified in the "call" method invocation. Is there any way to expose this api function without resorting to creating an external module in C++?
Thanks.
See Question&Answers more detail:os