Why is the Win32 boilerplate the way it is?
Jeremy Sorensen via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sun Jun 29 22:30:21 PDT 2014
On Sunday, 29 June 2014 at 07:51:50 UTC, Jacob Carlborg wrote:
> You don't need to use WinMain. You can use a plain D main
> function and add the "-L/SUBSYSTEM:WINDOWS:4.0" link flag to
> suppress the console. There are API's to get access to the
> arguments passed to WinMain, if necessary.
Thanks for your help on this, I couldn't find a way to get the
nCmdShow argument, is it safe to assume SW_SHOWNORMAL for
starting a new application?
So the situation so far is this:
1. You don't need hPrevInstance
2. You can get hInstance via GetModuleHandle(null) (I think that
is the best way)
3. [awesome] use main(string[] args) to get your command line
arguments exactly like you are used to (except no program name, I
tested this)
4. You don't have to worry about the runtime, it is handled
automatically
5. You don't have to catch at the top level and put up a message
box, this is also done automatically
Assuming the nCmdShow thing isn't a problem I see no reason why
the wiki should tell people to use WinMain at all.
More information about the Digitalmars-d-learn
mailing list