Gray C++ Libraries  0.0.2
A set of C++ libraries for MSVC, GNU on Windows, WinCE, Linux
cOSProcessX.h
Go to the documentation of this file.
1 //
4 //
5 
6 #ifndef _INC_cOSProcessX_H
7 #define _INC_cOSProcessX_H
8 #ifndef NO_PRAGMA_ONCE
9 #pragma once
10 #endif
11 
12 #include "../GrayLibBase.h"
16 #include "GrayCore/include/cOSProcess.h" // PROCESSID_t;
18 #include "GrayCore/include/cFile.h"
19 
20 #ifdef _WIN32
21 
22 #elif defined(__linux__)
23 #include <signal.h>
24 typedef size_t SIZE_T;
25 #else
26 
27 #error NOOS
28 #endif
29 
30 namespace GrayLib
31 {
33 
35  {
39  typedef cOSModule SUPER_t;
40 
41 #if defined(_WIN32) && ! defined(UNDER_CE)
42  public:
43  HANDLE m_hProcess;
44 
45  public:
46  UINT GetModulePath(OUT FILECHAR_t* pszModuleName, StrLen_t nSizeMax) const;
47  cString get_Name() const;
48 #endif
49 
50  public:
51  cOSModuleX(HANDLE hProcess = INVALID_HANDLE_VALUE, HMODULE hModule = HMODULE_NULL, bool bHaveRefCount = false)
52  : cOSModule(hModule, bHaveRefCount)
53  {
54 #if defined(_WIN32) && ! defined(UNDER_CE)
55  m_hProcess = hProcess;
56 #endif
57  }
58  void AttachModule(HANDLE hProcess, HMODULE hModule, bool bHaveRefCount)
59  {
60  FreeModuleLast();
61 #if defined(_WIN32) && ! defined(UNDER_CE)
62  m_hProcess = hProcess;
63 #endif
64  SUPER_t::AttachModule(hModule, bHaveRefCount);
65  }
66  };
67 
69  {
74  typedef cOSProcess SUPER_t;
75 
76  public:
77  cOSProcessX();
78  virtual ~cOSProcessX();
79 
80  static HRESULT GRAYCALL EnumProcesses(OUT PROCESSID_t* pnProcessIDs, COUNT_t iQtyMax);
81  static HRESULT GRAYCALL FindProcessByName(const FILECHAR_t* pszName, OUT PROCESSID_t* pnProcessIDs, COUNT_t iInstQty);
82 
83 #if defined(_WIN32) && ! defined(UNDER_CE)
84  virtual cStringF get_ProcessPath() const;
85 
86  HRESULT GetModules(OUT HMODULE* pHandles, ITERATE_t uCount) const;
87  HRESULT GetModules(cArrayStruct<cOSModuleX>& aModules) const;
88  HMODULE get_ModuleHandle() const;
89  HRESULT FindHandleNames(const cArrayString<>& aLockedFiles) const;
90 #endif
91 
92  static bool GRAYCALL FindCmdForMime(OUT FILECHAR_t* pszExeNameRet, StrLen_t iLenNameMax, const FILECHAR_t* pszMimeType);
93 
94  HRESULT StartProcess(const FILECHAR_t* pszExeName, const FILECHAR_t* pszArgs = nullptr, TIMESYSD_t nTimeWait = cTimeSys::k_CLEAR, SHOWWINDOW_t nShowCmd = SW_SHOWNORMAL, const FILECHAR_t* pszCurrentDir = nullptr, const FILECHAR_t* pszFileOutPipe = nullptr, OUT APP_EXITCODE_t* pnExitCode = nullptr);
95  HRESULT StartProcessCmd(const FILECHAR_t* pszCmd, const FILECHAR_t* pszDocument, TIMESYSD_t nWait = cTimeSys::k_INF, SHOWWINDOW_t nShowCmd = SW_SHOWNORMAL);
96  HRESULT ShellExec(const FILECHAR_t* pszVerb, const FILECHAR_t* pszDocument, const FILECHAR_t* pszMimeType = nullptr, SHOWWINDOW_t nShowCmd = SW_SHOWNORMAL, const FILECHAR_t* pszParams = nullptr, const FILECHAR_t* pszDir = nullptr);
97 
99  };
100 };
101 #endif // _INC_cOSProcessX_H
#define GRAYCALL
declare calling convention for static functions so everyone knows the arg passing scheme....
Definition: GrayCore.h:36
#define GRAYLIB_LINK
Definition: GrayLibBase.h:35
INT32 HRESULT
_WIN32 style error codes. INT32
Definition: SysTypes.h:465
#define HMODULE_NULL
Definition: cOSModule.h:31
Definition: cOSProcessX.h:35
cOSModuleX(HANDLE hProcess=INVALID_HANDLE_VALUE, HMODULE hModule=HMODULE_NULL, bool bHaveRefCount=false)
Definition: cOSProcessX.h:51
void AttachModule(HANDLE hProcess, HMODULE hModule, bool bHaveRefCount)
Definition: cOSProcessX.h:58
Definition: cOSProcessX.h:69
UNITTEST2_PREDEF(cOSProcessX)
Definition: cArrayString.h:19
Definition: cArray.h:932
Definition: cOSModule.h:34
Definition: cOSProcess.h:68
static const TIMESYS_t k_CLEAR
Definition: cTimeSys.h:99
static const TIMESYS_t k_INF
INFINITE in _WIN32. MAILSLOT_WAIT_FOREVER.
Definition: cTimeSys.h:101
Definition: cMesh.h:22
UNITTEST2_PREDEF(cQuadtree)
int StrLen_t
the length of a string in chars (bytes for UTF8, wchar_t for UNICODE). or offset in characters....
Definition: StrConst.h:32
size_t COUNT_t
like size_t but a count of things that might NOT be bytes. ASSUME unsigned. _countof(x)
Definition: Index.h:32
INT32 TIMESYSD_t
Time delta. signed milli-Seconds Span. cTimeSys::k_DMAX, cTimeSys::k_INF = MAILSLOT_WAIT_FOREVER.
Definition: cTimeSys.h:28
int ITERATE_t
like size_t but signed
Definition: Index.h:28
char FILECHAR_t
a UTF8 char in a file name. like TCHAR
Definition: FileName.h:22