RE: [GD-Windows] Finding HWND of the current thread
Brought to you by:
vexxed72
From: Jon W. <hp...@mi...> - 2004-07-29 08:05:24
|
May I suggest that you're not guaranteed that GetModuleHandle() returns a pointer to your executable header, and you're not guaranteed that your executable loads at 0x400000 ? They might have a hard time changing this behavior for existing apps, especially because of hacky code like the posted code, but you never know about future versions. If you want the header, use GetModuleFileName() on the main module, and read the header yourself. Then check whether the header is actually a "PE" header, and just assume you're not console if it isn't. At least, that won't CRASH when you port your code, or some new version of Windows comes out. Cheers, / h+ -----Original Message----- From: gam...@li... [mailto:gam...@li...]On Behalf Of Jan Wassenberg Sent: Wednesday, July 28, 2004 1:45 AM To: gam...@li... Subject: Re: [GD-Windows] Finding HWND of the current thread On Thu, 15 Jul 2004 14:19:49 -0400, Brian Hook <ho...@bo...> wrote: >> GetConsoleWindow > As a library, I won't know if it's a console window or not. You can check the Subsystem field of the PE "optional" header (always present): if it's equal IMAGE_SUBSYSTEM_WINDOWS_CUI (3), you've got a console app. void* base = (void*)0x400000 (or GetModuleHandle(0)) IMAGE_NT_HEADERS* h = ImageNtHeader(base) h->OptionalHeader.Subsystem == 3? Disclaimer: off the top of my head and ugly to boot ;) ------------------------------------------------------- This SF.Net email is sponsored by BEA Weblogic Workshop FREE Java Enterprise J2EE developer tools! Get your free copy of BEA WebLogic Workshop 8.1 today. http://ads.osdn.com/?ad_id=4721&alloc_id=10040&op=click _______________________________________________ Gamedevlists-windows mailing list Gam...@li... https://lists.sourceforge.net/lists/listinfo/gamedevlists-windows Archives: http://sourceforge.net/mailarchive/forum.php?forum_id=555 |