DotNetDupe 4.0.6
C++17/20 Implementation of the .NET Base Class Library (BCL)
Loading...
Searching...
No Matches
Process.h
Go to the documentation of this file.
1
3
4#pragma once
5
6#include "Common.h"
7#include "System/Object.h"
8#include "System/String.h"
10#include "System/Array.h"
11
12namespace DotNetDupe {
13 namespace System {
14 namespace Diagnostics {
15
29
38 class Process : public Object {
39 public:
41 DOTNETDUPE_API Process(int iId, const String& sProcessName, void* pProcessHandle = nullptr);
42 DOTNETDUPE_API virtual ~Process();
43
44 DOTNETDUPE_API ProcessStartInfo GetStartInfo() const { return m_objStartInfo; }
45 DOTNETDUPE_API void SetStartInfo(const ProcessStartInfo& objStartInfo) { m_objStartInfo = objStartInfo; }
46
49 DOTNETDUPE_API bool Start();
50
54 DOTNETDUPE_API static SmartPointer<Process> Start(const String& sFileName);
55
60 DOTNETDUPE_API static SmartPointer<Process> Start(const String& sFileName, const String& sArguments);
61
66
69
73 DOTNETDUPE_API bool WaitForExit(int iMilliseconds);
74
77 DOTNETDUPE_API int GetExitCode() const { return m_iExitCode; }
78
81 DOTNETDUPE_API bool GetHasExited() const;
82
85 DOTNETDUPE_API int GetId() const { return m_iId; }
86
89 DOTNETDUPE_API String GetProcessName() const { return m_sProcessName; }
90
94
98
102
107
112
114 DOTNETDUPE_API void Kill();
115
116 private:
117 ProcessStartInfo m_objStartInfo;
118 int m_iId;
119 String m_sProcessName;
120 mutable int m_iExitCode;
121 mutable bool m_bHasExited;
122 void* m_pProcessHandle;
123
124 void Refresh() const;
125 };
126 }
127 }
128}
Provides methods for creating, manipulating, searching, and sorting arrays.
Defines common cross-platform macros, export decorators, and fundamental types.
#define DOTNETDUPE_API
Platform-specific linkage decoration for exporting or importing library symbols.
Definition Common.h:20
Base object class for DotNetDupe mirroring .NET System.Object.
Provides reference-counted and weak pointer memory management primitives ensuring zero raw ownership.
High-performance UTF-8 / UTF-16 string manipulation class mirroring .NET System.String.
Provides methods for creating, manipulating, searching, and sorting arrays, thereby serving as the ba...
Definition Array.h:29
static int GetCurrentProcessId()
Gets the process identifier of the calling process.
Definition Process.cpp:282
bool Start()
Starts (or reuses) the process resource that is specified by the StartInfo property.
Definition Process.cpp:221
static Array< SmartPointer< Process > > GetProcesses()
Creates an array of new Process components and associates them with all active system processes.
Definition Process.cpp:369
String GetProcessName() const
Gets the name of the process.
Definition Process.h:89
static SmartPointer< Process > GetProcessById(int iProcessId)
Returns a Process component given the identifier of a process on the local computer.
Definition Process.cpp:392
void WaitForExit()
Instructs the Process component to wait indefinitely for the associated process to exit.
Definition Process.cpp:245
ProcessStartInfo GetStartInfo() const
Definition Process.h:44
int GetId() const
Gets the unique identifier for the associated process.
Definition Process.h:85
int GetExitCode() const
Gets the value that the associated process specified when it terminated.
Definition Process.h:77
static Array< SmartPointer< Process > > GetProcessesByName(const String &sProcessName)
Creates an array of new Process components and associates them with all processes sharing the specifi...
Definition Process.cpp:420
void Kill()
Immediately stops the associated process.
Definition Process.cpp:271
bool GetHasExited() const
Gets a value indicating whether the associated process has been terminated.
Definition Process.cpp:266
static SmartPointer< Process > GetCurrentProcess()
Gets a new Process component and associates it with the currently active process.
Definition Process.cpp:409
void SetStartInfo(const ProcessStartInfo &objStartInfo)
Definition Process.h:45
Specifies a set of values that are used when you start a process.
Definition Process.h:17
Supports all classes in the DotNetDupe class hierarchy.
Definition Object.h:18
A unified smart pointer that supports both unique and shared ownership semantics.
Represents text as a sequence of UTF-8 code units with culture-invariant operations.
Definition String.h:74