source: trunk/gsinstaller/launchApp.cpp@ 1537

Last change on this file since 1537 was 1498, checked in by cs025, 24 years ago

Further changes for uninstaller

  • Property svn:keywords set to Author Date Id Revision
File size: 1.7 KB
Line 
1#include "launchapp.h"
2
3#include "gsPlatform.h"
4
5launchApp::launchApp(FilePath &file)
6{ this->exeMap["default"] = file;
7}
8
9void launchApp::platformApp(string platform, FilePath &file)
10{ this->exeMap[platform] = file;
11}
12
13void launchApp::setCommandLine(string commandLine)
14{ this->commandline = commandLine;
15}
16
17int launchApp::run(bool test, int deftest, string prompt, string header, bool wait)
18{ gsPlatform platform;
19 FilePath exePath;
20 string runLine;
21
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;
28 }
29 }
30
31 // get the executable for this platform
32 exePath = this->exeMap[platform.platformString()];
33
34 // if we didn't get it, get the default
35 if (exePath.isEmpty())
36 { exePath = this->exeMap["default"];
37 }
38
39 // couldn't find a path
40 if (exePath.isEmpty())
41 { return -1;
42 }
43
44 // prepare process information fields
45 STARTUPINFO startup;
46 PROCESS_INFORMATION process;
47 startup.cb = sizeof(STARTUPINFO);
48 process.hProcess = 0;
49
50 // build command line if required
51 if (this->commandline != "")
52 { runLine = exePath.pathString() + " " + this->commandline;
53 }
54
55 // execute the process
56 if (CreateProcess((LPSTR) exePath.cString(),
57 runLine != "" ? (LPSTR) runLine.c_str() : NULL,
58 NULL, NULL, FALSE, 0, NULL, NULL,
59 &startup, &process) == 0)
60 { DWORD error = GetLastError();
61 return -2;
62 }
63
64 if (wait)
65 { WaitForSingleObject(process.hProcess, INFINITE);
66 }
67
68 // success: return a positive number
69 return 1;
70}
Note: See TracBrowser for help on using the repository browser.