forked from CHMP-HLab/HLab
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSetupApi.cs
More file actions
86 lines (68 loc) · 2.71 KB
/
Copy pathSetupApi.cs
File metadata and controls
86 lines (68 loc) · 2.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/*
HLab.Windows.API
Copyright (c) 2021 Mathieu GRENET. All right reserved.
This file is part of HLab.Windows.API.
HLab.Windows.API is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
HLab.Windows.API is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with MouseControl. If not, see <http://www.gnu.org/licenses/>.
mailto:mathieu@mgth.fr
http://www.mgth.fr
*/
using System;
using System.Runtime.InteropServices;
using System.Security;
namespace HLab.Sys.Windows.API;
[SuppressUnmanagedCodeSecurity]
public static partial class SetupApi
{
const string DLL = $"{nameof(SetupApi)}.dll";
[StructLayout(LayoutKind.Sequential)]
public struct SP_DEVINFO_DATA
{
public uint cbSize;
public Guid classGuid;
public uint devInst;
public nint reserved;
public SP_DEVINFO_DATA()
{
cbSize = (uint)Marshal.SizeOf(typeof(SP_DEVINFO_DATA));
}
}
public static Guid GUID_CLASS_MONITOR = new Guid(0x4d36e96e, 0xe325, 0x11ce, 0xbf, 0xc1, 0x08, 0x00, 0x2b, 0xe1, 0x03, 0x18);
const int MAX_DEVICE_ID_LEN = 200;
public const int MAX_PATH = 260;
public const int DIGCF_PRESENT = 0x2;
public const int DIGCF_PROFILE = 0x8;
public const int DICS_FLAG_GLOBAL = 0x1;
public const int DIREG_DEV = 0x1;
public const int KEY_READ = 0x20019;
const int NAME_SIZE = 128;
const uint ERROR_SUCCESS = 0;
[DllImport(DLL)]
public static extern nint SetupDiGetClassDevsEx(ref Guid ClassGuid,
[MarshalAs(UnmanagedType.LPStr)] string enumerator,
nint hwndParent, int Flags, nint DeviceInfoSet,
[MarshalAs(UnmanagedType.LPStr)] string MachineName, nint Reserved);
[DllImport(DLL, SetLastError = true)]
public static extern bool SetupDiEnumDeviceInfo(nint DeviceInfoSet, uint MemberIndex, ref SP_DEVINFO_DATA DeviceInfoData);
[DllImport(DLL, SetLastError = true)]
public static extern bool SetupDiDestroyDeviceInfoList
(
nint DeviceInfoSet
);
[DllImport(DLL, CharSet = CharSet.Auto, SetLastError = true)]
public static extern nint SetupDiOpenDevRegKey(
nint hDeviceInfoSet,
ref SP_DEVINFO_DATA deviceInfoData,
int scope,
int hwProfile,
int parameterRegistryValueKind,
int samDesired);
}