how can D program find it's own executable name on windows ?
Mike Parker
aldacron at gmail.com
Tue Jan 29 23:47:13 PST 2013
On Tuesday, 29 January 2013 at 15:51:09 UTC, rsk82 wrote:
> On Tuesday, 29 January 2013 at 15:46:40 UTC, monarch_dodra
> wrote:
>> stdout.writeln(args[0]);
>
> It doesn't work while I have WinMain function that then calls
> myWinMain, as it is winsamp.d
>
> Error: undefined identifier args, did you mean struct CArgs?
If you pass the following on the command line:
-L/SUBSYSTEM:windows:5
You can get rid of your WinMain function and use a standard main,
while still getting a "windowed" app instead of a console app.
Dropping the :5 would allow you to support Windows 9x, but DMD
doesn't (or isn't going to) support that anymore anyway. I always
add :5 for XP and higher.
When running with main, DRuntime stores the args, so you can
access them anywhere in your program by importing core.runtime
and accessing the Runtime.args property. I had assumed that held
true when WinMain was used, but after scanning through the source
I don't see that it is.
More information about the Digitalmars-d-learn
mailing list