小编Hex*_*ede的帖子

C++ DXVA库"操作失败,因为DDC/CI消息在其命令字段中具有无效值."

我正在尝试创建一个C++控制台应用程序,它将根据屏幕上显示的像素的平均亮度自动调整显示器的亮度.不幸的是,在我进入第二部分之前,我甚至无法使用DXVA库.

这是我当前的代码(我从这里采用了一些代码:如何使用GetMonitorCapabilities和GetMonitorBrightness函数):

#include "stdafx.h"
#include <iostream>

#include <Windows.h>
#include <WinUser.h>
#include <physicalmonitorenumerationapi.h>
#include <highlevelmonitorconfigurationapi.h>
#include <strsafe.h>

std::string GetLastErrorAsString()
{
    DWORD errorMessageID = ::GetLastError();
    if (errorMessageID == 0)
        return std::string();

    LPSTR messageBuffer = nullptr;
    size_t size = FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
        NULL, errorMessageID, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPSTR)&messageBuffer, 0, NULL);

    std::string message(messageBuffer, size);
    LocalFree(messageBuffer);

    return message;
}

int main()
{
    HWND hWnd = GetDesktopWindow();
    HMONITOR hMonitor = MonitorFromWindow(hWnd, MONITOR_DEFAULTTOPRIMARY);
    DWORD cPhysicalMonitors = 0;

    BOOL bSuccess = GetNumberOfPhysicalMonitorsFromHMONITOR(hMonitor, &cPhysicalMonitors);
    if (!bSuccess) …
Run Code Online (Sandbox Code Playgroud)

c++ dxva

7
推荐指数
0
解决办法
158
查看次数

标签 统计

c++ ×1

dxva ×1