基本信息
源码名称:获取设置显示器的亮度,对比度等参数
源码大小:0.86M
文件格式:.rar
开发语言:C/C++
更新时间:2021-10-25
友情提示:(无需注册或充值,赞助后即可获取资源下载链接)
嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300
本次赞助数额为: 2 元×
微信扫码支付:2 元
×
请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
源码介绍
获取设置显示器的亮度,对比度等参数
static BOOL CALLBACK MonitorEnum(HMONITOR hMon, HDC hdc, LPRECT lprcMonitor, LPARAM pData)
{
cout << "hmonitor:" << hMon << endl;
MONITORINFOEX mi;
mi.cbSize = sizeof(mi);
GetMonitorInfo(hMon, (LPMONITORINFO)&mi);
wcout << "deviceName: " << mi.szDevice << endl;
DWORD cPhysicalMonitors;
BOOL bSuccess = GetNumberOfPhysicalMonitorsFromHMONITOR(hMon, &cPhysicalMonitors);
cout << "GetNumber: " << bSuccess << ", number of physical monitors: " << cPhysicalMonitors << endl;
LPPHYSICAL_MONITOR pPhysicalMonitors = (LPPHYSICAL_MONITOR)malloc(cPhysicalMonitors * sizeof(PHYSICAL_MONITOR));
if (pPhysicalMonitors != NULL)
{
bSuccess = GetPhysicalMonitorsFromHMONITOR(hMon, cPhysicalMonitors, pPhysicalMonitors);
cout << "GetPhysicalMonitor: " << bSuccess << endl
<< "Handle: " << pPhysicalMonitors->hPhysicalMonitor << endl
<< "Description: ";
wcout << (WCHAR*)(pPhysicalMonitors->szPhysicalMonitorDescription) << endl;
cout << (pPhysicalMonitors->hPhysicalMonitor) << endl;
if (bSuccess) {
BYTE vcpCode = 0xD6;
//bSuccess = SetVCPFeature(pPhysicalMonitors->hPhysicalMonitor, vcpCode, 0x1);
bSuccess = SetMonitorBrightness(pPhysicalMonitors->hPhysicalMonitor, 60);
cout << "SetMonitorBrightness:" << bSuccess << endl;
//try to get edid
int len = sizeof(DWORD);
cout << len << endl;
vcpCode = 0xDF;
DWORD curValue;
DWORD maxValue;
LPMC_VCP_CODE_TYPE vcpCodeType = (LPMC_VCP_CODE_TYPE)malloc(sizeof(MC_VCP_CODE_TYPE));
memset(vcpCodeType, 0, sizeof(MC_VCP_CODE_TYPE));
bSuccess = GetVCPFeatureAndVCPFeatureReply(pPhysicalMonitors->hPhysicalMonitor, vcpCode, vcpCodeType, &curValue, &maxValue);
cout << "GetVCPFeatureAndVCPFeatureReply:" << bSuccess << endl;
DWORD dwStringLength = 0;
bSuccess = GetCapabilitiesStringLength(pPhysicalMonitors->hPhysicalMonitor, &dwStringLength);
if (bSuccess) {
LPSTR pCapabilitiesString = (LPSTR)malloc(dwStringLength);
if (pCapabilitiesString) {
bSuccess = CapabilitiesRequestAndCapabilitiesReply(pPhysicalMonitors->hPhysicalMonitor, pCapabilitiesString, dwStringLength);
if (bSuccess) {
std::string strCapabilities = pCapabilitiesString;
std::cout << strCapabilities << std::endl << std::endl;
}
}
}
}
DestroyPhysicalMonitors(cPhysicalMonitors, pPhysicalMonitors);
free(pPhysicalMonitors);
}
cout << "---------------------------------------" << endl;
return TRUE;
}
获取设置显示器的亮度,对比度等参数
static BOOL CALLBACK MonitorEnum(HMONITOR hMon, HDC hdc, LPRECT lprcMonitor, LPARAM pData)
{
cout << "hmonitor:" << hMon << endl;
MONITORINFOEX mi;
mi.cbSize = sizeof(mi);
GetMonitorInfo(hMon, (LPMONITORINFO)&mi);
wcout << "deviceName: " << mi.szDevice << endl;
DWORD cPhysicalMonitors;
BOOL bSuccess = GetNumberOfPhysicalMonitorsFromHMONITOR(hMon, &cPhysicalMonitors);
cout << "GetNumber: " << bSuccess << ", number of physical monitors: " << cPhysicalMonitors << endl;
LPPHYSICAL_MONITOR pPhysicalMonitors = (LPPHYSICAL_MONITOR)malloc(cPhysicalMonitors * sizeof(PHYSICAL_MONITOR));
if (pPhysicalMonitors != NULL)
{
bSuccess = GetPhysicalMonitorsFromHMONITOR(hMon, cPhysicalMonitors, pPhysicalMonitors);
cout << "GetPhysicalMonitor: " << bSuccess << endl
<< "Handle: " << pPhysicalMonitors->hPhysicalMonitor << endl
<< "Description: ";
wcout << (WCHAR*)(pPhysicalMonitors->szPhysicalMonitorDescription) << endl;
cout << (pPhysicalMonitors->hPhysicalMonitor) << endl;
if (bSuccess) {
BYTE vcpCode = 0xD6;
//bSuccess = SetVCPFeature(pPhysicalMonitors->hPhysicalMonitor, vcpCode, 0x1);
bSuccess = SetMonitorBrightness(pPhysicalMonitors->hPhysicalMonitor, 60);
cout << "SetMonitorBrightness:" << bSuccess << endl;
//try to get edid
int len = sizeof(DWORD);
cout << len << endl;
vcpCode = 0xDF;
DWORD curValue;
DWORD maxValue;
LPMC_VCP_CODE_TYPE vcpCodeType = (LPMC_VCP_CODE_TYPE)malloc(sizeof(MC_VCP_CODE_TYPE));
memset(vcpCodeType, 0, sizeof(MC_VCP_CODE_TYPE));
bSuccess = GetVCPFeatureAndVCPFeatureReply(pPhysicalMonitors->hPhysicalMonitor, vcpCode, vcpCodeType, &curValue, &maxValue);
cout << "GetVCPFeatureAndVCPFeatureReply:" << bSuccess << endl;
DWORD dwStringLength = 0;
bSuccess = GetCapabilitiesStringLength(pPhysicalMonitors->hPhysicalMonitor, &dwStringLength);
if (bSuccess) {
LPSTR pCapabilitiesString = (LPSTR)malloc(dwStringLength);
if (pCapabilitiesString) {
bSuccess = CapabilitiesRequestAndCapabilitiesReply(pPhysicalMonitors->hPhysicalMonitor, pCapabilitiesString, dwStringLength);
if (bSuccess) {
std::string strCapabilities = pCapabilitiesString;
std::cout << strCapabilities << std::endl << std::endl;
}
}
}
}
DestroyPhysicalMonitors(cPhysicalMonitors, pPhysicalMonitors);
free(pPhysicalMonitors);
}
cout << "---------------------------------------" << endl;
return TRUE;
}