Archived

This topic is now archived and is closed to further replies.

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

This topic is 5819 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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( );

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites