WinStd Windows Win32 API using Standard C++

Loading...
Searching...
No Matches
SetupAPI.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 <SetupAPI.h>
13
14 namespace winstd
15{
18
25 class setup_device_info_list : public handle<HDEVINFO, INVALID_HANDLE_VALUE>
26 {
27 WINSTD_HANDLE_IMPL(setup_device_info_list, HDEVINFO, INVALID_HANDLE_VALUE)
28
29 public:
35 virtual ~setup_device_info_list()
36 {
37 if (m_h != invalid)
38 free_internal();
39 }
40
41 protected:
47 void free_internal() noexcept override
48 {
49 SetupDiDestroyDeviceInfoList(m_h);
50 }
51 };
52
56 class setup_driver_info_list_builder
57 {
58 WINSTD_NONCOPYABLE(setup_driver_info_list_builder)
59 WINSTD_NONMOVABLE(setup_driver_info_list_builder)
60
61 public:
67 setup_driver_info_list_builder(
68 _In_ HDEVINFO DeviceInfoSet,
69 _Inout_opt_ PSP_DEVINFO_DATA DeviceInfoData,
70 _In_ DWORD DriverType) noexcept :
71 m_DeviceInfoSet (DeviceInfoSet),
72 m_DeviceInfoData(DeviceInfoData),
73 m_DriverType (DriverType)
74 {
75 m_result = SetupDiBuildDriverInfoList(m_DeviceInfoSet, m_DeviceInfoData, m_DriverType);
76 }
77
83 virtual ~setup_driver_info_list_builder()
84 {
85 if (m_result)
86 SetupDiDestroyDriverInfoList(m_DeviceInfoSet, m_DeviceInfoData, m_DriverType);
87 }
88
94 BOOL status() const noexcept
95 {
96 return m_result;
97 }
98
99 protected:
101 HDEVINFO m_DeviceInfoSet;
102 PSP_DEVINFO_DATA m_DeviceInfoData;
103 DWORD m_DriverType;
104 BOOL m_result;
106 };
107
109}
winstd::handle
Base abstract template class to support generic object handle keeping.
Definition Common.h:1024
winstd::handle< HDEVINFO, INVALID_HANDLE_VALUE >::m_h
handle_type m_h
Object handle.
Definition Common.h:1276
winstd::ref_unique_ptr
Helper class for returning pointers to std::unique_ptr.
Definition Common.h:863
winstd::setup_device_info_list
HDEVINFO wrapper class.
Definition SetupAPI.h:26
winstd::setup_device_info_list::~setup_device_info_list
virtual ~setup_device_info_list()
Frees the device information set.
Definition SetupAPI.h:35
winstd::setup_device_info_list::free_internal
void free_internal() noexcept override
Frees the device information set.
Definition SetupAPI.h:47
winstd::setup_driver_info_list_builder
Builds a list of drivers in constructor and deletes it in destructor.
Definition SetupAPI.h:57
winstd::setup_driver_info_list_builder::setup_driver_info_list_builder
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:67
winstd::setup_driver_info_list_builder::~setup_driver_info_list_builder
virtual ~setup_driver_info_list_builder()
Deletes a driver list and destructs the builder.
Definition SetupAPI.h:83
winstd::setup_driver_info_list_builder::status
BOOL status() const noexcept
Return result of SetupDiBuildDriverInfoList() call.
Definition SetupAPI.h:94
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
WINSTD_HANDLE_IMPL
#define WINSTD_HANDLE_IMPL(C, T, INVAL)
Implements default constructors and operators to prevent their auto-generation by compiler.
Definition Common.h:164
winstd::handle< HDEVINFO, INVALID_HANDLE_VALUE >::invalid
static const HDEVINFO invalid
Invalid handle value.
Definition Common.h:1034