How to have the ability to execute like game.exe -easy?

Started by
2 comments, last by SledgeHammer 22 years, 3 months ago
Hi. I am using win32 application to build using vc++ 6.0.I want to have my game to have multiple level of difficulties, and i want to run it using batch file like game -easy game -normal game -hard How can i achieve that? Thanks in advance
Advertisement
int WINAPI WinMain(
HINSTANCE hInstance, // handle to current instance
HINSTANCE hPrevInstance, // handle to previous instance
LPSTR lpCmdLine, // pointer to command line
int nCmdShow // show state of window
);

lpCmdLine contains the command line excluding the program name
Ex:
c:\game test
lpCmdLine contains test
humanity will always be slaved by its ignorance
Actually, in that example, I believe lpCmdLine contains "game.exe test". But all you have to do is MessageBox( NULL, lpCmdLine, NULL, MB_OK ); and find out for yourself.

Then you just parse it. I wrote a simple string parser that converts it into int argc and char** argv like in a DOS (or Console) program. It''s really pretty easy, since you know all words are seperated by one space. No tabs or multiple spaces or anything.

~CGameProgrammer( );

~CGameProgrammer( );Developer Image Exchange -- New Features: Upload screenshots of your games (size is unlimited) and upload the game itself (up to 10MB). Free. No registration needed.
quote:
I wrote a simple string parser that converts it into int argc and char** argv like in a DOS (or Console) program.


Try CommandLineToArgvW() instead (note that it''s Unicode).


"If people are good only because they fear punishment and hope for reward, then we are a sorry lot indeed." - Albert Einstein

This topic is closed to new replies.

Advertisement