win32/coil/Process.cpp
Go to the documentation of this file.
1 // -*- C++ -*-
20 #include <coil/Process.h>
21 
22 namespace coil
23 {
24 
32  int launch_shell(std::string command)
33  {
34 #ifdef UNICODE
35  // std::string -> LPTSTR
36  std::wstring wcommand = string2wstring(command);
37  LPTSTR lpcommand = new TCHAR[wcommand.size() + 1];
38  _tcscpy(lpcommand, wcommand.c_str());
39 #else
40  // std::string -> LPTSTR
41  LPTSTR lpcommand = new TCHAR[command.size() + 1];
42  _tcscpy(lpcommand, command.c_str());
43 #endif // UNICODE
44 
45  STARTUPINFO si;
46  ZeroMemory( &si, sizeof(si) );
47  si.cb = sizeof(si);
48 
49  PROCESS_INFORMATION pi;
50  ZeroMemory( &pi, sizeof(pi) );
51 
52  if(!CreateProcess(NULL, lpcommand, NULL, NULL, FALSE, 0,
53  NULL, NULL, &si, &pi) )
54  {
55  delete lpcommand;
56  return -1;
57  }
58  CloseHandle(pi.hProcess);
59  CloseHandle(pi.hThread);
60  delete lpcommand;
61  return 0;
62  }
63 
64  int daemon(int nochdir, int noclose)
65  {
66  // not implemented
67  return 0;
68  }
69 }; // namespace coil
70 
int launch_shell(std::string command)
Launching a process.
int daemon(int nochdir, int noclose)
std::wstring string2wstring(std::string str)
string to wstring conversion
Definition: stringutil.cpp:40
Common Object Interface Layer.


openrtm_aist
Author(s): Noriaki Ando
autogenerated on Mon Jun 10 2019 14:07:54