WinStd Windows Win32 API using Standard C++

Loading...
Searching...
No Matches
WinTrust.h
1/*
2 SPDX-License-Identifier: MIT
3 Copyright © 1991-2024 Amebis
4 Copyright © 2016 GÉANT
5*/
6
8
9#pragma once
10
11#include "Common.h"
12#include <WinTrust.h>
13
14 namespace winstd
15{
18
22 class wintrust
23 {
24 WINSTD_NONCOPYABLE(wintrust)
25 WINSTD_NONMOVABLE(wintrust)
26
27 public:
31 wintrust(_In_opt_ HWND hwnd, _In_ const GUID &action, _Inout_ WINTRUST_DATA &wtd) :
32 m_hwnd(hwnd),
33 m_action(action),
34 m_wtd(wtd)
35 {
36 const LONG lResult = WinVerifyTrust(m_hwnd, &m_action, &m_wtd);
37 if (lResult != ERROR_SUCCESS)
38 throw win_runtime_error(lResult, "WinVerifyTrust failed");
39 }
40
44 virtual ~wintrust()
45 {
46 m_wtd.dwStateAction = WTD_STATEACTION_CLOSE;
47 WinVerifyTrust(m_hwnd, &m_action, &m_wtd);
48 }
49
50 protected:
52 HWND m_hwnd;
53 GUID m_action;
54 WINTRUST_DATA &m_wtd;
56 };
57
59}
winstd::ref_unique_ptr
Helper class for returning pointers to std::unique_ptr.
Definition Common.h:863
winstd::win_runtime_error
Windows runtime error.
Definition Common.h:1524
winstd::wintrust
WinTrust engine wrapper class.
Definition WinTrust.h:23
winstd::wintrust::wintrust
wintrust(HWND hwnd, const GUID &action, WINTRUST_DATA &wtd)
Initializes a new class instance.
Definition WinTrust.h:31
winstd::wintrust::~wintrust
virtual ~wintrust()
Destroys the WinTrust context.
Definition WinTrust.h:44
WINSTD_NONCOPYABLE
#define WINSTD_NONCOPYABLE(C)
Declares a class as non-copyable.
Definition Common.h:67
WINSTD_NONMOVABLE
#define WINSTD_NONMOVABLE(C)
Declares a class as non-movable.
Definition Common.h:75