WinTrust.h
/*
SPDX-License-Identifier: MIT
Copyright © 1991-2022 Amebis
Copyright © 2016 GÉANT
*/
#pragma once
#include "Common.h"
#include <WinTrust.h>
namespace winstd
{
class wintrust
{
WINSTD_NONCOPYABLE(wintrust)
WINSTD_NONMOVABLE(wintrust)
public:
wintrust(_In_opt_ HWND hwnd, _In_ const GUID &action, _Inout_ WINTRUST_DATA &wtd) :
m_hwnd(hwnd),
m_action(action),
m_wtd(wtd)
{
const LONG lResult = WinVerifyTrust(m_hwnd, &m_action, &m_wtd);
if (lResult != ERROR_SUCCESS)
throw win_runtime_error(lResult, "WinVerifyTrust failed.");
}
virtual ~wintrust()
{
m_wtd.dwStateAction = WTD_STATEACTION_CLOSE;
WinVerifyTrust(m_hwnd, &m_action, &m_wtd);
}
protected:
HWND m_hwnd;
GUID m_action;
WINTRUST_DATA &m_wtd;
};
}
winstd::win_runtime_error
Windows runtime error.
Definition: Common.h:1048
winstd::wintrust
WinTrust engine wrapper class.
Definition: WinTrust.h:24
winstd::wintrust::wintrust
wintrust(HWND hwnd, const GUID &action, 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