Debian Codegraph @

CodeLite/winprocess.h

raw
1 //////////////////////////////////////////////////////////////////////////////
2 //////////////////////////////////////////////////////////////////////////////
3 //
4 // copyright : (C) 2008 by Eran Ifrah
5 // file name : winprocess.h
6 //
7 // -------------------------------------------------------------------------
8 // A
9 // _____ _ _ _ _
10 // / __ \ | | | | (_) |
11 // | / \/ ___ __| | ___| | _| |_ ___
12 // | | / _ \ / _ |/ _ \ | | | __/ _ )
13 // | \__/\ (_) | (_| | __/ |___| | || __/
14 // \____/\___/ \__,_|\___\_____/_|\__\___|
15 //
16 // F i l e
17 //
18 // This program is free software; you can redistribute it and/or modify
19 // it under the terms of the GNU General Public License as published by
20 // the Free Software Foundation; either version 2 of the License, or
21 // (at your option) any later version.
22 //
23 //////////////////////////////////////////////////////////////////////////////
24 //////////////////////////////////////////////////////////////////////////////
25 #ifndef __winprocess__
26 #define __winprocess__
27
28 #ifdef __WXMSW__
29
30 #include "wx/msw/wrapwin.h" // includes windows.h
31 #include <wx/string.h>
32
33 class WinProcess
34 {
35 public:
36 WinProcess();
37 virtual ~WinProcess();
38
39 // Create process asynchronously and return a process object
40 static WinProcess* Execute(const wxString& cmd, wxString& errMsg, const wxString& workingDir = wxEmptyString);
41
42 // Read from process stdout - return immediately if no data is available
43 bool Read(wxString& buff);
44
45 // Write to the process stdin
46 bool Write(const wxString& buff);
47
48 // Return true if the process is still alive
49 bool IsAlive();
50
51 // Clean the process resources and kill the process if it is
52 // still alive
53 void Cleanup();
54
55 private:
56 // WINDOWS implementation
57 // Creating process related handles
58 HANDLE hChildStdinRd, hChildStdinWr, hChildStdinWrDup, hChildStdoutRd, hChildStdoutWr, hChildStdoutRdDup,
59 hSaveStdin, hSaveStdout;
60
61 // Child process id & information
62 DWORD dwProcessId;
63 PROCESS_INFORMATION piProcInfo;
64 };
65
66 #endif
67
68 #endif // __winprocess__