I know the following:
'L'
- Long
'P'
- Pointer
'I'
- Integer
'V'
- Void
My problem is that I can't pass a null pointer when I perform an API call. E.g.: ['L', 'P', 'L'] -> api.call(0, nil, 0) :: ArgumentError: Null pointer given
. My question is: Are there more parameter types that I don't know about and what should I do to pass a null pointer as a method parameter?
Background
I have been searching the internet for native Ruby programming examples of WinForms-based applications. I have considered the .NET addition to Ruby known as IronRuby for simplicity in coding (trying to avoid wxRuby, and also a .NET fan), but I first want to be able to code explicitly in pure Ruby first.
Now, I have successfully been able to implement most addresses I've tested in the user32.dll object such as:
api = Win32API.new('user32', 'MessageBox', ['L', 'P', 'P', 'L'], 'I')
# or
api = Win32API.new('user32', 'MessageBeep', ['L'], 'I')
..but I cannot perform a CreateWindow
Or CreateWindowEx
without null parameters.
If it would be of any help, I have found how to do this in Python here (under WinAPI).
Using Win32API: msdn.microsoft.com/en-us/library/ff381397(v=VS.85).aspx
[EDIT]
Well, I think I may have just solved my own problem with this link
(warning: may contain inappropriate content): [link]
I more used that forum as reference and did a bit of fiddling around my self:
createwindow = Win32API.new("user32","CreateWindowEx",'lpplllllllll','l')
showwindow = Win32API.new('user32','ShowWindow',%w(l l),'l')
hWND = createwindow.call((0x00000100|0x00000200),"static", "Window Title",((0x4000000|0x80000000|0)|0x02000000),0,0,600,400,0,0,0,0)
showwindow(hWND, 1)
The only thing that happens after the 'window' is displayed is crash... and that may have been because of some incorrect handling, but, I am happy that I got it to work(for a little bit)! Just need to figure out the rest...
See Question&Answers more detail:
os