Qx v0.5.7
Qt Extensions Library
Loading...
Searching...
No Matches
qx-processwaiter_win.h
1#ifndef QX_PROCCESSBIDER_P_WIN_H
2#define QX_PROCCESSBIDER_P_WIN_H
3
4// Qt Includes
5#include <QObject>
6
7// Inter-component Includes
8#include "qx-processwaiter.h"
9
12typedef void* HANDLE;
13typedef unsigned char BOOLEAN;
14#define CALLBACK __stdcall
15
16namespace Qx
17{
18
19/* It's critical in the design of this that these objects are never destroyed (more specifically, never completely destroyed, so
20 * cleanup in destructor is fine) while they have a registered wait */
21class ProcessWaiter : public AbstractProcessWaiter
22{
23 Q_OBJECT
24//-Instance Members------------------------------------------------------------------------------------------
25private:
26 HANDLE mProcessHandle;
27 HANDLE mWaitHandle;
28 HANDLE mTaskKillHandle;
29 HANDLE mAdminCloseHandle;
30 std::function<void(bool)> mAdminCloseCallback;
31 bool mCleaningUp;
32
33//-Constructor----------------------------------------------------------------------------------------------
34public:
35 explicit ProcessWaiter(QObject* parent);
36
37//-Destructor----------------------------------------------------------------------------------------------
38public:
39 ~ProcessWaiter();
40
41//-Class Functions----------------------------------------------------------------------------------------------
42private:
43 static void CALLBACK waitCallback(void* context, BOOLEAN timedOut);
44 static void CALLBACK adminCloseNativeCallback(void* context, BOOLEAN timedOut);
45 static bool processIsElevated(bool def);
46 static bool processIsElevated(HANDLE pHandle, bool def);
47
48//-Instance Functions----------------------------------------------------------------------------------------------
49private:
50 void closeImpl(std::chrono::milliseconds timeout, bool force) override;
51 void closeAdmin(bool force, std::function<void(bool)> callback);
52 bool startAdminClose(bool force);
53 void cleanupAdminCloseHandles();
54 void cleanup();
55
56public:
57 bool wait() override;
58 bool isWaiting() const override;
59
60//-Slots------------------------------------------------------------------------------------------------------------
61public slots:
62 void handleProcessSignaled() override;
63 void handleAdminCloseFinsihed(bool timeout);
64};
65
66}
67
70#endif // QX_PROCCESSBIDER_P_WIN_H
The Qx namespace is the main namespace through which all non-global functionality of the Qx library i...
Definition qx-processwaiter.cpp:5
SystemError processIsElevated(bool &elevated)
Definition qx-common-windows.cpp:270
void * HANDLE
Definition qx-windefs.h:8