WinStd
Additional templates and function helpers for Microsoft Windows using Standard C++ classes
SetupAPI.h
Go to the documentation of this file.
1/*
2 SPDX-License-Identifier: MIT
3 Copyright © 1991-2022 Amebis
4 Copyright © 2016 GÉANT
5*/
6
12
13#pragma once
14
15#include "Common.h"
16#include <SetupAPI.h>
17
18namespace winstd
19{
22
29 class setup_device_info_list : public handle<HDEVINFO, INVALID_HANDLE_VALUE>
30 {
31 WINSTD_HANDLE_IMPL(setup_device_info_list, INVALID_HANDLE_VALUE)
32
33 public:
40 {
41 if (m_h != invalid)
43 }
44
45 protected:
51 void free_internal() noexcept override
52 {
53 SetupDiDestroyDeviceInfoList(m_h);
54 }
55 };
56
61 {
64
65 public:
72 _In_ HDEVINFO DeviceInfoSet,
73 _Inout_opt_ PSP_DEVINFO_DATA DeviceInfoData,
74 _In_ DWORD DriverType) noexcept :
75 m_DeviceInfoSet (DeviceInfoSet),
76 m_DeviceInfoData(DeviceInfoData),
77 m_DriverType (DriverType)
78 {
79 m_result = SetupDiBuildDriverInfoList(m_DeviceInfoSet, m_DeviceInfoData, m_DriverType);
80 }
81
88 {
89 if (m_result)
90 SetupDiDestroyDriverInfoList(m_DeviceInfoSet, m_DeviceInfoData, m_DriverType);
91 }
92
98 BOOL status() const noexcept
99 {
100 return m_result;
101 }
102
103 protected:
105 HDEVINFO m_DeviceInfoSet;
106 PSP_DEVINFO_DATA m_DeviceInfoData;
107 DWORD m_DriverType;
108 BOOL m_result;
110 };
111
113}
General API.
Integrates WinStd classes with Microsoft Setup API.
Base abstract template class to support generic object handle keeping.
Definition: Common.h:615
handle_type m_h
Object handle.
Definition: Common.h:866
HDEVINFO wrapper class.
Definition: SetupAPI.h:30
virtual ~setup_device_info_list()
Frees the device information set.
Definition: SetupAPI.h:39
void free_internal() noexcept override
Frees the device information set.
Definition: SetupAPI.h:51
Builds a list of drivers in constructor and deletes it in destructor.
Definition: SetupAPI.h:61
setup_driver_info_list_builder(HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, DWORD DriverType) noexcept
Construct the builder and builds a list of drivers that is associated with a specific device or with ...
Definition: SetupAPI.h:71
virtual ~setup_driver_info_list_builder()
Deletes a driver list and destructs the builder.
Definition: SetupAPI.h:87
BOOL status() const noexcept
Return result of SetupDiBuildDriverInfoList() call.
Definition: SetupAPI.h:98
#define WINSTD_NONCOPYABLE(C)
Declares a class as non-copyable.
Definition: Common.h:74
#define WINSTD_NONMOVABLE(C)
Declares a class as non-movable.
Definition: Common.h:82
#define WINSTD_HANDLE_IMPL(C, INVAL)
Implements default constructors and operators to prevent their auto-generation by compiler.
Definition: Common.h:171
static const HDEVINFO invalid
Invalid handle value.
Definition: Common.h:625