Hello! I'm a beginner in the worl of C++. I'm building a program that acts as a launcher for a game. In it I have Start and Exit button. What I want the Start button to do is start an .exe with extra conditions: IP and Port.

if (nResponse == IDOK)
	{
		// Code when hit Start
	}

Code what I want to enter is:

dklegend.exe NEWSTART Futec(***********:9909)

How should I have my if condition written to make this happen?

The app is an MFC!

Recommended Answers

All 3 Replies

:S been 11 hrs and no one replied.. I guess I'll go by the title of this thread

"run a cmd code in mfc app"

cmd commands would be as useful as using system();
so for the cmd command: taskkill /F /IM notepad.exe
you would write in c++ system("task kill /F /IM notepad.exe");

As for the game your trying to start, I would say right cick the exe and press properties.. in the target field I guess u can enter +port 27015 or whatever.. At least thats how it works for most games.. in c++ im not sure how you would go about that.. other than the system(); call

There are at least three ways to launch a process -- system(), ShellExecute() and CreteProcess(). Which one you want to use depends on how much control you want over the newly created process. google for those functions and you will see how to use them. CreateProcess() is the most complicated, but also gives you the most control.

Thank you for your help on this!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.