impr: Make Win32 API properly use unicode support

This commit is contained in:
WerWolv
2024-06-28 11:12:17 +02:00
parent b642c493d7
commit 91f6aae9ef
9 changed files with 26 additions and 25 deletions

View File

@@ -381,8 +381,8 @@ namespace hex::plugin::builtin {
m_availableDrives.clear();
std::array<TCHAR, MAX_DEVICE_ID_LEN> deviceInstanceID = {};
std::array<TCHAR, 1024> description = {};
std::array<WCHAR, MAX_DEVICE_ID_LEN> deviceInstanceId = {};
std::array<WCHAR, 1024> description = {};
const GUID hddClass = GUID_DEVINTERFACE_DISK;
@@ -404,7 +404,7 @@ namespace hex::plugin::builtin {
if (!SetupDiEnumInterfaceDevice(hDevInfo, nullptr, &hddClass, i, &interfaceData))
break;
if (CM_Get_Device_ID(deviceInfoData.DevInst, deviceInstanceID.data(), MAX_PATH, 0) != CR_SUCCESS)
if (CM_Get_Device_IDW(deviceInfoData.DevInst, deviceInstanceId.data(), MAX_PATH, 0) != CR_SUCCESS)
continue;
// Get the required size of the device path
@@ -419,19 +419,19 @@ namespace hex::plugin::builtin {
if (!SetupDiGetDeviceInterfaceDetail(hDevInfo, &interfaceData, data, requiredSize, nullptr, nullptr))
continue;
auto path = data->DevicePath;
auto path = reinterpret_cast<const WCHAR*>(data->DevicePath);
// Query the friendly name of the device
DWORD size = 0;
DWORD propertyRegDataType = SPDRP_PHYSICAL_DEVICE_OBJECT_NAME;
SetupDiGetDeviceRegistryProperty(hDevInfo, &deviceInfoData, SPDRP_FRIENDLYNAME,
SetupDiGetDeviceRegistryPropertyW(hDevInfo, &deviceInfoData, SPDRP_FRIENDLYNAME,
&propertyRegDataType, reinterpret_cast<BYTE*>(description.data()),
sizeof(description),
&size);
auto friendlyName = description.data();
m_availableDrives.insert({ path, friendlyName });
m_availableDrives.insert({ utf16ToUtf8(path), utf16ToUtf8(friendlyName) });
}
// Add all logical drives