显示器恢复出厂工具(成品 源码)
// test.cpp : 定义应用程序的入口点。//
#include "stdafx.h"
#include "test.h"
#include <PhysicalMonitorEnumerationAPI.h>
#include <HighLevelMonitorConfigurationAPI.h>
#pragmacomment(lib, "dxva2.lib")
int APIENTRY _tWinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
HMONITOR hMonitor = NULL;
DWORD cPhysicalMonitors;
LPPHYSICAL_MONITOR pPhysicalMonitors = NULL;
// Get the monitor handle.
hMonitor = MonitorFromWindow(GetDesktopWindow(), 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).
RestoreMonitorFactoryDefaults(pPhysicalMonitors->hPhysicalMonitor);
// Close the monitor handles.
bSuccess = DestroyPhysicalMonitors(
cPhysicalMonitors,
pPhysicalMonitors);
// Free the array.
free(pPhysicalMonitors);
}
}
return 0;
}
页:
[1]