Skip to content

Commit f90d42a

Browse files
committed
Merge pull request #96 devpropdef.h
2 parents a138cb4 + 8495834 commit f90d42a

11 files changed

+531
-4
lines changed

TH-NETII Windows API.sln

+15
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "THNETII.WinApi.Constants.SC
9191
EndProject
9292
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "THNETII.WinApi.Headers.WinSCard", "src\THNETII.WinApi.Headers.WinSCard\THNETII.WinApi.Headers.WinSCard.csproj", "{56348771-2C99-4C0A-B63A-C7F0736621DA}"
9393
EndProject
94+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "THNETII.WinApi.Headers.DevPropDef", "src\THNETII.WinApi.Headers.DevPropDef\THNETII.WinApi.Headers.DevPropDef.csproj", "{E4A4DA91-3696-40A6-9834-E5FAACEF682E}"
95+
EndProject
9496
Global
9597
GlobalSection(SolutionConfigurationPlatforms) = preSolution
9698
Debug|Any CPU = Debug|Any CPU
@@ -473,6 +475,18 @@ Global
473475
{56348771-2C99-4C0A-B63A-C7F0736621DA}.Release|x64.Build.0 = Release|Any CPU
474476
{56348771-2C99-4C0A-B63A-C7F0736621DA}.Release|x86.ActiveCfg = Release|Any CPU
475477
{56348771-2C99-4C0A-B63A-C7F0736621DA}.Release|x86.Build.0 = Release|Any CPU
478+
{E4A4DA91-3696-40A6-9834-E5FAACEF682E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
479+
{E4A4DA91-3696-40A6-9834-E5FAACEF682E}.Debug|Any CPU.Build.0 = Debug|Any CPU
480+
{E4A4DA91-3696-40A6-9834-E5FAACEF682E}.Debug|x64.ActiveCfg = Debug|Any CPU
481+
{E4A4DA91-3696-40A6-9834-E5FAACEF682E}.Debug|x64.Build.0 = Debug|Any CPU
482+
{E4A4DA91-3696-40A6-9834-E5FAACEF682E}.Debug|x86.ActiveCfg = Debug|Any CPU
483+
{E4A4DA91-3696-40A6-9834-E5FAACEF682E}.Debug|x86.Build.0 = Debug|Any CPU
484+
{E4A4DA91-3696-40A6-9834-E5FAACEF682E}.Release|Any CPU.ActiveCfg = Release|Any CPU
485+
{E4A4DA91-3696-40A6-9834-E5FAACEF682E}.Release|Any CPU.Build.0 = Release|Any CPU
486+
{E4A4DA91-3696-40A6-9834-E5FAACEF682E}.Release|x64.ActiveCfg = Release|Any CPU
487+
{E4A4DA91-3696-40A6-9834-E5FAACEF682E}.Release|x64.Build.0 = Release|Any CPU
488+
{E4A4DA91-3696-40A6-9834-E5FAACEF682E}.Release|x86.ActiveCfg = Release|Any CPU
489+
{E4A4DA91-3696-40A6-9834-E5FAACEF682E}.Release|x86.Build.0 = Release|Any CPU
476490
EndGlobalSection
477491
GlobalSection(SolutionProperties) = preSolution
478492
HideSolutionNode = FALSE
@@ -510,6 +524,7 @@ Global
510524
{35C252B4-AD97-4E09-8097-72FDCA04EBF7} = {9689DB3E-1ED7-478C-AC14-C734B0397619}
511525
{25A891EB-9BF0-45D1-89EE-B24E80DE259E} = {9689DB3E-1ED7-478C-AC14-C734B0397619}
512526
{56348771-2C99-4C0A-B63A-C7F0736621DA} = {9689DB3E-1ED7-478C-AC14-C734B0397619}
527+
{E4A4DA91-3696-40A6-9834-E5FAACEF682E} = {9689DB3E-1ED7-478C-AC14-C734B0397619}
513528
EndGlobalSection
514529
GlobalSection(ExtensibilityGlobals) = postSolution
515530
SolutionGuid = {6EF7C9CF-E403-4B60-AB44-5F9FFEB668B7}
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
#include <WinSCard.h>
1+
#include <Windows.h>
2+
#include <devpropdef.h>
23

34
int main(int argc, char* argv[])
45
{
5-
SCARD_READERSTATE instance;
6+
DEVPROPTYPE instance;
67
const int size = sizeof(instance);
7-
const int value = SCARD_ABSENT;
8+
const int value = DEVPROP_TYPE_EMPTY;
89

9-
const void* ptr = SCardGetReaderDeviceInstanceId;
10+
const void* ptr = NULL;
1011

1112
return EXIT_SUCCESS;
1213
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
using System;
2+
using System.Runtime.InteropServices;
3+
4+
namespace THNETII.WinApi.Native.DevPropDef
5+
{
6+
using static DevPropDefMacros;
7+
8+
// C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\shared\devpropdef.h, line 143
9+
//
10+
// DEVPROPCOMPKEY structure
11+
/// <summary>
12+
/// This structure represents a compound key for a property.
13+
/// </summary>
14+
[StructLayout(LayoutKind.Sequential)]
15+
public struct DEVPROPCOMPKEY : IEquatable<DEVPROPCOMPKEY>
16+
{
17+
/// <summary>
18+
/// A <see cref="DEVPROPKEY"/> structure that represents a key for a property.
19+
/// </summary>
20+
public DEVPROPKEY Key;
21+
/// <summary>
22+
/// A <see cref="DEVPROPSTORE"/>-typed value that indicates the property store.
23+
/// </summary>
24+
public DEVPROPSTORE Store;
25+
/// <summary>
26+
/// A string for the property's locale name.
27+
/// </summary>
28+
public LPCWSTR LocaleName;
29+
30+
public override bool Equals(object obj) => obj switch
31+
{
32+
DEVPROPCOMPKEY key => this == key,
33+
null => false,
34+
_ => false,
35+
};
36+
37+
public override int GetHashCode() =>
38+
#if NETCOREAPP
39+
HashCode.Combine(Key, Store, LocaleName.Pointer);
40+
#else
41+
Key.GetHashCode() ^ Store.GetHashCode() ^ LocaleName.Pointer.GetHashCode();
42+
#endif
43+
44+
public static bool operator ==(in DEVPROPCOMPKEY left, in DEVPROPCOMPKEY right) =>
45+
IsEqualDevPropCompKey(left, right);
46+
47+
public static bool operator !=(DEVPROPCOMPKEY left, DEVPROPCOMPKEY right)
48+
=> !(left == right);
49+
50+
/// <inheritdoc cref="IEquatable{DEVPROPCOMPKEY}.Equals(DEVPROPCOMPKEY)"/>
51+
public readonly bool Equals(in DEVPROPCOMPKEY other) => this == other;
52+
53+
bool IEquatable<DEVPROPCOMPKEY>.Equals(DEVPROPCOMPKEY other) =>
54+
Equals(in other);
55+
}
56+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
using System;
2+
using System.Runtime.InteropServices;
3+
4+
namespace THNETII.WinApi.Native.DevPropDef
5+
{
6+
// C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\shared\devpropdef.h, line 175
7+
//
8+
// DEVPROPERTY structure
9+
/// <summary>
10+
/// Describes a property for a software device.
11+
/// </summary>
12+
[StructLayout(LayoutKind.Sequential)]
13+
public struct DEVPROPERTY
14+
{
15+
/// <summary>
16+
/// A <see cref="DEVPROPCOMPKEY"/> structure that represents a compound key for a property.
17+
/// </summary>
18+
public DEVPROPCOMPKEY CompKey;
19+
/// <summary>
20+
/// A <see cref="DEVPROPTYPE"/> value that indicates the property type. Valid <see cref="DEVPROPTYPE"/> values are constructed from base <strong>DEVPROP_TYPE_</strong> values, which may be modified by a logical OR with <strong>DEVPROP_TYPEMOD_</strong> values, as appropriate.
21+
/// </summary>
22+
public DEVPROPTYPE Type;
23+
/// <summary>
24+
/// The size in bytes of the property in <see cref="Buffer"/>.
25+
/// </summary>
26+
public int BufferSize;
27+
internal IntPtr BufferPointer;
28+
/// <summary>
29+
/// The buffer that contains the property info.
30+
/// </summary>
31+
public unsafe Span<byte> Buffer
32+
{
33+
get => new Span<byte>(BufferPointer.ToPointer(), BufferSize);
34+
set
35+
{
36+
fixed (byte* pValue = value)
37+
(BufferPointer, BufferSize) = ((IntPtr)pValue, value.Length);
38+
}
39+
}
40+
}
41+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
using System;
2+
using System.Runtime.InteropServices;
3+
4+
namespace THNETII.WinApi.Native.DevPropDef
5+
{
6+
using static DevPropDefMacros;
7+
8+
// C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\shared\devpropdef.h, line 107
9+
/// <summary>
10+
/// In Windows Vista and later versions of Windows, the <see cref="DEVPROPKEY"/> structure represents a device property key for a device property in the <a href="https://docs.microsoft.com/windows-hardware/drivers/install/unified-device-property-model--windows-vista-and-later-">unified device property model</a>.
11+
/// </summary>
12+
/// <remarks>
13+
/// <para>The <see cref="DEVPROPKEY"/> structure is part of the <a href="https://docs.microsoft.com/windows-hardware/drivers/install/unified-device-property-model--windows-vista-and-later-">unified device property model</a>.</para>
14+
/// <para>Microsoft Docs page: <a href="https://docs.microsoft.com/en-us/windows-hardware/drivers/install/devpropkey">DEVPROPKEY structure</a></para>
15+
/// </remarks>
16+
[StructLayout(LayoutKind.Sequential)]
17+
public struct DEVPROPKEY : IEquatable<DEVPROPKEY>
18+
{
19+
/// <summary>
20+
/// A <see cref="Guid"/> value that specifies a property category.
21+
/// </summary>
22+
public Guid fmtid;
23+
/// <summary>
24+
/// A value that uniquely identifies the property within the property category. For internal system reasons, a property identifier must be greater than or equal to two.
25+
/// </summary>
26+
public uint pid;
27+
28+
public override bool Equals(object obj) => obj switch
29+
{
30+
DEVPROPKEY otherKey => Equals(in otherKey),
31+
null => false,
32+
_ => false,
33+
};
34+
35+
public override int GetHashCode() =>
36+
#if NETCOREAPP
37+
HashCode.Combine(fmtid, pid);
38+
#else
39+
fmtid.GetHashCode() ^ pid.GetHashCode();
40+
#endif
41+
42+
public static bool operator ==(in DEVPROPKEY left, in DEVPROPKEY right) =>
43+
IsEqualDevPropKey(left, right);
44+
45+
public static bool operator !=(in DEVPROPKEY left, in DEVPROPKEY right) =>
46+
!(left == right);
47+
48+
/// <inheritdoc cref="IEquatable{DEVPROPKEY}.Equals(DEVPROPKEY)"/>
49+
public readonly bool Equals(in DEVPROPKEY other) => this == other;
50+
51+
bool IEquatable<DEVPROPKEY>.Equals(DEVPROPKEY other) =>
52+
Equals(in other);
53+
}
54+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
namespace THNETII.WinApi.Native.DevPropDef
2+
{
3+
// C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\shared\devpropdef.h, line 128
4+
//
5+
// DEVPROPSTORE Enumeration
6+
/// <summary>
7+
/// This enumeration describes where a property is stored.
8+
/// </summary>
9+
public enum DEVPROPSTORE
10+
{
11+
DEVPROP_STORE_SYSTEM,
12+
DEVPROP_STORE_USER
13+
}
14+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
1+
using System;
2+
3+
namespace THNETII.WinApi.Native.DevPropDef
4+
{
5+
// C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\shared\devpropdef.h, line 28
6+
/// <summary>
7+
/// Type definition for property data types. Valid <see cref="DEVPROPTYPE"/> values are
8+
/// constructed from base <strong>DEVPROP_TYPE_</strong> values, which may be modified by a
9+
/// logical OR with <strong>DEVPROP_TYPEMOD_</strong> values, as appropriate.
10+
/// </summary>
11+
[Flags]
12+
public enum DEVPROPTYPE : uint
13+
{
14+
/// <summary>
15+
/// array of fixed-sized data elements
16+
/// <para>
17+
/// Property type modifiers. Used to modify base <strong>DEVPROP_TYPE_</strong> values, as
18+
/// appropriate. Not valid as standalone <see cref="DEVPROPTYPE"/> values.
19+
/// </para>
20+
/// </summary>
21+
DEVPROP_TYPEMOD_ARRAY = DevPropDefConstants.DEVPROP_TYPEMOD_ARRAY,
22+
/// <summary>
23+
/// list of variable-sized data elements
24+
/// <para>
25+
/// Property type modifiers. Used to modify base <strong>DEVPROP_TYPE_</strong> values, as
26+
/// appropriate. Not valid as standalone <see cref="DEVPROPTYPE"/> values.
27+
/// </para>
28+
/// </summary>
29+
DEVPROP_TYPEMOD_LIST = DevPropDefConstants.DEVPROP_TYPEMOD_LIST,
30+
31+
//
32+
// Property data types.
33+
//
34+
/// <summary>
35+
/// nothing, no property data
36+
/// </summary>
37+
DEVPROP_TYPE_EMPTY = DevPropDefConstants.DEVPROP_TYPE_EMPTY,
38+
/// <summary>
39+
/// null property data
40+
/// </summary>
41+
DEVPROP_TYPE_NULL = DevPropDefConstants.DEVPROP_TYPE_NULL,
42+
/// <summary>
43+
/// 8-bit signed int (SBYTE)
44+
/// </summary>
45+
DEVPROP_TYPE_SBYTE = DevPropDefConstants.DEVPROP_TYPE_SBYTE,
46+
/// <summary>
47+
/// 8-bit unsigned int (BYTE)
48+
/// </summary>
49+
DEVPROP_TYPE_BYTE = DevPropDefConstants.DEVPROP_TYPE_BYTE,
50+
/// <summary>
51+
/// 16-bit signed int (SHORT)
52+
/// </summary>
53+
DEVPROP_TYPE_INT16 = DevPropDefConstants.DEVPROP_TYPE_INT16,
54+
/// <summary>
55+
/// 16-bit unsigned int (USHORT)
56+
/// </summary>
57+
DEVPROP_TYPE_UINT16 = DevPropDefConstants.DEVPROP_TYPE_UINT16,
58+
/// <summary>
59+
/// 32-bit signed int (LONG)
60+
/// </summary>
61+
DEVPROP_TYPE_INT32 = DevPropDefConstants.DEVPROP_TYPE_INT32,
62+
/// <summary>
63+
/// 32-bit unsigned int (ULONG)
64+
/// </summary>
65+
DEVPROP_TYPE_UINT32 = DevPropDefConstants.DEVPROP_TYPE_UINT32,
66+
/// <summary>
67+
/// 64-bit signed int (LONG64)
68+
/// </summary>
69+
DEVPROP_TYPE_INT64 = DevPropDefConstants.DEVPROP_TYPE_INT64,
70+
/// <summary>
71+
/// 64-bit unsigned int (ULONG64)
72+
/// </summary>
73+
DEVPROP_TYPE_UINT64 = DevPropDefConstants.DEVPROP_TYPE_UINT64,
74+
/// <summary>
75+
/// 32-bit floating-point (FLOAT)
76+
/// </summary>
77+
DEVPROP_TYPE_FLOAT = DevPropDefConstants.DEVPROP_TYPE_FLOAT,
78+
/// <summary>
79+
/// 64-bit floating-point (DOUBLE)
80+
/// </summary>
81+
DEVPROP_TYPE_DOUBLE = DevPropDefConstants.DEVPROP_TYPE_DOUBLE,
82+
/// <summary>
83+
/// 128-bit data (DECIMAL)
84+
/// </summary>
85+
DEVPROP_TYPE_DECIMAL = DevPropDefConstants.DEVPROP_TYPE_DECIMAL,
86+
/// <summary>
87+
/// 128-bit unique identifier (GUID)
88+
/// </summary>
89+
DEVPROP_TYPE_GUID = DevPropDefConstants.DEVPROP_TYPE_GUID,
90+
/// <summary>
91+
/// 64 bit signed int currency value (CURRENCY)
92+
/// </summary>
93+
DEVPROP_TYPE_CURRENCY = DevPropDefConstants.DEVPROP_TYPE_CURRENCY,
94+
/// <summary>
95+
/// date (DATE)
96+
/// </summary>
97+
DEVPROP_TYPE_DATE = DevPropDefConstants.DEVPROP_TYPE_DATE,
98+
/// <summary>
99+
/// file time (FILETIME)
100+
/// </summary>
101+
DEVPROP_TYPE_FILETIME = DevPropDefConstants.DEVPROP_TYPE_FILETIME,
102+
/// <summary>
103+
/// 8-bit boolean (DEVPROP_BOOLEAN)
104+
/// </summary>
105+
DEVPROP_TYPE_BOOLEAN = DevPropDefConstants.DEVPROP_TYPE_BOOLEAN,
106+
/// <summary>
107+
/// null-terminated string
108+
/// </summary>
109+
DEVPROP_TYPE_STRING = DevPropDefConstants.DEVPROP_TYPE_STRING,
110+
/// <summary>
111+
/// multi-sz string list
112+
/// </summary>
113+
DEVPROP_TYPE_STRING_LIST = DevPropDefConstants.DEVPROP_TYPE_STRING_LIST,
114+
/// <summary>
115+
/// self-relative binary SECURITY_DESCRIPTOR
116+
/// </summary>
117+
DEVPROP_TYPE_SECURITY_DESCRIPTOR = DevPropDefConstants.DEVPROP_TYPE_SECURITY_DESCRIPTOR,
118+
/// <summary>
119+
/// security descriptor string (SDDL format)
120+
/// </summary>
121+
DEVPROP_TYPE_SECURITY_DESCRIPTOR_STRING = DevPropDefConstants.DEVPROP_TYPE_SECURITY_DESCRIPTOR_STRING,
122+
/// <summary>
123+
/// device property key (DEVPROPKEY)
124+
/// </summary>
125+
DEVPROP_TYPE_DEVPROPKEY = DevPropDefConstants.DEVPROP_TYPE_DEVPROPKEY,
126+
/// <summary>
127+
/// device property type (DEVPROPTYPE)
128+
/// </summary>
129+
DEVPROP_TYPE_DEVPROPTYPE = DevPropDefConstants.DEVPROP_TYPE_DEVPROPTYPE,
130+
/// <summary>
131+
/// custom binary data
132+
/// </summary>
133+
DEVPROP_TYPE_BINARY = DevPropDefConstants.DEVPROP_TYPE_BINARY,
134+
/// <summary>
135+
/// 32-bit Win32 system error code
136+
/// </summary>
137+
DEVPROP_TYPE_ERROR = DevPropDefConstants.DEVPROP_TYPE_ERROR,
138+
/// <summary>
139+
/// 32-bit NTSTATUS code
140+
/// </summary>
141+
DEVPROP_TYPE_NTSTATUS = DevPropDefConstants.DEVPROP_TYPE_NTSTATUS,
142+
/// <summary>
143+
/// string resource (@[path\]&lt;dllname&gt;,-&lt;strId&gt;)
144+
/// </summary>
145+
DEVPROP_TYPE_STRING_INDIRECT = DevPropDefConstants.DEVPROP_TYPE_STRING_INDIRECT,
146+
147+
//
148+
// Max base DEVPROP_TYPE_ and DEVPROP_TYPEMOD_ values.
149+
//
150+
/// <summary>
151+
/// max valid DEVPROP_TYPE_ value
152+
/// </summary>
153+
MAX_DEVPROP_TYPE = DevPropDefConstants.MAX_DEVPROP_TYPE,
154+
/// <summary>
155+
/// max valid DEVPROP_TYPEMOD_ value
156+
/// </summary>
157+
MAX_DEVPROP_TYPEMOD = DevPropDefConstants.MAX_DEVPROP_TYPEMOD,
158+
159+
//
160+
// Bitmasks for extracting DEVPROP_TYPE_ and DEVPROP_TYPEMOD_ values.
161+
//
162+
/// <summary>
163+
/// range for base DEVPROP_TYPE_ values
164+
/// </summary>
165+
DEVPROP_MASK_TYPE = DevPropDefConstants.DEVPROP_MASK_TYPE,
166+
/// <summary>
167+
/// mask for DEVPROP_TYPEMOD_ type modifiers
168+
/// </summary>
169+
DEVPROP_MASK_TYPEMOD = DevPropDefConstants.DEVPROP_MASK_TYPEMOD,
170+
}
171+
}

0 commit comments

Comments
 (0)