trying to extend ruby with win32 programming
I have some C++ Win32 code that I want to call from Ruby. But the code needs to be set up like this
int WinMain(HINSTANCE hInsta开发者_如何学Pythonnce, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
otherwise things don't work right when I try creating windows and stuff. I don't know how to do that with a Ruby extension.
What can I do? Is there some routine I can call from main()
to set up the process so my win32 api calls work right?
Edit: (mostly) solved. see my answer.
ShowWindow() takes an nShowCmd parameter, where 0 means SW_HIDE, ie to hide the window:
http://msdn.microsoft.com/en-us/library/ms633548(VS.85).aspx
I changed the nShowCmd
parameter to 10
in the various window-related functions.
Now stuff works just fine... I had just given up when fiddling with hInstance wasn't enough to get it to work.
I can't find much info on nShowCmd
though. Why do windows not work when it's 0
?
精彩评论