Skip to content

Commit fea4d9e

Browse files
Adapter selection: use explicit DEVPKEY_Device_Luid definition
1 parent 13d3827 commit fea4d9e

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

Common/Include/AdapterOption.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include <algorithm> // For sort
66
#include <setupapi.h>
77
#include <devguid.h>
8+
#include <devpropdef.h>
89
#include <devpkey.h>
910
#include <cstdint>
1011
#include <optional>
@@ -15,6 +16,13 @@
1516
using namespace std;
1617
using namespace Microsoft::WRL;
1718

19+
// DEVPKEY_Device_Luid: {60b193cb-5276-4d0f-96fc-f173ab17af69}, 2
20+
// Define it ourselves to avoid SDK/WDK header differences where DEVPKEY_Device_Luid may not be declared.
21+
static const DEVPROPKEY DEVPKEY_Device_Luid_Custom = {
22+
{ 0x60b193cb, 0x5276, 0x4d0f, { 0x96, 0xfc, 0xf1, 0x73, 0xab, 0xad, 0x3e, 0xc6 } },
23+
2
24+
};
25+
1826
// Structure to vector gpus
1927
struct GPUInfo {
2028
wstring name; // GPU name
@@ -95,7 +103,7 @@ inline std::optional<LUID> ResolveAdapterLuidFromPciBus(uint32_t targetBusIndex)
95103
if (!SetupDiGetDevicePropertyW(
96104
devInfo,
97105
&devData,
98-
&DEVPKEY_Device_Luid,
106+
&DEVPKEY_Device_Luid_Custom,
99107
&propType,
100108
reinterpret_cast<PBYTE>(&luid64),
101109
sizeof(luid64),

0 commit comments

Comments
 (0)