I’ve been working with the “SDL_RegisterApp” business recently.
I’m trying to figure out if it is really needed. in my case it
would appear not (with an NT4 and Win98 system), but I’m sure
there’s plenty of cases where it’s needed. if we look in
wincommon/SDL_sysevents.c, line 426, we see this code…
/* This function needs to be passed the correct process handle
by the application. The following call just returns a handle
to the SDL DLL, which is useless for our purposes and causes
DirectInput to fail to initialize.
*/
if ( ! hInst ) {
hInst = GetModuleHandle(NULL);
}
this code allows the user to pass NULL for the module’s handle,
but it comes with a stern warning that it won’t work.
that’s where i’m a little puzzled. for me it is working great.
calling SDL_RegisterApp myself, passing NULL for hInst has
taken care of all my input problems on both my win98 and nt4
systems.
maybe i’m just gettin real lucky and it “shouldn’t” be working,
but it seems pretty stable for now
the question then is, does the current SDL need the ModuleHandle
from the hosting application, or can it just get the handle for
itself? if it doesn’t need info from the hosting application, it
seems we could call SDL_RegisterApp from SDL internally and not
bother the hosting application with it at all?
with this we could remove the heavy reliance on requiring SDLmain
to handle the dirty initializing work for us?
of course, this all seems to fly in the face of the warning
comment here, so i’m suspect this could still be a very bad idea.
perhaps the author of this comment can shed some light on the
situation? it would be a pretty scary change to remove the need
for this call. but if it is possible, it seems like it would be
worth pursuing.