やろうとしているのは、解像度/リフレッシュレートなどの画面情報を取得することです。
#pragma once
#include < windows.h >
#include <string>
#include <sstream>
struct DesktopScreenInfo
{
int Width;
int Height;
int ScreenDepth;
int FrameRate;
std::string ScreenInfoString;
};
class DesktopScreen
{
public:
DesktopScreen(void);
~DesktopScreen(void);
DesktopScreenInfo GetScreenInfo();
private:
DISPLAY_DEVICE GetPrimaryDevice();
};
#include "DesktopScreen.h"
DesktopScreen::DesktopScreen(void)
{
}
DesktopScreen::~DesktopScreen(void)
{
}
DISPLAY_DEVICE DesktopScreen::GetPrimaryDevice(){
int index=0;
DISPLAY_DEVICE dd;
dd.cb = sizeof(DISPLAY_DEVICE);
while (EnumDisplayDevices(NULL, index++, &dd, 0))
{
if (dd.StateFlags & DISPLAY_DEVICE_PRIMARY_DEVICE) return dd;
}
return dd;
}
DesktopScreenInfo DesktopScreen::GetScreenInfo(){
DISPLAY_DEVICE dd = GetPrimaryDevice();
DesktopScreenInfo info;
DEVMODE dm;
dm.dmSize = sizeof(DEVMODE);
if (!EnumDisplaySettings(dd.DeviceName, ENUM_CURRENT_SETTINGS, &dm))
{
//printf("EnumDisplaySettings failed:%d\n", GetLastError());
return info;
}
info.Width = dm.dmPelsWidth;
info.Height = dm.dmPelsHeight;
info.ScreenDepth = dm.dmBitsPerPel;
info.FrameRate = dm.dmDisplayFrequency;
std::stringstream ss;
ss << info.Width << "x" << info.Height << ":" << info.ScreenDepth << "@" << info.FrameRate;
info.ScreenInfoString = ss.str();
}
しかし、それを構築しようとすると、このエラーが発生します
Error 2 error LNK2019: unresolved external symbol __imp__EnumDisplayDevicesA@16 referenced in function "private: struct _DISPLAY_DEVICEA __thiscall DesktopScreen::GetPrimaryDevice(void)" (?GetPrimaryDevice@DesktopScreen@@AAE?AU_DISPLAY_DEVICEA@@XZ)
Error 3 error LNK2019: unresolved external symbol __imp__EnumDisplaySettingsA@12 referenced in function "public: struct DesktopScreenInfo __thiscall DesktopScreen::GetScreenInfo(void)" (?GetScreenInfo@DesktopScreen@@QAE?AUDesktopScreenInfo@@XZ)
何が悪いのかわかりません:S