Changeset 1548
- Timestamp:
- 2000-09-16T00:44:06+12:00 (24 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsinstaller/launchApp.cpp
r1543 r1548 4 4 5 5 launchApp::launchApp(FilePath &file) 6 { 7 this->exeMap["default"] = file; 6 { this->exeMap["default"] = file; 8 7 } 9 8 10 9 void launchApp::platformApp(string platform, FilePath &file) 11 { 12 this->exeMap[platform] = file; 10 { this->exeMap[platform] = file; 13 11 } 14 12 15 13 void launchApp::setCommandLine(string commandLine) 16 { 17 this->commandline = commandLine; 14 { this->commandline = commandLine; 18 15 } 19 16 20 17 int launchApp::run(bool test, int deftest, string prompt, string header, bool wait) 21 { 22 gsPlatform platform; 23 FilePath exePath; 24 string runLine; 18 { gsPlatform platform; 19 FilePath exePath; 20 string runLine; 25 21 26 if (test) 27 { 28 // if user didn't want it then cancel 29 if (MessageBox(0, prompt.c_str(), header.c_str(), 30 MB_YESNO | MB_ICONQUESTION | MB_SYSTEMMODAL | 31 (deftest == 0 ? MB_DEFBUTTON1 : MB_DEFBUTTON2)) == IDNO) 32 { 33 return 0; 34 } 22 if (test) 23 { // if user didn't want it then cancel 24 if (MessageBox(0, prompt.c_str(), header.c_str(), 25 MB_YESNO | MB_ICONQUESTION | MB_SYSTEMMODAL | 26 (deftest == 0 ? MB_DEFBUTTON1 : MB_DEFBUTTON2)) == IDNO) 27 { return 0; 35 28 } 29 } 36 30 37 31 // get the executable for this platform 38 exePath =this->exeMap[platform.platformString()];32 exePath = this->exeMap[platform.platformString()]; 39 33 40 34 // if we didn't get it, get the default 41 35 if (exePath.isEmpty()) 42 { 43 exePath = this->exeMap["default"]; 44 } 36 { exePath = this->exeMap["default"]; 37 } 45 38 46 39 // couldn't find a path 47 40 if (exePath.isEmpty()) 48 { 49 return -1; 50 } 41 { return -1; 42 } 51 43 52 44 // prepare process information fields 53 45 STARTUPINFO startup; 54 PROCESS_INFORMATION process; 55 startup.cb = sizeof(STARTUPINFO); 56 process.hProcess = 0; 46 PROCESS_INFORMATION process; 47 ZeroMemory(&startup, sizeof(STARTUPINFO)); 48 startup.cb = sizeof(STARTUPINFO); 49 process.hProcess = 0; 57 50 58 51 // build command line if required 59 52 if (this->commandline != "") 60 { 61 runLine = exePath.pathString() + " " + this->commandline; 62 } 53 { runLine = exePath.pathString() + " " + this->commandline; 54 } 63 55 64 56 MessageBox(0, exePath.cString(), runLine.c_str(), MB_OK); 65 57 66 67 if ( CreateProcess((LPSTR) exePath.cString(),68 (runLine != "" && false)? (LPSTR) runLine.c_str() : NULL,69 NULL, NULL, FALSE, 0, NULL, NULL,58 // execute the process 59 if (!CreateProcess((LPSTR) exePath.cString(), 60 runLine != "" ? (LPSTR) runLine.c_str() : NULL, 61 NULL, NULL, TRUE, NORMAL_PRIORITY_CLASS, NULL, NULL, 70 62 &startup, &process) == 0) 71 { 72 DWORD error = GetLastError(); 73 MessageBox(0, "Failed", "Failed", MB_OK); 74 return -2; 75 } 63 { DWORD error = GetLastError(); 64 /*char buffer[20]; 65 sprintf(buffer, "%lu", error); 66 MessageBox(0, buffer, "Failed", MB_OK);*/ 67 return -2; 68 } 76 69 77 70 if (wait) 78 { 79 WaitForSingleObject(process.hProcess, INFINITE); 80 } 71 { WaitForSingleObject(process.hProcess, INFINITE); 72 } 81 73 82 74 // success: return a positive number 83 75 return 1; 84 76 } 77
Note:
See TracChangeset
for help on using the changeset viewer.