title: Ruby win32 api interface
body: <p>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.</p>
  
  <p>I know that you can do something like this:</p>
  
  <pre><code>function = Win32API.new('user32','MessageBox',['L', 'P', 'P', 'L'],'I')
  </code></pre>
  
  <p>But I can't seem to be able to call this function with the current win32 bindings:</p>
  
  <p><a href="http://msdn.microsoft.com/en-us/library/bb762108%28VS.85%29.aspx" rel="noreferrer">http://msdn.microsoft.com/en-us/library/bb762108%28VS.85%29.aspx</a></p>
  
  <p>The problem is in its prototype:</p>
  
  <pre><code>UINT_PTR SHAppBarMessage(      
      DWORD dwMessage,
      PAPPBARDATA pData
  );
  </code></pre>
  
  <p>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:</p>
  
  <pre><code>typedef struct _AppBarData {
      DWORD cbSize;
      HWND hWnd;
      UINT uCallbackMessage;
      UINT uEdge;
      RECT rc;
      LPARAM lParam;
  } APPBARDATA, *PAPPBARDATA;
  </code></pre>
  
  <p>I tried to define this api method using both:</p>
  
  <pre><code>api = Win32API.new('shell32','SHAppBarMessage',['L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L'],'I') 
  </code></pre>
  
  <p>and</p>
  
  <pre><code>api = Win32API.new('shell32','SHAppBarMessage',['L', 'LLLLLLLL'],'I')
  </code></pre>
  
  <p>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++?</p>
  
  <p>Thanks.</p>