Process.cpp
Go to the documentation of this file.
00001 // -*- C++ -*-
00020 #include <coil/Process.h>
00021 
00022 namespace coil
00023 {
00024 
00032   int launch_shell(std::string command)
00033   {
00034 #ifdef UNICODE
00035         // std::string -> LPTSTR
00036     std::wstring wcommand = string2wstring(command);
00037     LPTSTR lpcommand = new TCHAR[wcommand.size() + 1];
00038     _tcscpy(lpcommand, wcommand.c_str());
00039 #else
00040         // std::string -> LPTSTR
00041     LPTSTR lpcommand = new TCHAR[command.size() + 1];
00042     _tcscpy(lpcommand, command.c_str());
00043 #endif // UNICODE
00044 
00045     STARTUPINFO si;
00046     ZeroMemory( &si, sizeof(si) );
00047     si.cb = sizeof(si);
00048 
00049     PROCESS_INFORMATION pi;
00050     ZeroMemory( &pi, sizeof(pi) );
00051 
00052     if(!CreateProcess(NULL, lpcommand, NULL, NULL, FALSE, 0,
00053                       NULL, NULL, &si, &pi) )
00054       {
00055         delete lpcommand;
00056         return -1;
00057       }
00058     CloseHandle(pi.hProcess);
00059     CloseHandle(pi.hThread);
00060     delete lpcommand;
00061     return 0;
00062   }
00063 
00064   int daemon(int nochdir, int noclose)
00065   {
00066     // not implemented
00067     return 0;
00068   }
00069 }; // namespace coil
00070 


openrtm_aist
Author(s): Noriaki Ando
autogenerated on Sun Mar 26 2017 03:37:16