mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-10-05 15:49:01 +00:00
Common: Move GetDeviceProperty() into its own header
Otherwise we include Windows headers in the entire codebase through CommonFuncs.h
This commit is contained in:
parent
5cc0a5a3be
commit
68713e08b4
8 changed files with 77 additions and 34 deletions
|
@ -92,28 +92,5 @@ std::optional<std::wstring> GetModuleName(void* hInstance)
|
|||
name.resize(size);
|
||||
return name;
|
||||
}
|
||||
|
||||
std::wstring GetDeviceProperty(const HDEVINFO& device_info, const PSP_DEVINFO_DATA device_data,
|
||||
const DEVPROPKEY* requested_property)
|
||||
{
|
||||
DWORD required_size = 0;
|
||||
DEVPROPTYPE device_property_type;
|
||||
BOOL result;
|
||||
|
||||
result = SetupDiGetDeviceProperty(device_info, device_data, requested_property,
|
||||
&device_property_type, nullptr, 0, &required_size, 0);
|
||||
if (!result && GetLastError() != ERROR_INSUFFICIENT_BUFFER)
|
||||
return std::wstring();
|
||||
|
||||
std::vector<TCHAR> unicode_buffer(required_size / sizeof(TCHAR));
|
||||
|
||||
result = SetupDiGetDeviceProperty(
|
||||
device_info, device_data, requested_property, &device_property_type,
|
||||
reinterpret_cast<PBYTE>(unicode_buffer.data()), required_size, nullptr, 0);
|
||||
if (!result)
|
||||
return std::wstring();
|
||||
|
||||
return std::wstring(unicode_buffer.data());
|
||||
}
|
||||
#endif
|
||||
} // namespace Common
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue