void PlayerWin::openNewPlayerWithProjectConfig(const ProjectConfig &config) { static long taskid = 100; stringstream buf; buf << taskid++; string commandLine; commandLine.append(getApplicationExePath()); if (!config.isWelcome()) { commandLine.append(" "); commandLine.append(config.makeCommandLine()); } CCLOG("PlayerWin::openNewPlayerWithProjectConfig(): %s", commandLine.c_str()); // http://msdn.microsoft.com/en-us/library/windows/desktop/ms682499(v=vs.85).aspx SECURITY_ATTRIBUTES sa = {0}; sa.nLength = sizeof(sa); PROCESS_INFORMATION pi = {0}; STARTUPINFO si = {0}; si.cb = sizeof(STARTUPINFO); #define MAX_COMMAND 1024 // lenth of commandLine is always beyond MAX_PATH WCHAR command[MAX_COMMAND]; memset(command, 0, sizeof(command)); MultiByteToWideChar(CP_ACP, 0, commandLine.c_str(), -1, command, MAX_COMMAND); BOOL success = CreateProcess(NULL, command, // command line NULL, // process security attributes NULL, // primary thread security attributes FALSE, // handles are inherited 0, // creation flags NULL, // use parent's environment NULL, // use parent's current directory &si, // STARTUPINFO pointer &pi); // receives PROCESS_INFORMATION if (!success) { CCLOG("PlayerTaskWin::run() - create process failed, for execute %s", commandLine.c_str()); } }