|
|
|
@@ -1,10 +1,8 @@
|
|
|
|
|
#include "ScreenManager.h"
|
|
|
|
|
#include <Windows.h>
|
|
|
|
|
#include "spdlog/spdlog.h"
|
|
|
|
|
#include "spdlog/sinks/basic_file_sink.h"
|
|
|
|
|
#include "spdlog/sinks/stdout_color_sinks.h"
|
|
|
|
|
#include "Utils/StringUtil.h"
|
|
|
|
|
#include "Utils/Log.h"
|
|
|
|
|
#include <dxgi.h>
|
|
|
|
|
|
|
|
|
|
ScreenManager::ScreenManager()
|
|
|
|
|
{
|
|
|
|
@@ -43,43 +41,43 @@ void ScreenManager::_UpdateDisplayDeviceList()
|
|
|
|
|
|
|
|
|
|
void ScreenManager::_UpdateDisplayAdapterList()
|
|
|
|
|
{
|
|
|
|
|
LOG_FUNC_START();
|
|
|
|
|
HRESULT hr = S_OK;
|
|
|
|
|
IDXGIFactory* pFactory = nullptr;
|
|
|
|
|
hr = CreateDXGIFactory(__uuidof(IDXGIFactory), (void**)(&pFactory));
|
|
|
|
|
if (FAILED(hr)) {
|
|
|
|
|
spdlog::error("CreateDXGIFactory failed");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
LOG_FUNC_START();
|
|
|
|
|
HRESULT hr = S_OK;
|
|
|
|
|
IDXGIFactory* pFactory = nullptr;
|
|
|
|
|
hr = CreateDXGIFactory(__uuidof(IDXGIFactory), (void**)(&pFactory));
|
|
|
|
|
if (FAILED(hr)) {
|
|
|
|
|
spdlog::error("CreateDXGIFactory failed");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
IDXGIAdapter* pAdapter = nullptr;
|
|
|
|
|
for (UINT adapterIndex = 0; pFactory->EnumAdapters(adapterIndex, &pAdapter) != DXGI_ERROR_NOT_FOUND; ++adapterIndex)
|
|
|
|
|
{
|
|
|
|
|
DXGI_ADAPTER_DESC adapterDesc;
|
|
|
|
|
pAdapter->GetDesc(&adapterDesc);
|
|
|
|
|
spdlog::info("Adapter Index:{0}, Description:{1}, DeviceId:{2}, VendorId:{3}, SubSysId:{4}, Revision:{5}, AdapterLuid(H-L):{6}-{7} ",
|
|
|
|
|
adapterIndex, Wchar2String(adapterDesc.Description), adapterDesc.DeviceId, adapterDesc.VendorId, adapterDesc.SubSysId,
|
|
|
|
|
adapterDesc.Revision, adapterDesc.AdapterLuid.HighPart, adapterDesc.AdapterLuid.LowPart);
|
|
|
|
|
IDXGIAdapter* pAdapter = nullptr;
|
|
|
|
|
for (UINT adapterIndex = 0; pFactory->EnumAdapters(adapterIndex, &pAdapter) != DXGI_ERROR_NOT_FOUND; ++adapterIndex)
|
|
|
|
|
{
|
|
|
|
|
DXGI_ADAPTER_DESC adapterDesc;
|
|
|
|
|
pAdapter->GetDesc(&adapterDesc);
|
|
|
|
|
spdlog::info("Adapter Index:{0}, Description:{1}, DeviceId:{2}, VendorId:{3}, SubSysId:{4}, Revision:{5}, AdapterLuid(H-L):{6}-{7} ",
|
|
|
|
|
adapterIndex, Wchar2String(adapterDesc.Description), adapterDesc.DeviceId, adapterDesc.VendorId, adapterDesc.SubSysId,
|
|
|
|
|
adapterDesc.Revision, adapterDesc.AdapterLuid.HighPart, adapterDesc.AdapterLuid.LowPart);
|
|
|
|
|
|
|
|
|
|
// print adapter output info
|
|
|
|
|
IDXGIOutput* pOutput;
|
|
|
|
|
int outputCount = 0;
|
|
|
|
|
for (UINT j = 0; pAdapter->EnumOutputs(j, &pOutput) != DXGI_ERROR_NOT_FOUND; ++j) {
|
|
|
|
|
DXGI_OUTPUT_DESC outputDesc;
|
|
|
|
|
pOutput->GetDesc(&outputDesc);
|
|
|
|
|
// print adapter output info
|
|
|
|
|
IDXGIOutput* pOutput;
|
|
|
|
|
int outputCount = 0;
|
|
|
|
|
for (UINT j = 0; pAdapter->EnumOutputs(j, &pOutput) != DXGI_ERROR_NOT_FOUND; ++j) {
|
|
|
|
|
DXGI_OUTPUT_DESC outputDesc;
|
|
|
|
|
pOutput->GetDesc(&outputDesc);
|
|
|
|
|
|
|
|
|
|
MONITORINFOEX monitorInfo;
|
|
|
|
|
monitorInfo.cbSize = sizeof(MONITORINFOEX);
|
|
|
|
|
if (GetMonitorInfo(outputDesc.Monitor, &monitorInfo))
|
|
|
|
|
{
|
|
|
|
|
// 输出友好名称
|
|
|
|
|
spdlog::info("Adapter Output Index:{0}, DeviceName:{1}, szDevice:{2}, right:{3}, bottom:{4}",
|
|
|
|
|
j, Wchar2String(outputDesc.DeviceName), monitorInfo.szDevice, monitorInfo.rcMonitor.right, monitorInfo.rcMonitor.bottom);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
pFactory->Release();
|
|
|
|
|
LOG_FUNC_END();
|
|
|
|
|
MONITORINFOEX monitorInfo;
|
|
|
|
|
monitorInfo.cbSize = sizeof(MONITORINFOEX);
|
|
|
|
|
if (GetMonitorInfo(outputDesc.Monitor, &monitorInfo))
|
|
|
|
|
{
|
|
|
|
|
// 输出友好名称
|
|
|
|
|
spdlog::info("Adapter Output Index:{0}, DeviceName:{1}, szDevice:{2}, right:{3}, bottom:{4}",
|
|
|
|
|
j, Wchar2String(outputDesc.DeviceName), monitorInfo.szDevice, monitorInfo.rcMonitor.right, monitorInfo.rcMonitor.bottom);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
pFactory->Release();
|
|
|
|
|
LOG_FUNC_END();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BOOL ScreenManager::_EnumMonitorProc(HMONITOR hMonitor)
|
|
|
|
|