WinStd Additional templates and function helpers for Microsoft Windows using Standard C++ classes

WinTrust.h
1/*
2 SPDX-License-Identifier: MIT
3 Copyright © 1991-2022 Amebis
4 Copyright © 2016 GÉANT
5*/
6
7#pragma once
8
9#include "Common.h"
10#include <WinTrust.h>
11
12 namespace winstd
13{
19
23 class wintrust
24 {
25 WINSTD_NONCOPYABLE(wintrust)
26 WINSTD_NONMOVABLE(wintrust)
27
28 public:
32 wintrust(_In_opt_ HWND hwnd, _In_ const GUID &action, _Inout_ WINTRUST_DATA &wtd) :
33 m_hwnd(hwnd),
34 m_action(action),
35 m_wtd(wtd)
36 {
37 const LONG lResult = WinVerifyTrust(m_hwnd, &m_action, &m_wtd);
38 if (lResult != ERROR_SUCCESS)
39 throw win_runtime_error(lResult, "WinVerifyTrust failed.");
40 }
41
45 virtual ~wintrust()
46 {
47 m_wtd.dwStateAction = WTD_STATEACTION_CLOSE;
48 WinVerifyTrust(m_hwnd, &m_action, &m_wtd);
49 }
50
51 protected:
52 HWND m_hwnd;
53 GUID m_action;
54 WINTRUST_DATA &m_wtd;
55 };
56
58}
winstd::win_runtime_error
Windows runtime error.
Definition: Common.h:1026
winstd::wintrust
WinTrust engine wrapper class.
Definition: WinTrust.h:24
winstd::wintrust::wintrust
wintrust(_In_opt_ HWND hwnd, _In_ const GUID &action, _Inout_ WINTRUST_DATA &wtd)
Initializes a new class instance.
Definition: WinTrust.h:32
winstd::wintrust::~wintrust
virtual ~wintrust()
Destroys the WinTrust context.
Definition: WinTrust.h:45
WINSTD_NONCOPYABLE
#define WINSTD_NONCOPYABLE(C)
Declares a class as non-copyable.
Definition: Common.h:53
WINSTD_NONMOVABLE
#define WINSTD_NONMOVABLE(C)
Declares a class as non-movable.
Definition: Common.h:61