I've been practicing some "useful" C++ syntax in a way I can interact with windows. I've learned ShellExecute, I've tried using it to start up a game (Okay...); but I think I got a wrong syntax cuz the build file called RUN.exe when put in the game folder doesn't call the game, as supposed.
here's the code
(1) I know the handle must be NULL because i doesn't open in a window.
(2) I'm not too sure about the file path, as the file path depends on the game folder.
(3) I've included the " -console -game cstrike" in the file path because I'm not sure wethere they are called parameters (don't actually know what exactly parameters are)
Always read documentation for the function you want. You need to be careful with the directory components. Also, be careful with escape sequences in string literals.
1 2 3 4 5 6 7 8 9 10 11 12 13
string dir = "D:\\somewhere";
if ((unsigned)ShellExecute(
NULL,
"open",
(dir + "\\hl.exe").c_str(),
"-console -game cstrike",
dir.c_str(),
SW_SHOWNORMAL
) <= 32)
{
cerr << "Fooey. I could not execute \"hl.exe\".\n";
return 1;
}