Re: [GD-Windows] Finding HWND of the current thread
Brought to you by:
vexxed72
From: Jan W. <ur...@st...> - 2004-07-30 18:27:51
|
On Thu, 29 Jul 2004 01:04:04 -0700, Jon Watte <hp...@mi...> wrote: > 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. That would be the more correct way of going about things :) However, I don't think these assumptions can ever be broken (famous last words). The app load address must stay the same, since PE relocation info is no longer generated (because 0x400000 is guaranteed). GetModuleHandle has to return a pointer, since crt0 currently uses it as such (checking if the app is managed). Now if they're willing to break every single (not recompileable) program in existence with future versions, all bets are off. Best Regards Jan |