Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Executing included file with command line parameter

Status
Not open for further replies.

emperorevil

Programmer
Apr 28, 2002
23
0
0
US
Here's what I need to do:

There's this program that runs differently from executing it regularly and when you run it from a command line with the parameter TestPlay.

What I want to do is make another application that will automatically run file.exe as if it were executed with the TestPlay parameter.

How would I do this with minimal file size?
 
Replace YOURPROG.EXE with the actual filename. Small enough??


#include <windows.h>

int WINAPI WinMain ( HINSTANCE hInst,
HINSTANCE hPrevInst,
LPSTR lpCommandLine,
int cCmdShow )
{
STARTUPINFO su;
memset ( &su, 0, sizeof ( su ));
su.cb = sizeof ( su );
PROCESS_INFORMATION pi;
if ( CreateProcess ( NULL, &quot;YOURPROG.EXE TestPlay&quot;, NULL, NULL,
FALSE, 0, NULL, NULL, &su, &pi ))
{ CloseHandle ( pi.hProcess );
CloseHandle ( pi.hThread ); }
return 0; }

NOTE: You could also make a shortcut to your program and add the TestPlay parameter to the shortcut. In that case you wouldn't need any program at all.

Marcel
 
Thanks a lot!

But, what I meant to say is how would I do it if it was all going to be one file. Like including file.exe within the application and running it with TestPlay. That's what I meant by minimal space.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top