Compare commits
6 Commits
2ea026f7be
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 29c109aeee | |||
| 2e4e55b4d3 | |||
| 53b1a99d3c | |||
| 91b7ea9e26 | |||
| ef9faa08c7 | |||
| 5c00047718 |
3
.gitignore
vendored
3
.gitignore
vendored
@@ -2,3 +2,6 @@
|
||||
/.vs
|
||||
/Debug
|
||||
/*/Debug
|
||||
/Release
|
||||
/*/Release
|
||||
x64/
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 16
|
||||
VisualStudioVersion = 16.0.32802.440
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.8.34322.80
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "WinDevice", "WinDevice\WinDevice.vcxproj", "{FC07175F-EC7A-4CE5-9F7F-976DC6AED04D}"
|
||||
EndProject
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
enum AudioDeviceType
|
||||
enum WINDEVICE_API AudioDeviceType
|
||||
{
|
||||
Render,
|
||||
Capture
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
#include <Mmdeviceapi.h>
|
||||
|
||||
class AudioManager
|
||||
class WINDEVICE_API AudioManager
|
||||
{
|
||||
public:
|
||||
AudioManager();
|
||||
|
||||
50
WinDevice/Device/UserDeviceInfo.h
Normal file
50
WinDevice/Device/UserDeviceInfo.h
Normal file
@@ -0,0 +1,50 @@
|
||||
#pragma once
|
||||
#include "stdafx.h"
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
|
||||
namespace WinDevice {
|
||||
struct WINDEVICE_API OsInfo {
|
||||
// 操作系统名称
|
||||
std::string name;
|
||||
unsigned long majorVersion;
|
||||
unsigned long minorVersion;
|
||||
unsigned long buildNumber;
|
||||
// 总内存大小(以字节为单位)
|
||||
int64_t totalMemory;
|
||||
};
|
||||
|
||||
struct WINDEVICE_API CpuInfo {
|
||||
std::string name;
|
||||
int coreCout;
|
||||
};
|
||||
|
||||
struct WINDEVICE_API GpuInfo {
|
||||
std::string name;
|
||||
/**
|
||||
* \brief 厂商Id
|
||||
*
|
||||
* 可能的值:
|
||||
* - NVIDIA:0x10DE
|
||||
* - Intel :0x8086
|
||||
* - AMD :0x1002
|
||||
*/
|
||||
uint32_t vendorId;
|
||||
uint32_t deviceId;
|
||||
size_t vram;
|
||||
};
|
||||
|
||||
struct WINDEVICE_API DisplayMonitorInfo {
|
||||
std::shared_ptr<HMONITOR> monitor;
|
||||
std::string name;
|
||||
long width;
|
||||
long height;
|
||||
};
|
||||
|
||||
struct WINDEVICE_API UserDeviceInfo {
|
||||
std::shared_ptr<CpuInfo> cpu;
|
||||
std::shared_ptr<OsInfo> os;
|
||||
std::shared_ptr<std::vector<GpuInfo>> gpu;
|
||||
std::shared_ptr<std::vector<DisplayMonitorInfo>> monitor;
|
||||
};
|
||||
}
|
||||
230
WinDevice/Device/WinDeviceManager.cpp
Normal file
230
WinDevice/Device/WinDeviceManager.cpp
Normal file
@@ -0,0 +1,230 @@
|
||||
#include "WinDeviceManager.h"
|
||||
#include "stdafx.h"
|
||||
#include <ddraw.h>
|
||||
#include "../Utils/StringUtil.h"
|
||||
|
||||
namespace WinDevice
|
||||
{
|
||||
WinDeviceManager::WinDeviceManager()
|
||||
{
|
||||
}
|
||||
|
||||
WinDeviceManager::~WinDeviceManager()
|
||||
{
|
||||
}
|
||||
|
||||
void WinDeviceManager::_UpdateCpuInfo()
|
||||
{
|
||||
SYSTEM_INFO sysInfo;
|
||||
GetSystemInfo(&sysInfo);
|
||||
|
||||
// 获取CPU信息
|
||||
int cpuInfo[4] = {-1};
|
||||
__cpuid(cpuInfo, 0);
|
||||
unsigned int maxCpuId = cpuInfo[0];
|
||||
|
||||
char cpuBrandString[0x40];
|
||||
memset(cpuBrandString, 0, sizeof(cpuBrandString));
|
||||
|
||||
for (unsigned int i = 0x80000002; i <= 0x80000004; ++i)
|
||||
{
|
||||
__cpuid(cpuInfo, i);
|
||||
memcpy(cpuBrandString + (i - 0x80000002) * 16, cpuInfo, sizeof(cpuInfo));
|
||||
}
|
||||
if (!this->cpuInfo)
|
||||
{
|
||||
this->cpuInfo = std::make_shared<CpuInfo>(*this->cpuInfo);
|
||||
}
|
||||
this->cpuInfo->name = std::string(cpuBrandString);
|
||||
this->cpuInfo->coreCout = sysInfo.dwNumberOfProcessors;
|
||||
}
|
||||
|
||||
UserDeviceInfo WinDeviceManager::GetUserDeviceInfo()
|
||||
{
|
||||
UserDeviceInfo userInfo;
|
||||
|
||||
_UpdateOperatingSystemInfo();
|
||||
_UpdateCpuInfo();
|
||||
_UpdateGpuInfo();
|
||||
// 每次获取主要是因为显示器可能发生变化
|
||||
_UpdateMonitorInfo();
|
||||
|
||||
userInfo.os = std::make_shared<OsInfo>(*osInfo);
|
||||
userInfo.cpu = std::make_shared<CpuInfo>(*cpuInfo);
|
||||
userInfo.gpu = std::make_shared<std::vector<GpuInfo>>(*gpuInfos);
|
||||
userInfo.monitor = std::make_shared<std::vector<DisplayMonitorInfo>>(*monitorInfos);
|
||||
|
||||
return userInfo;
|
||||
}
|
||||
#pragma warning(disable : 4996)
|
||||
void WinDeviceManager::_UpdateOperatingSystemInfo()
|
||||
{
|
||||
if (!osInfo)
|
||||
{
|
||||
osInfo = std::make_shared<OsInfo>(*osInfo);
|
||||
}
|
||||
// 获取操作系统版本信息
|
||||
OSVERSIONINFO osvi;
|
||||
ZeroMemory(&osvi, sizeof(OSVERSIONINFO));
|
||||
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
|
||||
GetVersionEx(&osvi);
|
||||
osInfo->name = Wstring2String(osvi.szCSDVersion);
|
||||
osInfo->majorVersion = static_cast<unsigned long>(osvi.dwMajorVersion);
|
||||
osInfo->minorVersion = static_cast<unsigned long>(osvi.dwMinorVersion);
|
||||
osInfo->buildNumber = static_cast<unsigned long>(osvi.dwBuildNumber);
|
||||
|
||||
// 获取系统内存信息
|
||||
MEMORYSTATUSEX memStatus;
|
||||
ZeroMemory(&memStatus, sizeof(MEMORYSTATUSEX));
|
||||
memStatus.dwLength = sizeof(MEMORYSTATUSEX);
|
||||
GlobalMemoryStatusEx(&memStatus);
|
||||
osInfo->totalMemory = static_cast<int64_t>(memStatus.ullTotalPhys / (1024 * 1024));
|
||||
}
|
||||
|
||||
void WinDeviceManager::_UpdateGpuInfo()
|
||||
{
|
||||
if (!gpuInfos)
|
||||
{
|
||||
gpuInfos = std::make_shared<std::vector<GpuInfo>>(*gpuInfos);
|
||||
}
|
||||
gpuInfos->clear();
|
||||
IDXGIFactory* pFactory = nullptr;
|
||||
CreateDXGIFactory(__uuidof(IDXGIFactory), (void**)(&pFactory));
|
||||
IDXGIAdapter* pAdapter = nullptr;
|
||||
bool isFind = false;
|
||||
for (UINT adapterIndex = 0; pFactory->EnumAdapters(adapterIndex, &pAdapter) != DXGI_ERROR_NOT_FOUND; ++
|
||||
adapterIndex)
|
||||
{
|
||||
DXGI_ADAPTER_DESC adapter_desc;
|
||||
pAdapter->GetDesc(&adapter_desc);
|
||||
GpuInfo gpuInfo;
|
||||
gpuInfo.name = Wstring2String(adapter_desc.Description);
|
||||
gpuInfo.deviceId = static_cast<uint32_t>(adapter_desc.DeviceId);
|
||||
gpuInfo.vendorId = static_cast<uint32_t>(adapter_desc.VendorId);
|
||||
gpuInfo.vram = static_cast<size_t>(adapter_desc.DedicatedVideoMemory);
|
||||
gpuInfos->push_back(gpuInfo);
|
||||
}
|
||||
pFactory->Release();
|
||||
}
|
||||
|
||||
BOOL WinDeviceManager::_EnumMonitorProc(HMONITOR hMonitor)
|
||||
{
|
||||
MONITORINFOEXA miex;
|
||||
miex.cbSize = sizeof(miex);
|
||||
|
||||
if (GetMonitorInfoA(hMonitor, (LPMONITORINFO)&miex))
|
||||
{
|
||||
DisplayMonitorInfo info;
|
||||
info.monitor = std::make_shared<HMONITOR>(hMonitor);
|
||||
info.name = miex.szDevice;
|
||||
info.width = miex.rcMonitor.right - miex.rcMonitor.left;
|
||||
info.height = miex.rcMonitor.bottom - miex.rcMonitor.top;
|
||||
monitorInfos->push_back(info);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL CALLBACK WinDeviceManager::Monitor_enum_proc_(HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData)
|
||||
{
|
||||
return ((WinDeviceManager*)dwData)->_EnumMonitorProc(hMonitor);
|
||||
}
|
||||
|
||||
void WinDeviceManager::_UpdateMonitorInfo()
|
||||
{
|
||||
if (!monitorInfos)
|
||||
{
|
||||
monitorInfos = std::make_shared<std::vector<DisplayMonitorInfo>>(*monitorInfos);
|
||||
}
|
||||
monitorInfos->clear();
|
||||
::EnumDisplayMonitors(NULL, NULL, Monitor_enum_proc_, (LPARAM)this);
|
||||
}
|
||||
|
||||
bool WinDeviceManager::IsDirectDrawAccelerationAvailable()
|
||||
{
|
||||
IDirectDraw* pDirectDraw = nullptr;
|
||||
|
||||
HRESULT hr = DirectDrawCreate(nullptr, &pDirectDraw, nullptr);
|
||||
if (FAILED(hr))
|
||||
{
|
||||
// DirectDraw 创建失败,可能是不支持或没有安装 DirectX
|
||||
return false;
|
||||
}
|
||||
|
||||
// 获取 DirectDraw 加速信息
|
||||
DDCAPS ddcaps;
|
||||
ZeroMemory(&ddcaps, sizeof(ddcaps));
|
||||
ddcaps.dwSize = sizeof(ddcaps);
|
||||
|
||||
hr = pDirectDraw->GetCaps(&ddcaps, nullptr);
|
||||
pDirectDraw->Release();
|
||||
|
||||
if (FAILED(hr))
|
||||
{
|
||||
// 获取 DirectDraw 加速信息失败
|
||||
return false;
|
||||
}
|
||||
|
||||
// 检查是否支持硬件加速
|
||||
return (ddcaps.dwCaps & DDCAPS_NOHARDWARE) == 0;
|
||||
}
|
||||
|
||||
bool WinDeviceManager::IsDirect3DAccelerationAvailable()
|
||||
{
|
||||
D3D_FEATURE_LEVEL featureLevel;
|
||||
|
||||
// 尝试创建硬件设备,如果失败,尝试创建支持较低特性级别的设备
|
||||
HRESULT hr = D3D11CreateDevice(
|
||||
nullptr,
|
||||
D3D_DRIVER_TYPE_HARDWARE,
|
||||
nullptr,
|
||||
0,
|
||||
nullptr,
|
||||
0,
|
||||
D3D11_SDK_VERSION,
|
||||
nullptr,
|
||||
&featureLevel,
|
||||
nullptr
|
||||
);
|
||||
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// 依次尝试创建支持较低特性级别的设备
|
||||
hr = D3D10CreateDevice(
|
||||
nullptr,
|
||||
D3D10_DRIVER_TYPE_HARDWARE,
|
||||
nullptr,
|
||||
0,
|
||||
D3D10_SDK_VERSION,
|
||||
nullptr
|
||||
);
|
||||
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
IDirect3D9* pD3D = Direct3DCreate9(D3D_SDK_VERSION);
|
||||
|
||||
if (pD3D == nullptr)
|
||||
{
|
||||
// DirectX is not installed or not available
|
||||
return false;
|
||||
}
|
||||
D3DCAPS9 caps;
|
||||
if (FAILED(pD3D->GetDeviceCaps(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, &caps)))
|
||||
{
|
||||
// Failed to get device capabilities
|
||||
pD3D->Release();
|
||||
return false;
|
||||
}
|
||||
// Check if Direct3D acceleration is supported
|
||||
const bool accelerationAvailable = (caps.DevCaps & D3DDEVCAPS_HWTRANSFORMANDLIGHT) != 0;
|
||||
|
||||
pD3D->Release();
|
||||
|
||||
return accelerationAvailable;
|
||||
}
|
||||
}
|
||||
31
WinDevice/Device/WinDeviceManager.h
Normal file
31
WinDevice/Device/WinDeviceManager.h
Normal file
@@ -0,0 +1,31 @@
|
||||
#pragma once
|
||||
#include <memory>
|
||||
|
||||
#include "UserDeviceInfo.h"
|
||||
#include <Mmdeviceapi.h>
|
||||
|
||||
namespace WinDevice
|
||||
{
|
||||
class WINDEVICE_API WinDeviceManager {
|
||||
public:
|
||||
WinDeviceManager();
|
||||
~WinDeviceManager();
|
||||
|
||||
UserDeviceInfo GetUserDeviceInfo();
|
||||
static bool IsDirectDrawAccelerationAvailable();
|
||||
static bool IsDirect3DAccelerationAvailable();
|
||||
|
||||
private:
|
||||
std::shared_ptr<OsInfo> osInfo;
|
||||
std::shared_ptr<CpuInfo> cpuInfo;
|
||||
std::shared_ptr<std::vector<GpuInfo>> gpuInfos;
|
||||
std::shared_ptr<std::vector<DisplayMonitorInfo>> monitorInfos;
|
||||
|
||||
void _UpdateOperatingSystemInfo();
|
||||
void _UpdateCpuInfo();
|
||||
void _UpdateGpuInfo();
|
||||
BOOL _EnumMonitorProc(HMONITOR hMonitor);
|
||||
static BOOL CALLBACK Monitor_enum_proc_(HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData);
|
||||
void _UpdateMonitorInfo();
|
||||
};
|
||||
}
|
||||
7
WinDevice/Export.h
Normal file
7
WinDevice/Export.h
Normal file
@@ -0,0 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#ifdef WINDEVICE_EXPORTS
|
||||
#define WINDEVICE_API __declspec(dllexport)
|
||||
#else
|
||||
#define WINDEVICE_API __declspec(dllimport)
|
||||
#endif
|
||||
@@ -4,7 +4,7 @@
|
||||
#include <iostream>
|
||||
#include <Windows.h>
|
||||
#include <string>
|
||||
#include <spdlog.h>
|
||||
#include "spdlog/spdlog.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
#pragma once
|
||||
#include "Export.h"
|
||||
#include <string>
|
||||
|
||||
class CmdUtil
|
||||
class WINDEVICE_API CmdUtil
|
||||
{
|
||||
public:
|
||||
static std::string ExecuteCommand(const std::string& command);
|
||||
|
||||
19
WinDevice/Utils/Log.cpp
Normal file
19
WinDevice/Utils/Log.cpp
Normal file
@@ -0,0 +1,19 @@
|
||||
#include "Log.h"
|
||||
#include "spdlog/spdlog.h"
|
||||
|
||||
|
||||
void Log::Init(LogLevel level, std::string fileName)
|
||||
{
|
||||
spdlog::set_pattern("[%H:%M:%S %z] [%n] [%^---%L---%$] [thread %t] %v");
|
||||
}
|
||||
|
||||
void Log::Info(std::string format, std::string args...)
|
||||
{
|
||||
spdlog::info(format, args);
|
||||
}
|
||||
|
||||
void Log::WInfo(std::wstring format, std::wstring args...)
|
||||
{
|
||||
std::string s_format(format.begin(), format.end());
|
||||
|
||||
}
|
||||
18
WinDevice/Utils/Log.h
Normal file
18
WinDevice/Utils/Log.h
Normal file
@@ -0,0 +1,18 @@
|
||||
#pragma once
|
||||
#include "Export.h"
|
||||
#include "spdlog/spdlog.h"
|
||||
|
||||
enum LogLevel : int
|
||||
{
|
||||
Debug = spdlog::level::debug,
|
||||
Info = spdlog::level::info,
|
||||
};
|
||||
|
||||
class Log
|
||||
{
|
||||
public:
|
||||
static void Init(LogLevel level, std::string fileName);
|
||||
|
||||
static void Info(std::string format, std::string args...);
|
||||
static void WInfo(std::wstring format, std::wstring args...);
|
||||
};
|
||||
24
WinDevice/Utils/StringUtil.h
Normal file
24
WinDevice/Utils/StringUtil.h
Normal file
@@ -0,0 +1,24 @@
|
||||
#ifndef STRING_UTIL_H
|
||||
#define STRING_UTIL_H
|
||||
#include "Export.h"
|
||||
#include <string>
|
||||
#include <locale>
|
||||
#include <codecvt>
|
||||
|
||||
template<typename To, typename From>
|
||||
WINDEVICE_API To Convert(const From& input) {
|
||||
std::wstring_convert<std::codecvt_utf8<typename From::value_type>, typename From::value_type> converter;
|
||||
return converter.to_bytes(input);
|
||||
}
|
||||
|
||||
WINDEVICE_API inline std::string Wstring2String(const std::wstring& input) {
|
||||
return Convert<std::string>(input);
|
||||
}
|
||||
|
||||
WINDEVICE_API inline std::string Wchar2String(const WCHAR* input) {
|
||||
std::wstring_convert<std::codecvt_utf8<wchar_t>> converter;
|
||||
return converter.to_bytes(input);
|
||||
}
|
||||
|
||||
|
||||
#endif // STRING_CONVERSION_H
|
||||
@@ -1,9 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#include "Export.h"
|
||||
#pragma comment(lib, "IPHLPAPI.lib")
|
||||
#pragma comment(lib, "wbemuuid.lib")
|
||||
|
||||
class SysInfoUtil
|
||||
class WINDEVICE_API SysInfoUtil
|
||||
{
|
||||
public:
|
||||
void GetMacByGetAdaptersInfo(char* outMAC) const;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
#include "TimeUtil.h"
|
||||
#include <spdlog.h>
|
||||
|
||||
#include "spdlog/spdlog.h"
|
||||
|
||||
template <typename Func>
|
||||
void TimeUtil<Func>::CalExecuteTime(Func func)
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
#pragma once
|
||||
#include "Export.h"
|
||||
template <typename Func>
|
||||
|
||||
class TimeUtil
|
||||
class WINDEVICE_API TimeUtil
|
||||
{
|
||||
public:
|
||||
static void CalExecuteTime(Func func);
|
||||
|
||||
@@ -1,15 +1,107 @@
|
||||
#include "ScreenManager.h"
|
||||
#include "spdlog/spdlog.h"
|
||||
#include "spdlog/sinks/basic_file_sink.h"
|
||||
#include "spdlog/sinks/stdout_color_sinks.h"
|
||||
#include "Utils/StringUtil.h"
|
||||
|
||||
|
||||
void SceenManager::UpdateDisplayInfo()
|
||||
ScreenManager::ScreenManager()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void SceenManager::_UpdateDisplayDeviceList()
|
||||
ScreenManager::~ScreenManager()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void SceenManager::_UpdateMonitorInfoMap()
|
||||
void ScreenManager::UpdateDisplayInfo()
|
||||
{
|
||||
_UpdateDisplayDeviceList();
|
||||
_UpdateMonitorInfoMap();
|
||||
}
|
||||
|
||||
void ScreenManager::_UpdateDisplayDeviceList()
|
||||
{
|
||||
spdlog::info("=====GetInfoByEnumDisplayDevices start=====");
|
||||
DISPLAY_DEVICE displayDevice;
|
||||
displayDevice.cb = sizeof(DISPLAY_DEVICE);
|
||||
DWORD deviceIndex = 0;
|
||||
|
||||
while (EnumDisplayDevices(nullptr, deviceIndex, &displayDevice, 0))
|
||||
{
|
||||
spdlog::info("Display Device DeviceName:{0}, DeviceString:{1}, DeviceID:{2}, DeviceKey:{3}.",
|
||||
Wstring2String(displayDevice.DeviceName), Wstring2String(displayDevice.DeviceString),
|
||||
Wstring2String(displayDevice.DeviceID), Wstring2String(displayDevice.DeviceKey));
|
||||
_displayDeviceList.push_back(displayDevice);
|
||||
deviceIndex++;
|
||||
}
|
||||
|
||||
spdlog::info("=====GetInfoByEnumDisplayDevices end=====");
|
||||
}
|
||||
|
||||
BOOL ScreenManager::_EnumMonitorProc(HMONITOR hMonitor)
|
||||
{
|
||||
MONITORINFOEX monitorInfo;
|
||||
monitorInfo.cbSize = sizeof(MONITORINFOEX);
|
||||
if (GetMonitorInfo(hMonitor, &monitorInfo))
|
||||
{
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD>Ѻ<EFBFBD><D1BA><EFBFBD><EFBFBD><EFBFBD>
|
||||
spdlog::info("_UpdateMonitorInfoMap, szDevice:{0}, right:{1}, bottom:{2}", Wchar2String(monitorInfo.szDevice),
|
||||
monitorInfo.rcMonitor.right, monitorInfo.rcMonitor.bottom);
|
||||
}
|
||||
auto it = ScreenManager::_hMonitorInfoMap.find(hMonitor);
|
||||
if (it != ScreenManager::_hMonitorInfoMap.end())
|
||||
{
|
||||
// <20><><EFBFBD>Ѿ<EFBFBD><D1BE><EFBFBD><EFBFBD>ڣ<EFBFBD><DAA3><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD>ظ<EFBFBD>
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD>ﴦ<EFBFBD><EFB4A6><EFBFBD>ظ<EFBFBD><D8B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
}
|
||||
else
|
||||
{
|
||||
ScreenManager::_hMonitorInfoMap.insert(std::make_pair(hMonitor, monitorInfo));
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڣ<EFBFBD><DAA3><EFBFBD>ʾû<CABE><C3BB><EFBFBD>ظ<EFBFBD>
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD>ﴦ<EFBFBD><EFB4A6><EFBFBD><EFBFBD><EFBFBD>ظ<EFBFBD><D8B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
}
|
||||
|
||||
DISPLAYCONFIG_TARGET_DEVICE_NAME targetDeviceName = {};
|
||||
targetDeviceName.header.size = sizeof(targetDeviceName);
|
||||
|
||||
// <20><>ȡָ<C8A1><D6B8> HMONITOR <20><>Ŀ<EFBFBD><C4BF><EFBFBD>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
|
||||
if (DisplayConfigGetDeviceInfo(&targetDeviceName.header) == ERROR_SUCCESS)
|
||||
{
|
||||
spdlog::info("_UpdateMonitorInfoMap, monitorDevicePath:{0}, monitorFriendlyDeviceName:{1}",
|
||||
Wchar2String(targetDeviceName.monitorDevicePath), Wchar2String(targetDeviceName.monitorFriendlyDeviceName));
|
||||
|
||||
// <20><>ȡָ<C8A1><D6B8> HMONITOR <20>ķֱ<C4B7><D6B1><EFBFBD><EFBFBD><EFBFBD>Ϣ
|
||||
DEVMODE dm;
|
||||
dm.dmSize = sizeof(DEVMODE);
|
||||
dm.dmDriverExtra = 0;
|
||||
|
||||
if (EnumDisplaySettings(targetDeviceName.monitorDevicePath, ENUM_CURRENT_SETTINGS, &dm) != 0)
|
||||
{
|
||||
spdlog::info("Resolution:{0}x{1}", dm.dmPelsWidth, dm.dmPelsHeight);
|
||||
}
|
||||
else
|
||||
{
|
||||
spdlog::info("Failed to get display resolution.");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
spdlog::info("Failed to get display device info.");
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL CALLBACK ScreenManager::EnumMonitorsProc(HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData)
|
||||
{
|
||||
return ((ScreenManager*)dwData)->_EnumMonitorProc(hMonitor);
|
||||
}
|
||||
|
||||
void ScreenManager::_UpdateMonitorInfoMap()
|
||||
{
|
||||
spdlog::info("=====GetInfoByEnumDisplayMonitors start=====");
|
||||
// ö<><C3B6><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE>
|
||||
EnumDisplayMonitors(nullptr, nullptr, EnumMonitorsProc, reinterpret_cast<LPARAM>(this));
|
||||
spdlog::info("=====GetInfoByEnumDisplayMonitors end=====");
|
||||
}
|
||||
|
||||
@@ -1,17 +1,22 @@
|
||||
#pragma once
|
||||
#include "stdafx.h"
|
||||
#include <vector>
|
||||
#include <map>
|
||||
|
||||
#include <Mmdeviceapi.h>
|
||||
|
||||
class SceenManager
|
||||
class WINDEVICE_API ScreenManager
|
||||
{
|
||||
public:
|
||||
ScreenManager();
|
||||
~ScreenManager();
|
||||
void UpdateDisplayInfo();
|
||||
|
||||
private:
|
||||
void _UpdateDisplayDeviceList();
|
||||
void _UpdateMonitorInfoMap();
|
||||
static BOOL CALLBACK EnumMonitorsProc(HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData);
|
||||
BOOL _EnumMonitorProc(HMONITOR hMonitor);
|
||||
|
||||
std::vector<DISPLAY_DEVICE> _displayDeviceList;
|
||||
std::map<HMONITOR, MONITORINFOEX> _hMonitorInfoMap;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// WinDevice.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
|
||||
//
|
||||
#ifdef _DEBUG
|
||||
#include <stdafx.h>
|
||||
#include <chrono>
|
||||
#include <iostream>
|
||||
@@ -7,26 +8,25 @@
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
#include <spdlog.h>
|
||||
#include "spdlog/spdlog.h"
|
||||
|
||||
#include "Utils/CmdUtil.h"
|
||||
#include "Video/ScreenManager.h"
|
||||
#include "Device/WinDeviceManager.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
int main()
|
||||
{
|
||||
const std::string command = "wmic desktopmonitor get PNPDeviceId,ScreenWidth,ScreenHeight";
|
||||
const std::string command_output = CmdUtil::ExecuteCommand(command);
|
||||
|
||||
// const std::string command = "wmic desktopmonitor get PNPDeviceId,ScreenWidth,ScreenHeight";
|
||||
// const std::string command_output = CmdUtil::ExecuteCommand(command);
|
||||
// spdlog::info(L"xxxx");
|
||||
// ScreenManager sceen_manager;
|
||||
// sceen_manager.UpdateDisplayInfo();
|
||||
|
||||
spdlog::info("IsDirect3DAccelerationAvailable: {0}", WinDevice::WinDeviceManager::IsDirect3DAccelerationAvailable());
|
||||
spdlog::info("IsDirectDrawAccelerationAvailable: {0}", WinDevice::WinDeviceManager::IsDirectDrawAccelerationAvailable());
|
||||
getchar();
|
||||
return 0;
|
||||
}
|
||||
|
||||
// 运行程序: Ctrl + F5 或调试 >“开始执行(不调试)”菜单
|
||||
// 调试程序: F5 或调试 >“开始调试”菜单
|
||||
|
||||
// 入门使用技巧:
|
||||
// 1. 使用解决方案资源管理器窗口添加/管理文件
|
||||
// 2. 使用团队资源管理器窗口连接到源代码管理
|
||||
// 3. 使用输出窗口查看生成输出和其他消息
|
||||
// 4. 使用错误列表窗口查看错误
|
||||
// 5. 转到“项目”>“添加新项”以创建新的代码文件,或转到“项目”>“添加现有项”以将现有代码文件添加到项目
|
||||
// 6. 将来,若要再次打开此项目,请转到“文件”>“打开”>“项目”并选择 .sln 文件
|
||||
#endif
|
||||
1
WinDevice/WinDevice.def
Normal file
1
WinDevice/WinDevice.def
Normal file
@@ -0,0 +1 @@
|
||||
LIBRARY WinDevice
|
||||
@@ -33,7 +33,7 @@
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
@@ -46,7 +46,7 @@
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
@@ -72,29 +72,35 @@
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
<IncludePath>$(IncludePath)</IncludePath>
|
||||
<IncludePath>$(IncludePath);C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\Include;</IncludePath>
|
||||
<LibraryPath>$(VC_LibraryPath_x86);$(WindowsSDK_LibraryPath_x86);C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\Lib\x86;</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
<IncludePath>$(VC_IncludePath);$(WindowsSDK_IncludePath);C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\Include;</IncludePath>
|
||||
<LibraryPath>$(VC_LibraryPath_x64);$(WindowsSDK_LibraryPath_x64);C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\Lib\x64;</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<IncludePath>$(VC_IncludePath);$(WindowsSDK_IncludePath);C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\Include;</IncludePath>
|
||||
<LibraryPath>$(VC_LibraryPath_x64);$(WindowsSDK_LibraryPath_x64);C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\Lib\x64</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions);SPDLOG_WCHAR_FILENAMES</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<AdditionalIncludeDirectories>$(ProjectDir)include\third_lib\;$(ProjectDir)include\third_lib\spdlog\;.</AdditionalIncludeDirectories>
|
||||
<AdditionalIncludeDirectories>$(ProjectDir)include\third_lib\;.</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>dxgi.lib;cfgmgr32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalDependencies>dxgi.lib;cfgmgr32.lib;d3d9.lib;d3d10.lib;d3d11.lib;d3d12.lib;ddraw.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<ModuleDefinitionFile>WinDevice.def</ModuleDefinitionFile>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
@@ -103,15 +109,17 @@
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>WINDEVICE_EXPORTS;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<AdditionalIncludeDirectories>.;</AdditionalIncludeDirectories>
|
||||
<AdditionalIncludeDirectories>$(ProjectDir)include\third_lib\;.</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;dxgi.lib;cfgmgr32.lib;d3d9.lib;d3d10.lib;d3d11.lib;d3d12.lib;ddraw.lib;version.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<ModuleDefinitionFile>WinDevice.def</ModuleDefinitionFile>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
@@ -120,11 +128,13 @@
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<AdditionalIncludeDirectories>.;</AdditionalIncludeDirectories>
|
||||
<AdditionalIncludeDirectories>$(ProjectDir)include\third_lib\;.</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;dxgi.lib;cfgmgr32.lib;d3d9.lib;d3d10.lib;d3d11.lib;d3d12.lib;ddraw.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<ModuleDefinitionFile>WinDevice.def</ModuleDefinitionFile>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
@@ -133,20 +143,24 @@
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>WINDEVICE_EXPORTS;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<AdditionalIncludeDirectories>.;</AdditionalIncludeDirectories>
|
||||
<AdditionalIncludeDirectories>$(ProjectDir)include\third_lib\;.</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;dxgi.lib;cfgmgr32.lib;d3d9.lib;d3d10.lib;d3d11.lib;d3d12.lib;ddraw.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<ModuleDefinitionFile>WinDevice.def</ModuleDefinitionFile>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="Audio\AudioManager.cpp" />
|
||||
<ClCompile Include="Device\WinDeviceManager.cpp" />
|
||||
<ClCompile Include="Utils\CmdUtil.cpp" />
|
||||
<ClCompile Include="Utils\Log.cpp" />
|
||||
<ClCompile Include="Utils\SysInfoUtil.cpp" />
|
||||
<ClCompile Include="Utils\TimeUtil.cpp" />
|
||||
<ClCompile Include="Video\ScreenManager.cpp" />
|
||||
@@ -155,12 +169,20 @@
|
||||
<ItemGroup>
|
||||
<ClInclude Include="Audio\AudioEnum.h" />
|
||||
<ClInclude Include="Audio\AudioManager.h" />
|
||||
<ClInclude Include="Device\UserDeviceInfo.h" />
|
||||
<ClInclude Include="Device\WinDeviceManager.h" />
|
||||
<ClInclude Include="Export.h" />
|
||||
<ClInclude Include="stdafx.h" />
|
||||
<ClInclude Include="Utils\CmdUtil.h" />
|
||||
<ClInclude Include="Utils\Log.h" />
|
||||
<ClInclude Include="Utils\StringUtil.h" />
|
||||
<ClInclude Include="Utils\SysInfoUtil.h" />
|
||||
<ClInclude Include="Utils\TimeUtil.h" />
|
||||
<ClInclude Include="Video\ScreenManager.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="WinDevice.def" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
|
||||
@@ -33,6 +33,12 @@
|
||||
<ClCompile Include="Utils\TimeUtil.cpp">
|
||||
<Filter>源文件</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Utils\Log.cpp">
|
||||
<Filter>源文件</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Device\WinDeviceManager.cpp">
|
||||
<Filter>源文件</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="Audio\AudioEnum.h">
|
||||
@@ -56,5 +62,22 @@
|
||||
<ClInclude Include="Utils\TimeUtil.h">
|
||||
<Filter>头文件</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Utils\Log.h">
|
||||
<Filter>头文件</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Utils\StringUtil.h">
|
||||
<Filter>头文件</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Device\UserDeviceInfo.h">
|
||||
<Filter>头文件</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Device\WinDeviceManager.h">
|
||||
<Filter>头文件</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="WinDevice.def">
|
||||
<Filter>源文件</Filter>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -1,363 +0,0 @@
|
||||
// Copyright(c) 2015-present, Gabi Melman & spdlog contributors.
|
||||
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
|
||||
|
||||
// spdlog main header file.
|
||||
// see example.cpp for usage example
|
||||
|
||||
#ifndef SPDLOG_H
|
||||
#define SPDLOG_H
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <spdlog/common.h>
|
||||
#include <spdlog/details/registry.h>
|
||||
#include <spdlog/logger.h>
|
||||
#include <spdlog/version.h>
|
||||
#include <spdlog/details/synchronous_factory.h>
|
||||
|
||||
#include <chrono>
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
namespace spdlog {
|
||||
|
||||
using default_factory = synchronous_factory;
|
||||
|
||||
// Create and register a logger with a templated sink type
|
||||
// The logger's level, formatter and flush level will be set according the
|
||||
// global settings.
|
||||
//
|
||||
// Example:
|
||||
// spdlog::create<daily_file_sink_st>("logger_name", "dailylog_filename", 11, 59);
|
||||
template<typename Sink, typename... SinkArgs>
|
||||
inline std::shared_ptr<spdlog::logger> create(std::string logger_name, SinkArgs &&...sink_args)
|
||||
{
|
||||
return default_factory::create<Sink>(std::move(logger_name), std::forward<SinkArgs>(sink_args)...);
|
||||
}
|
||||
|
||||
// Initialize and register a logger,
|
||||
// formatter and flush level will be set according the global settings.
|
||||
//
|
||||
// Useful for initializing manually created loggers with the global settings.
|
||||
//
|
||||
// Example:
|
||||
// auto mylogger = std::make_shared<spdlog::logger>("mylogger", ...);
|
||||
// spdlog::initialize_logger(mylogger);
|
||||
SPDLOG_API void initialize_logger(std::shared_ptr<logger> logger);
|
||||
|
||||
// Return an existing logger or nullptr if a logger with such name doesn't
|
||||
// exist.
|
||||
// example: spdlog::get("my_logger")->info("hello {}", "world");
|
||||
SPDLOG_API std::shared_ptr<logger> get(const std::string &name);
|
||||
|
||||
// Set global formatter. Each sink in each logger will get a clone of this object
|
||||
SPDLOG_API void set_formatter(std::unique_ptr<spdlog::formatter> formatter);
|
||||
|
||||
// Set global format string.
|
||||
// example: spdlog::set_pattern("%Y-%m-%d %H:%M:%S.%e %l : %v");
|
||||
SPDLOG_API void set_pattern(std::string pattern, pattern_time_type time_type = pattern_time_type::local);
|
||||
|
||||
// enable global backtrace support
|
||||
SPDLOG_API void enable_backtrace(size_t n_messages);
|
||||
|
||||
// disable global backtrace support
|
||||
SPDLOG_API void disable_backtrace();
|
||||
|
||||
// call dump backtrace on default logger
|
||||
SPDLOG_API void dump_backtrace();
|
||||
|
||||
// Get global logging level
|
||||
SPDLOG_API level::level_enum get_level();
|
||||
|
||||
// Set global logging level
|
||||
SPDLOG_API void set_level(level::level_enum log_level);
|
||||
|
||||
// Determine whether the default logger should log messages with a certain level
|
||||
SPDLOG_API bool should_log(level::level_enum lvl);
|
||||
|
||||
// Set global flush level
|
||||
SPDLOG_API void flush_on(level::level_enum log_level);
|
||||
|
||||
// Start/Restart a periodic flusher thread
|
||||
// Warning: Use only if all your loggers are thread safe!
|
||||
template<typename Rep, typename Period>
|
||||
inline void flush_every(std::chrono::duration<Rep, Period> interval)
|
||||
{
|
||||
details::registry::instance().flush_every(interval);
|
||||
}
|
||||
|
||||
// Set global error handler
|
||||
SPDLOG_API void set_error_handler(void (*handler)(const std::string &msg));
|
||||
|
||||
// Register the given logger with the given name
|
||||
SPDLOG_API void register_logger(std::shared_ptr<logger> logger);
|
||||
|
||||
// Apply a user defined function on all registered loggers
|
||||
// Example:
|
||||
// spdlog::apply_all([&](std::shared_ptr<spdlog::logger> l) {l->flush();});
|
||||
SPDLOG_API void apply_all(const std::function<void(std::shared_ptr<logger>)> &fun);
|
||||
|
||||
// Drop the reference to the given logger
|
||||
SPDLOG_API void drop(const std::string &name);
|
||||
|
||||
// Drop all references from the registry
|
||||
SPDLOG_API void drop_all();
|
||||
|
||||
// stop any running threads started by spdlog and clean registry loggers
|
||||
SPDLOG_API void shutdown();
|
||||
|
||||
// Automatic registration of loggers when using spdlog::create() or spdlog::create_async
|
||||
SPDLOG_API void set_automatic_registration(bool automatic_registration);
|
||||
|
||||
// API for using default logger (stdout_color_mt),
|
||||
// e.g: spdlog::info("Message {}", 1);
|
||||
//
|
||||
// The default logger object can be accessed using the spdlog::default_logger():
|
||||
// For example, to add another sink to it:
|
||||
// spdlog::default_logger()->sinks().push_back(some_sink);
|
||||
//
|
||||
// The default logger can replaced using spdlog::set_default_logger(new_logger).
|
||||
// For example, to replace it with a file logger.
|
||||
//
|
||||
// IMPORTANT:
|
||||
// The default API is thread safe (for _mt loggers), but:
|
||||
// set_default_logger() *should not* be used concurrently with the default API.
|
||||
// e.g do not call set_default_logger() from one thread while calling spdlog::info() from another.
|
||||
|
||||
SPDLOG_API std::shared_ptr<spdlog::logger> default_logger();
|
||||
|
||||
SPDLOG_API spdlog::logger *default_logger_raw();
|
||||
|
||||
SPDLOG_API void set_default_logger(std::shared_ptr<spdlog::logger> default_logger);
|
||||
|
||||
// Initialize logger level based on environment configs.
|
||||
//
|
||||
// Useful for applying SPDLOG_LEVEL to manually created loggers.
|
||||
//
|
||||
// Example:
|
||||
// auto mylogger = std::make_shared<spdlog::logger>("mylogger", ...);
|
||||
// spdlog::apply_logger_env_levels(mylogger);
|
||||
SPDLOG_API void apply_logger_env_levels(std::shared_ptr<logger> logger);
|
||||
|
||||
template<typename... Args>
|
||||
inline void log(source_loc source, level::level_enum lvl, format_string_t<Args...> fmt, Args &&...args)
|
||||
{
|
||||
default_logger_raw()->log(source, lvl, fmt, std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
inline void log(level::level_enum lvl, format_string_t<Args...> fmt, Args &&...args)
|
||||
{
|
||||
default_logger_raw()->log(source_loc{}, lvl, fmt, std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
inline void trace(format_string_t<Args...> fmt, Args &&...args)
|
||||
{
|
||||
default_logger_raw()->trace(fmt, std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
inline void debug(format_string_t<Args...> fmt, Args &&...args)
|
||||
{
|
||||
default_logger_raw()->debug(fmt, std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
inline void info(format_string_t<Args...> fmt, Args &&...args)
|
||||
{
|
||||
default_logger_raw()->info(fmt, std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
inline void warn(format_string_t<Args...> fmt, Args &&...args)
|
||||
{
|
||||
default_logger_raw()->warn(fmt, std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
inline void error(format_string_t<Args...> fmt, Args &&...args)
|
||||
{
|
||||
default_logger_raw()->error(fmt, std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
inline void critical(format_string_t<Args...> fmt, Args &&...args)
|
||||
{
|
||||
default_logger_raw()->critical(fmt, std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline void log(source_loc source, level::level_enum lvl, const T &msg)
|
||||
{
|
||||
default_logger_raw()->log(source, lvl, msg);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline void log(level::level_enum lvl, const T &msg)
|
||||
{
|
||||
default_logger_raw()->log(lvl, msg);
|
||||
}
|
||||
|
||||
#ifdef SPDLOG_WCHAR_TO_UTF8_SUPPORT
|
||||
template<typename... Args>
|
||||
inline void log(source_loc source, level::level_enum lvl, wformat_string_t<Args...> fmt, Args &&...args)
|
||||
{
|
||||
default_logger_raw()->log(source, lvl, fmt, std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
inline void log(level::level_enum lvl, wformat_string_t<Args...> fmt, Args &&...args)
|
||||
{
|
||||
default_logger_raw()->log(source_loc{}, lvl, fmt, std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
inline void trace(wformat_string_t<Args...> fmt, Args &&...args)
|
||||
{
|
||||
default_logger_raw()->trace(fmt, std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
inline void debug(wformat_string_t<Args...> fmt, Args &&...args)
|
||||
{
|
||||
default_logger_raw()->debug(fmt, std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
inline void info(wformat_string_t<Args...> fmt, Args &&...args)
|
||||
{
|
||||
default_logger_raw()->info(fmt, std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
inline void warn(wformat_string_t<Args...> fmt, Args &&...args)
|
||||
{
|
||||
default_logger_raw()->warn(fmt, std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
inline void error(wformat_string_t<Args...> fmt, Args &&...args)
|
||||
{
|
||||
default_logger_raw()->error(fmt, std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
inline void critical(wformat_string_t<Args...> fmt, Args &&...args)
|
||||
{
|
||||
default_logger_raw()->critical(fmt, std::forward<Args>(args)...);
|
||||
}
|
||||
#endif
|
||||
|
||||
template<typename T>
|
||||
inline void trace(const T &msg)
|
||||
{
|
||||
default_logger_raw()->trace(msg);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline void debug(const T &msg)
|
||||
{
|
||||
default_logger_raw()->debug(msg);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline void info(const T &msg)
|
||||
{
|
||||
default_logger_raw()->info(msg);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline void warn(const T &msg)
|
||||
{
|
||||
default_logger_raw()->warn(msg);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline void error(const T &msg)
|
||||
{
|
||||
default_logger_raw()->error(msg);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline void critical(const T &msg)
|
||||
{
|
||||
default_logger_raw()->critical(msg);
|
||||
}
|
||||
|
||||
} // namespace spdlog
|
||||
|
||||
//
|
||||
// enable/disable log calls at compile time according to global level.
|
||||
//
|
||||
// define SPDLOG_ACTIVE_LEVEL to one of those (before including spdlog.h):
|
||||
// SPDLOG_LEVEL_TRACE,
|
||||
// SPDLOG_LEVEL_DEBUG,
|
||||
// SPDLOG_LEVEL_INFO,
|
||||
// SPDLOG_LEVEL_WARN,
|
||||
// SPDLOG_LEVEL_ERROR,
|
||||
// SPDLOG_LEVEL_CRITICAL,
|
||||
// SPDLOG_LEVEL_OFF
|
||||
//
|
||||
|
||||
#ifndef SPDLOG_NO_SOURCE_LOC
|
||||
# define SPDLOG_LOGGER_CALL(logger, level, ...) \
|
||||
(logger)->log(spdlog::source_loc{__FILE__, __LINE__, SPDLOG_FUNCTION}, level, __VA_ARGS__)
|
||||
#else
|
||||
# define SPDLOG_LOGGER_CALL(logger, level, ...) (logger)->log(spdlog::source_loc{}, level, __VA_ARGS__)
|
||||
#endif
|
||||
|
||||
#if SPDLOG_ACTIVE_LEVEL <= SPDLOG_LEVEL_TRACE
|
||||
# define SPDLOG_LOGGER_TRACE(logger, ...) SPDLOG_LOGGER_CALL(logger, spdlog::level::trace, __VA_ARGS__)
|
||||
# define SPDLOG_TRACE(...) SPDLOG_LOGGER_TRACE(spdlog::default_logger_raw(), __VA_ARGS__)
|
||||
#else
|
||||
# define SPDLOG_LOGGER_TRACE(logger, ...) (void)0
|
||||
# define SPDLOG_TRACE(...) (void)0
|
||||
#endif
|
||||
|
||||
#if SPDLOG_ACTIVE_LEVEL <= SPDLOG_LEVEL_DEBUG
|
||||
# define SPDLOG_LOGGER_DEBUG(logger, ...) SPDLOG_LOGGER_CALL(logger, spdlog::level::debug, __VA_ARGS__)
|
||||
# define SPDLOG_DEBUG(...) SPDLOG_LOGGER_DEBUG(spdlog::default_logger_raw(), __VA_ARGS__)
|
||||
#else
|
||||
# define SPDLOG_LOGGER_DEBUG(logger, ...) (void)0
|
||||
# define SPDLOG_DEBUG(...) (void)0
|
||||
#endif
|
||||
|
||||
#if SPDLOG_ACTIVE_LEVEL <= SPDLOG_LEVEL_INFO
|
||||
# define SPDLOG_LOGGER_INFO(logger, ...) SPDLOG_LOGGER_CALL(logger, spdlog::level::info, __VA_ARGS__)
|
||||
# define SPDLOG_INFO(...) SPDLOG_LOGGER_INFO(spdlog::default_logger_raw(), __VA_ARGS__)
|
||||
#else
|
||||
# define SPDLOG_LOGGER_INFO(logger, ...) (void)0
|
||||
# define SPDLOG_INFO(...) (void)0
|
||||
#endif
|
||||
|
||||
#if SPDLOG_ACTIVE_LEVEL <= SPDLOG_LEVEL_WARN
|
||||
# define SPDLOG_LOGGER_WARN(logger, ...) SPDLOG_LOGGER_CALL(logger, spdlog::level::warn, __VA_ARGS__)
|
||||
# define SPDLOG_WARN(...) SPDLOG_LOGGER_WARN(spdlog::default_logger_raw(), __VA_ARGS__)
|
||||
#else
|
||||
# define SPDLOG_LOGGER_WARN(logger, ...) (void)0
|
||||
# define SPDLOG_WARN(...) (void)0
|
||||
#endif
|
||||
|
||||
#if SPDLOG_ACTIVE_LEVEL <= SPDLOG_LEVEL_ERROR
|
||||
# define SPDLOG_LOGGER_ERROR(logger, ...) SPDLOG_LOGGER_CALL(logger, spdlog::level::err, __VA_ARGS__)
|
||||
# define SPDLOG_ERROR(...) SPDLOG_LOGGER_ERROR(spdlog::default_logger_raw(), __VA_ARGS__)
|
||||
#else
|
||||
# define SPDLOG_LOGGER_ERROR(logger, ...) (void)0
|
||||
# define SPDLOG_ERROR(...) (void)0
|
||||
#endif
|
||||
|
||||
#if SPDLOG_ACTIVE_LEVEL <= SPDLOG_LEVEL_CRITICAL
|
||||
# define SPDLOG_LOGGER_CRITICAL(logger, ...) SPDLOG_LOGGER_CALL(logger, spdlog::level::critical, __VA_ARGS__)
|
||||
# define SPDLOG_CRITICAL(...) SPDLOG_LOGGER_CRITICAL(spdlog::default_logger_raw(), __VA_ARGS__)
|
||||
#else
|
||||
# define SPDLOG_LOGGER_CRITICAL(logger, ...) (void)0
|
||||
# define SPDLOG_CRITICAL(...) (void)0
|
||||
#endif
|
||||
|
||||
#ifdef SPDLOG_HEADER_ONLY
|
||||
# include "spdlog-inl.h"
|
||||
#endif
|
||||
|
||||
#endif // SPDLOG_H
|
||||
@@ -90,7 +90,7 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Uncomment to enable wchar_t support (convert to utf8)
|
||||
//
|
||||
// #define SPDLOG_WCHAR_TO_UTF8_SUPPORT
|
||||
#define SPDLOG_WCHAR_TO_UTF8_SUPPORT
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -1,8 +1,26 @@
|
||||
|
||||
#pragma once
|
||||
#pragma once
|
||||
#include "Export.h"
|
||||
|
||||
#include <windows.h>
|
||||
#include <winerror.h>
|
||||
#include <shlwapi.h>
|
||||
#include <Psapi.h>
|
||||
#include <Shellapi.h>
|
||||
#include <Shellapi.h>
|
||||
|
||||
|
||||
#include "dxgi.h"
|
||||
#include "WinUser.h"
|
||||
#include <dxgi1_4.h>
|
||||
#include <d3d9.h>
|
||||
#include <d3d9caps.h>
|
||||
#include <d3d11.h>
|
||||
#include <d3d10_1.h>
|
||||
#include <d3d12.h>
|
||||
|
||||
#include <DirectXMath.h>
|
||||
#include <Dwrite.h>
|
||||
|
||||
#include <intrin.h>
|
||||
|
||||
#include "sysinfoapi.h"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user