Quicky patch/fix for windows

i’ve been working with Mark Baker on the python wrapper for SDL.
things are going good, but an idea occurred. Currently, the only
system dependent thing we have is the need to #include<window.h>
for a windows compile.

the only thing we need from this is “GetModuleHandle()” for
the call to “SDL_RegisterApp()”. I modified SDL’s GetModuleHandle
to check for a 0 value in the hInst argument and just call
"GetModuleHandle(NULL)" for itself.

by doing this we can strip the python wrapper code of all system
dependent headers. ok, not the biggest or most important gain in
the world, but it makes things a little cleaner on our end.

anyways, it’s not really a big change, but i can see it could
have a somewhat nice effect for all coders out there working on
bindings to other languages.

i was also able to change all the internal calls to
SDL_RegisterApp to pass NULL for the handle, and that worked fine
also. these were at SDL_dibevents.c(309), SDL_dx5events.c(753),
and SDL_main.c(133)

anyways, it’s just a little change, and it doesn’t really
effect our wrapper much, like i mentioned, just keeps things a
bit cleaner.

i’ve been working with Mark Baker on the python wrapper for SDL.
things are going good, but an idea occurred. Currently, the only
system dependent thing we have is the need to #include<window.h>
for a windows compile.

the only thing we need from this is “GetModuleHandle()” for
the call to “SDL_RegisterApp()”. I modified SDL’s GetModuleHandle
to check for a 0 value in the hInst argument and just call
"GetModuleHandle(NULL)" for itself.

Great idea!
I’ve implemented this, and you can find it in tonight’s CVS snapshot.

Thanks!
-Sam Lantinga, Lead Programmer, Loki Entertainment Software

i’ve been working with Mark Baker on the python wrapper for SDL.
things are going good, but an idea occurred. Currently, the only
system dependent thing we have is the need to #include<window.h>
for a windows compile.

the only thing we need from this is “GetModuleHandle()” for
the call to “SDL_RegisterApp()”. I modified SDL’s GetModuleHandle
to check for a 0 value in the hInst argument and just call
"GetModuleHandle(NULL)" for itself.

Great idea!
I’ve implemented this, and you can find it in tonight’s CVS snapshot.

Hmm, unfortunately this doesn’t work (DirectInput creation fails) because
if you call GetModuleHandle(NULL) from within a DLL, you get the handle for
the DLL, not the application.

Does anybody know how to get the module handle for the application?

See ya,
-Sam Lantinga, Lead Programmer, Loki Entertainment Software

Sam Lantinga wrote:

Hmm, unfortunately this doesn’t work (DirectInput creation fails) because
if you call GetModuleHandle(NULL) from within a DLL, you get the handle for
the DLL, not the application.

Does anybody know how to get the module handle for the application?

See ya,
-Sam Lantinga, Lead Programmer, Loki Entertainment Software

It’s a bit of a hack, but you might be able to use GetWindowInstance.
(which is a wrapper for GetWindowLong with a specific offset)

Sam Lantinga wrote:

Hmm, unfortunately this doesn’t work (DirectInput creation fails) because
if you call GetModuleHandle(NULL) from within a DLL, you get the handle for
the DLL, not the application.

Does anybody know how to get the module handle for the application?

See ya,
-Sam Lantinga, Lead Programmer, Loki Entertainment Software

It’s a bit of a hack, but you might be able to use GetWindowInstance.
(which is a wrapper for GetWindowLong with a specific offset)

The function is being called before the main window is created.

See ya!
-Sam Lantinga, Lead Programmer, Loki Entertainment Software

Sam Lantinga wrote:

Hmm, unfortunately this doesn’t work (DirectInput creation fails) because
if you call GetModuleHandle(NULL) from within a DLL, you get the handle for
the DLL, not the application.

well, if windows is gonna fuss, i suppose we should try to keep
windows happy? it’s no big problem if it won’t work, but i admit
i was excited when it was looking positive