我需要一个winRt c ++组件,可以从JavaScript中调用,可以控制屏幕亮度。我无法调用函数GetDC(NULL),弹出错误。这是我的代码片段:
#include "pch.h"
#include "Class1.h" // The one which i created.
#include <windows.h>
....
BOOL Class1::SetBrightness(HDC hDC, WORD wBrightness)
{
BOOL bReturn = FALSE;
HDC hGammaDC = hDC;
if (hDC == NULL)
{
HDC hGammaDC = GetDC(NULL); // Error 'GetDC' identifier not found.
}
if (hGammaDC != NULL)
{
WORD GammaArray[3][256];
for (int iIndex = 0; iIndex < 256; iIndex++)
{
int iArrayValue = iIndex * (wBrightness + 128);
if (iArrayValue > 65535)
iArrayValue = 65535;
GammaArray[0][iIndex] =
GammaArray[1][iIndex] =
GammaArray[2][iIndex] = (WORD)iArrayValue;
}
bReturn = SetDeviceGammaRamp(hGammaDC, GammaArray);
}
if (hDC == NULL)
ReleaseDC(NULL, hGammaDC);
return bReturn;
}
回复对我来说很重要。 提前致谢