Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/134.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 在Windows中以本机方式调整亮度_C#_C++_Windows_Winapi_Brightness - Fatal编程技术网

C# 在Windows中以本机方式调整亮度

C# 在Windows中以本机方式调整亮度,c#,c++,windows,winapi,brightness,C#,C++,Windows,Winapi,Brightness,我想知道什么是调整窗口亮度的本机方法 所谓本机,我指的是在Windows 8、8.1和10的左上角也显示亮度叠加的方法,就像按下了特殊的亮度键一样 我在互联网上到处寻找这个,但有些解决方案确实有效,可以调整亮度,但没有显示叠加。有什么想法吗?有类似的吗 SendMessage(HWND_BROADCAST, WM_SYSCOMMAND, SC_MONITORPOWER, 2); 它关闭了监视器,但是对于亮度,可以从C++使用吗?还是C#?谢谢 更新:这里是示例代码 HMONITOR hMoni

我想知道什么是调整窗口亮度的本机方法

所谓本机,我指的是在Windows 8、8.1和10的左上角也显示亮度叠加的方法,就像按下了特殊的亮度键一样

我在互联网上到处寻找这个,但有些解决方案确实有效,可以调整亮度,但没有显示叠加。有什么想法吗?有类似的吗

SendMessage(HWND_BROADCAST, WM_SYSCOMMAND, SC_MONITORPOWER, 2);

它关闭了监视器,但是对于亮度,可以从C++使用吗?还是C#?谢谢

更新:这里是示例代码

HMONITOR hMonitor = NULL;
DWORD cPhysicalMonitors;
LPPHYSICAL_MONITOR pPhysicalMonitors = NULL;

// Get the monitor handle.
hMonitor = MonitorFromWindow(GetForegroundWindow(), 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(
            hMonitor, cPhysicalMonitors, pPhysicalMonitors);

        // Use the monitor handles (not shown).
        DWORD pdwMinimumBrightness = 0;
        DWORD pdwCurrentBrightness = 0;
        DWORD pdwMaximumBrightness = 0;

        DWORD dwMonitorCapabilities = 0;
        DWORD dwSupportedColorTemperatures = 0;

        bSuccess = GetMonitorCapabilities(pPhysicalMonitors, &dwMonitorCapabilities, &dwSupportedColorTemperatures);

        cout << bSuccess << endl;

        // Close the monitor handles.
        bSuccess = DestroyPhysicalMonitors(
            cPhysicalMonitors,
            pPhysicalMonitors);

        // Free the array.
        free(pPhysicalMonitors);
    }
}
HMONITOR HMONITOR=NULL;
德沃德物理监测器;
LPPHYSICAL\u监视器PPPhysicalMonitors=NULL;
//获取监视器句柄。
hMonitor=MonitorFromWindow(getforegroughindow(),MONITOR\u DEFAULTTOPRIMARY);
//获取物理监视器的数量。
BOOL bSuccess=从HMonitor获取物理监视器的数量(
hMonitor,
&物理监测器
);
如果(b成功)
{
//分配物理监视结构的数组。
pPhysicalMonitors=(LPPhysicalU监视器)malloc(
CPPhysicalMonitors*sizeof(物理监视器);
if(pPhysicalMonitors!=NULL)
{
//获取数组。
bSuccess=GetPhysicalMonitors fromMonitor(
hMonitor、cPhysicalMonitors、pPhysicalMonitors);
//使用监视器手柄(未显示)。
DWORD pdwMinimumBrightness=0;
DWORD pdwCurrentBrightness=0;
DWORD PDWMaximum亮度=0;
DWORD dwMonitorCapabilities=0;
DWORD DWSupportedColorTemperations=0;
bSuccess=GetMonitorCapabilities(PPPhysicalMonitors、&dwMonitorCapabilities、&DWSupportedColorTemperations);

不可能重复:显示GUI的不是亮度控制API。是GUI应用程序调用API来控制亮度。好的,那么我该如何显示GUI并控制它呢?因为现在没有定义为亮度下降/上升的键,同样存在音量下降/上升,所以有c在我的电脑上很清楚有一个驱动程序在做这件事,所以应该可以通过自己的软件实现同样的效果。无论如何,GetMonitorBrightness对我来说是失败的。GUI是自动的。设置亮度,让windows来处理其余的。如果
Get/SetMonitorBrightness
失败,那么你应该向我们展示你正在使用的代码。最好是在好的,我用我的代码更新了帖子