argv[0] in Win32 Application (VC++ 6)?

In a console application, argv[0] is the current filepath of the exe..
is there anything similar to this in a Win32 Application which does not has main?
Don't Win32 applictions ahave a WinMain() or something like that?
Last edited on
In a console application, argv[0] is the current filepath of the exe..


That is not true.

argv[0] is just the command used to invoke the program. If run from the commandline, it likely will not be the full path of the exe unless the user actually typed in the full path.

When run from Windows Explorer (by double-clicking on the exe), it's likely that explorer launches the program with the full pathname... but you should not rely on argv[0] always being the full path, because it isn't.

is there anything similar to this in a Win32 Application which does not has main?


If you need to get the full path to the current exe, use GetModuleFileName:

http://msdn.microsoft.com/en-us/library/windows/desktop/ms683197%28v=vs.85%29.aspx


EDIT: also, you really should throw VC++6 away and get a more recent compiler. VC++6 is pre-standard so it can't compile a lot of valid C++ code... and code that you write for it likely will not compile in modern compilers.
Last edited on
Win32 App has Winmain, does it has anything like argv[0]?
i will use GetModuleFileName but argv[0] is much simpler..

also, you really should throw VC++6 away and get a more recent compiler. VC++6 is pre-standard so it can't compile a lot of valid C++ code... and code that you write for it likely will not compile in modern compilers.

i agree with you, which compiler would you recommend?
All win32 apps have CommandLineToArgvW and GetCommandLine APIs, use them
Topic archived. No new replies allowed.