In some documentation, Ruby’s Win32API has 'L' and 'N' to specify a “number”… and in some documentation, 'L' is “long”. Is 'N' deprecated, and isn’t 'L' the same as 'I' actually? A “number” is somewhat not so specific.
In
http://rubyforge.org/docman/view.php/85/3463/API.html#M000001
There is no specifying a boolean parameter as 'B' or 'I', only the return value…
In
http://www.ruby-doc.org/stdlib/libdoc/Win32API/rdoc/classes/Win32/Registry/Error.html#M001622
There is
Win32API.new('kernel32.dll', 'FormatMessageA', 'LPLLPLP', 'L')
instead of the more common ['L', 'P', 'L', ...] format
hWnd is 'L' and therefore 'I' will work too? (hWnd is handle to window)
Boolean parameter is 'B' and is the same as 'I'?
So basically, we can use most things as 'I'? Even the 'P' should be a 4-byte, so 'I' should work as well? Is there a more formal specification?
Update: now that I think more about 'P', it actually will use a Ruby’s String class object, and take the content buffer part and pass it into the C function. So using 'I' probably won’t trigger this behavior. (example: such as using GetWindowText())
I’m looking at the win32-api source code, and it looks like the only difference between ‘L’ and ‘I’ is that ‘L’ calls
rb_num2ulongand ‘I’ callsrb_num2intin<ruby.h>. So I guess the only difference is treatment as a signed value or not. ‘P’ also resultsrb_num2ulong, but it follows additional logic so I would probably stick to what the documentation suggests. I coudln’t find any mention of ‘N’ in the latest version of win32-api (1.4.5), so it’s probably deprecated. The Windows APIs do not returnboolean, but some returnBOOLwhich is (surprise! ) anint. In short, I don’t think you should use ‘I’ for everything. The win32-api documentation is pretty scant from what I’ve seen. At least the source code is available for browsing.