WinStd
Additional templates and function helpers for Microsoft Windows using Standard C++ classes
SetupAPI.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 <SetupAPI.h>
11
12namespace winstd
13{
19
26 class setup_device_info_list : public handle<HDEVINFO, INVALID_HANDLE_VALUE>
27 {
28 WINSTD_HANDLE_IMPL(setup_device_info_list, INVALID_HANDLE_VALUE)
29
30 public:
37 {
38 if (m_h != invalid)
40 }
41
42 protected:
48 void free_internal() noexcept override
49 {
50 SetupDiDestroyDeviceInfoList(m_h);
51 }
52 };
53
58 {
61
62 public:
69 _In_ HDEVINFO DeviceInfoSet,
70 _Inout_opt_ PSP_DEVINFO_DATA DeviceInfoData,
71 _In_ DWORD DriverType) noexcept :
72 m_DeviceInfoSet (DeviceInfoSet),
73 m_DeviceInfoData(DeviceInfoData),
74 m_DriverType (DriverType)
75 {
76 m_result = SetupDiBuildDriverInfoList(m_DeviceInfoSet, m_DeviceInfoData, m_DriverType);
77 }
78
85 {
86 if (m_result)
87 SetupDiDestroyDriverInfoList(m_DeviceInfoSet, m_DeviceInfoData, m_DriverType);
88 }
89
95 BOOL status() const noexcept
96 {
97 return m_result;
98 }
99
100 protected:
102 HDEVINFO m_DeviceInfoSet;
103 PSP_DEVINFO_DATA m_DeviceInfoData;
104 DWORD m_DriverType;
105 BOOL m_result;
107 };
108
110}
Base abstract template class to support generic object handle keeping.
Definition: Common.h:603
handle_type m_h
Object handle.
Definition: Common.h:854
HDEVINFO wrapper class.
Definition: SetupAPI.h:27
virtual ~setup_device_info_list()
Frees the device information set.
Definition: SetupAPI.h:36
void free_internal() noexcept override
Frees the device information set.
Definition: SetupAPI.h:48
Builds a list of drivers in constructor and deletes it in destructor.
Definition: SetupAPI.h:58
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:68
virtual ~setup_driver_info_list_builder()
Deletes a driver list and destructs the builder.
Definition: SetupAPI.h:84
BOOL status() const noexcept
Return result of SetupDiBuildDriverInfoList() call.
Definition: SetupAPI.h:95
#define WINSTD_NONCOPYABLE(C)
Declares a class as non-copyable.
Definition: Common.h:52
#define WINSTD_NONMOVABLE(C)
Declares a class as non-movable.
Definition: Common.h:60
#define WINSTD_HANDLE_IMPL(C, INVAL)
Implements default constructors and operators to prevent their auto-generation by compiler.
Definition: Common.h:161
static const HDEVINFO invalid
Invalid handle value.
Definition: Common.h:613