Advertisement

How to use command line with WinMain()?

Started by May 15, 2004 03:07 AM
2 comments, last by Keermalec 20 years, 6 months ago
I currently launch my prog, "viewer.exe" which reads in my world data, "world.dat", but the name "world.dat" is hard-coded into "viewer.exe". I would like to launch viewer with command line parameters such as "viewer.exe world.dat 800x600x32" in order to choose the world data file to read in and, for example, the resolution. I knew how to do this with the dos main() function but how does it work with winmain()? Thanks for your help.
I haven''t personally used the winmain() command line parameters, only dos. But wimain() has a 3rd parameter that is a pointer to a null terminated command line string, often named szCmdLine in the parameter list. Exploit that.
Well, R2D22U2..
Advertisement
GetCommandLine()
"Literally, it means that Bob is everything you can think of, but not dead; i.e., Bob is a purple-spotted, yellow-striped bumblebee/dragon/pterodactyl hybrid with a voracious addiction to Twix candy bars, but not dead."- kSquared
The third parameter of WinMain() is equivalent to the string returned by GetCommandLine() with the EXE file path removed. So you have to parse it into individual tokens yourself.

This topic is closed to new replies.

Advertisement