On Wednesday, 29 April 2020 at 11:55:54 UTC, Sam E. wrote:
On Wednesday, 29 April 2020 at 10:46:30 UTC, Mike Parker wrote:
On Wednesday, 29 April 2020 at 10:44:48 UTC, Mike Parker wrote:
Yeah, it says "WinMain is needed", which has never been true.
THere's no need for the def file either.
What's the way to get the hInstance without the use of WinMain?
From Microsoft documentation:
hInstance is the handle to the application instance. Get this
value from the hInstance parameter of wWinMain.
https://docs.microsoft.com/en-us/windows/win32/learnwin32/creating-a-window
I cannot find a D example using Win32 and the normal main
function, and while it is working for simple message boxes, as
soon as I want to do something slightly more complex (using a
window), an hInstance has to be provided (as far as I
understand, I'm not that knowledgeable with Win32).
auto hInstance = GetModuleHandleA(null);
It's documented to return HMODULE, but HINSTANCE is the same
thing (all the HANDLE types are void*). Passing null causes it to
return the handle associated with the process, so for the
executable "module", that's what you want (e.g., the process
handle is the module handle). In a DLL, it wouldn't be, as the
DLL would have a different handle than the process.
https://docs.microsoft.com/en-us/windows/win32/api/libloaderapi/nf-libloaderapi-getmodulehandlea