相关疑难解决方法(0)

如何使用GetMonitorCapabilities和GetMonitorBrightness函数

我正在尝试以编程方式调整我的显示器亮度.经过一些研究,我想出了这个链接,并编写了以下代码(主要是从其他链接复制粘贴,一个引导我).

#include "Windows.h"
#include "WinUser.h"
#include "PhysicalMonitorEnumerationAPI.h"
#include "HighLevelMonitorConfigurationAPI.h"
#include <strsafe.h>

void ShowError(LPTSTR lpszFunction);

int main()
{
    HMONITOR hMonitor = NULL;
    DWORD cPhysicalMonitors;
    LPPHYSICAL_MONITOR pPhysicalMonitors = NULL;

    HWND hWnd = GetDesktopWindow();

    // Get the monitor handle.
    hMonitor = MonitorFromWindow(hWnd, MONITOR_DEFAULTTOPRIMARY);

    // Get the number of physical monitors.
    BOOL bSuccess = GetNumberOfPhysicalMonitorsFromHMONITOR(hMonitor, &cPhysicalMonitors);

    if (bSuccess)
    {
        // Allocate the array of PHYSICAL_MONITOR structures.
        pPhysicalMonitors = (LPPHYSICAL_MONITOR)malloc(cPhysicalMonitors* sizeof(PHYSICAL_MONITOR));

        if (pPhysicalMonitors != NULL)
        {
            // Get the array.
            bSuccess = GetPhysicalMonitorsFromHMONITOR( …
Run Code Online (Sandbox Code Playgroud)

c++ windows winapi

7
推荐指数
1
解决办法
2139
查看次数

标签 统计

c++ ×1

winapi ×1

windows ×1