Changeset 1548


Ignore:
Timestamp:
2000-09-16T00:44:06+12:00 (24 years ago)
Author:
cs025
Message:

Fixed problem in running executables on Windows NT/2000

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsinstaller/launchApp.cpp

    r1543 r1548  
    44
    55launchApp::launchApp(FilePath &file)
    6 {
    7   this->exeMap["default"] = file;
     6{   this->exeMap["default"] = file;
    87}
    98
    109void launchApp::platformApp(string platform, FilePath &file)
    11 {
    12   this->exeMap[platform] = file;
     10{   this->exeMap[platform] = file;
    1311}
    1412
    1513void launchApp::setCommandLine(string commandLine)
    16 {
    17   this->commandline = commandLine;
     14{   this->commandline = commandLine;
    1815}
    1916
    2017int 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;
    2521
    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;
    3528    }
     29  }
    3630
    3731  // get the executable for this platform
    38   exePath = this->exeMap[platform.platformString()];
     32  exePath   =   this->exeMap[platform.platformString()];
    3933
    4034  // if we didn't get it, get the default
    4135  if (exePath.isEmpty())
    42     {
    43       exePath = this->exeMap["default"];
    44     }
     36  { exePath = this->exeMap["default"];
     37  }
    4538
    4639  // couldn't find a path
    4740  if (exePath.isEmpty())
    48     {
    49       return -1;
    50     }
     41  { return -1;
     42  }
    5143
    5244  // prepare process information fields
    5345  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;
    5750
    5851  // build command line if required
    5952  if (this->commandline != "")
    60     {
    61       runLine = exePath.pathString() + " " + this->commandline;
    62     }
     53  { runLine = exePath.pathString() + " " + this->commandline;
     54  }
    6355
    6456  MessageBox(0, exePath.cString(), runLine.c_str(), MB_OK);
    6557
    66   // execute the process
    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,
    7062                    &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  }
    7669
    7770  if (wait)
    78     {
    79       WaitForSingleObject(process.hProcess, INFINITE);
    80     }
     71  { WaitForSingleObject(process.hProcess, INFINITE);
     72  }
    8173
    8274  // success: return a positive number
    8375  return 1;
    8476}
     77
Note: See TracChangeset for help on using the changeset viewer.