win32 - EnumDisplayDevices和EnumDisplayMonitors的使用
EnumDisplayDevices枚举适配器
EnumDisplayMonitors枚举监视器
#pragma comment(lib, "dxva2.lib")
#include <windows.h>
#include <lowlevelmonitorconfigurationapi.h>
#include <physicalmonitorenumerationapi.h>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <highlevelmonitorconfigurationapi.h>
#include <vector> using namespace std; void D(HANDLE hPhysicalMonitor)
{
DWORD cchStringLength = 0;
BOOL bSuccess = 0;
LPSTR szCapabilitiesString = NULL; // Get the length of the string.
bSuccess = GetCapabilitiesStringLength(
hPhysicalMonitor, // Handle to the monitor.
&cchStringLength
);
int err = GetLastError(); if (bSuccess)
{
// Allocate the string buffer.
LPSTR szCapabilitiesString = (LPSTR)malloc(cchStringLength);
if (szCapabilitiesString != NULL)
{
// Get the capabilities string.
bSuccess = CapabilitiesRequestAndCapabilitiesReply(
hPhysicalMonitor,
szCapabilitiesString,
cchStringLength
);
cout << szCapabilitiesString << endl;
// Free the string buffer.
free(szCapabilitiesString);
}
}
} static BOOL CALLBACK MonitorEnum(HMONITOR hMon, HDC hdc, LPRECT lprcMonitor, LPARAM pData)
{
cout << "hmonitor:" << hMon << 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));
bSuccess = GetPhysicalMonitorsFromHMONITOR(hMon, cPhysicalMonitors, pPhysicalMonitors);
cout << "GetPhysicalMonitor: " << bSuccess << endl
<< "Handle: " << pPhysicalMonitors->hPhysicalMonitor << endl
<< "Description: ";
wcout << (WCHAR*)(pPhysicalMonitors->szPhysicalMonitorDescription) << endl;; D(pPhysicalMonitors->hPhysicalMonitor); DestroyPhysicalMonitors(cPhysicalMonitors, pPhysicalMonitors);
free(pPhysicalMonitors); cout << "---------------------------------------" << endl; return TRUE;
} void A()
{
HWND hWnd = GetDesktopWindow();
EnumDisplayMonitors(0, 0, MonitorEnum, NULL);
HMONITOR hMonitor = MonitorFromWindow(hWnd, MONITOR_DEFAULTTOPRIMARY);
cout << "---------------------------------------" << endl;
cout << "Monitor: " << hMonitor << endl; } void B()
{
DWORD DispNum = 0;
DISPLAY_DEVICE DisplayDevice;
// Initialize DisplayDevice.
ZeroMemory(&DisplayDevice, sizeof(DisplayDevice));
DisplayDevice.cb = sizeof(DisplayDevice); while ((EnumDisplayDevices(NULL, DispNum, &DisplayDevice, 0)))
{
std::wstring deviceName = DisplayDevice.DeviceName;
DISPLAY_DEVICE DisplayDeviceM;
ZeroMemory(&DisplayDeviceM, sizeof(DisplayDeviceM));
DisplayDeviceM.cb = sizeof(DisplayDeviceM);
int monitorIndex = 0;
while (EnumDisplayDevices(deviceName.c_str(), monitorIndex, &DisplayDeviceM, EDD_GET_DEVICE_INTERFACE_NAME))
{
std::wstring monitorID = DisplayDeviceM.DeviceID;
wcout <<"monitorID :"<< monitorID<< endl;
++monitorIndex;
}
DispNum++;
}
cout << "---------------------------------------" << endl;
} int main()
{
B(); A(); getchar(); return 0;
}
win32 - EnumDisplayDevices和EnumDisplayMonitors的使用的更多相关文章
- Microsoft Win32 to Microsoft .NET Framework API Map
Microsoft Win32 to Microsoft .NET Framework API Map .NET Development (General) Technical Articles ...
- C#[Win32&WinCE&WM]应用程序只能运行一个实例:MutexHelper
前言 在开发应用程序时,通常只让程序运行一个实例.所以,就要判断程序是否已经运行. 下面是我自己在项目中使用到,封装好的帮助类.有 普通的 C# 应用程序 和 Windows CE 和 Windows ...
- java.lang.UnsatisfiedLinkError: %1 不是有效的 Win32 应用程序。
JNA 调用 dll 库时,保错: ///////////////// 通过 JNA 引入 DLL 库 //////////// /** * ID_FprCap.dll 负责指纹的采集, 指纹仪的初始 ...
- 初次认识 C# win32 api
第一次接触win32api,刚开始的时候有点迷迷糊糊的. Windows API 就是windows应用程序接口. win api向上就是windows应用程序,向下就是windows操作系统核心. ...
- [老文章搬家] [翻译] 深入解析win32 crt 调试堆
09 年翻译的东西. 原文见: http://www.nobugs.org/developer/win32/debug_crt_heap.html 在DeviceStudio的Debug编译模式下, ...
- Virus.Win32.Virlock.b分析
0x00 样本说明 分析样本是被0b500d25f645c0b25532c1e3c9741667的样本感染得到.感染前的文件是Tcpview.exe,一款windows网络连接查看工具. 感染前后文件 ...
- cocos2d-x 从win32到android移植的全套解决方案
引言:我们使用cocos2d-x引擎制作了一款飞行射击游戏,其中创新性地融入了手势识别功能.但是我们在移植过程中遇到了很多的问题,同时也发现网上的资料少而不全.所以在项目行将结束的时候,我们特地写了这 ...
- Git使用出错:Couldn‘t reserve space for cygwin‘s heap, Win32
今天使用Git在命令行下更新代码遇到了问题,起初觉得是自己安装某软件导致冲突,从网上搜索了一下找到类似问题,成功解决问题. 错误信息如下: E:\storm-sql>git pull origi ...
- ATL封装IE内核启示:使用Win32/ATL建立窗口
开发大型GUI界面程序MFC当仁不让,但如果是开发图形应用程序,并不需要大规模界面控件,没有必要链接庞大的MFC库,直接使用platform sdk会很麻烦,这时ATL中的关于Windows的封装就是 ...
- Win32 OpenProcess打开进程失败,返回5无权限操作
Win32 OpenProcess打开进程失败,返回5无权限操作,相信你会碰到这样的事,在IDE中可以,单独却不可以了,其实这时就需要提权了,否则是无法打开的,OpenProcess提权至Debug即 ...
随机推荐
- [转帖]datax安装+配置+使用文档
1 DataX离线同步工具DataX3.0介绍 DataX 是阿里巴巴集团内被广泛使用的离线数据同步工具/平台,实现包括 MySQL.Oracle.SqlServer.Postgre.HDFS.Hiv ...
- [转帖]tidb关闭sql_mode=ONLY_FULL_GROUP_BY模式
报错: 1 of ORDER BY clause is not in SELECT list, references column 'xxx' which is not in SELECT list ...
- [转帖]《Linux性能优化实战》笔记(十九)—— DNS 解析原理与故障案例分析
一. 域名与 DNS 解析 域名主要是为了方便让人记住,而 IP 地址是机器间的通信的真正机制.以 time.geekbang.org 为例,最后面的 org 是顶级域名,中间的 geekbang 是 ...
- [转帖]Jmeter脚本录:抓取https请求
Jmeter抓取http请求 https://blog.csdn.net/qq19970496/article/details/86595109 代理设置步骤请参照该篇文章.本文件只做补充HTTPS中 ...
- 【转帖】【笔记】python连接神通数据库
https://www.cnblogs.com/wyongbo/p/17054924.html python连接国产神州通用数据库. 一.准备 下载whl及dll: 链接: https://pan.b ...
- [转帖]关于iostat的问题,svctm数据不可信
使用FIO对磁盘进行压力测试,使用1个线程对磁盘进行随机读,设置单次read的数据块分别为128KB和1M,数据如下: (1)单次IO数据块为128KB (2)单次IO数据块为1M 从上面的数据可以看 ...
- [转帖]【JVM】类文件结构
Class文件的定义 一组以8字节为基础单位的二进制流, 各个数据项目严格按照顺序紧凑排列在class文件中, 中间没有任何分隔符,这使得class文件中存储的内容几乎是全部程序运行的程序. 注:Ja ...
- 记录一次RPC服务有损上线的分析过程
1. 问题背景 某应用在启动完提供JSF服务后,短时间内出现了大量的空指针异常. 分析日志,发现是服务依赖的藏经阁配置数据未加载完成导致.即所谓的有损上线或者是直接发布,当应用启动时,service还 ...
- NutUI 4.0 正式发布!
作者: 京东零售 NutUI NutUI 4.0 Github 地址:github.com/jdf2e/nutui NutUI 4.0 官网:nutui.jd.com 前言 技术日异月新.发展创新.持 ...
- 【计数,DP】ABC306Ex Balance Scale
Problem Link 现在有 \(n\) 个球,每个球有一个重量,重量未知.接下来会进行 \(m\) 次称重,每次给定 \(a_i\) 和 \(b_i\),比较这两个球的重量,结果可能是 \(&g ...