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的使用的更多相关文章

  1. Microsoft Win32 to Microsoft .NET Framework API Map

    Microsoft Win32 to Microsoft .NET Framework API Map .NET Development (General) Technical Articles   ...

  2. C#[Win32&WinCE&WM]应用程序只能运行一个实例:MutexHelper

    前言 在开发应用程序时,通常只让程序运行一个实例.所以,就要判断程序是否已经运行. 下面是我自己在项目中使用到,封装好的帮助类.有 普通的 C# 应用程序 和 Windows CE 和 Windows ...

  3. java.lang.UnsatisfiedLinkError: %1 不是有效的 Win32 应用程序。

    JNA 调用 dll 库时,保错: ///////////////// 通过 JNA 引入 DLL 库 //////////// /** * ID_FprCap.dll 负责指纹的采集, 指纹仪的初始 ...

  4. 初次认识 C# win32 api

    第一次接触win32api,刚开始的时候有点迷迷糊糊的. Windows API 就是windows应用程序接口. win api向上就是windows应用程序,向下就是windows操作系统核心. ...

  5. [老文章搬家] [翻译] 深入解析win32 crt 调试堆

    09 年翻译的东西. 原文见:  http://www.nobugs.org/developer/win32/debug_crt_heap.html 在DeviceStudio的Debug编译模式下, ...

  6. Virus.Win32.Virlock.b分析

    0x00 样本说明 分析样本是被0b500d25f645c0b25532c1e3c9741667的样本感染得到.感染前的文件是Tcpview.exe,一款windows网络连接查看工具. 感染前后文件 ...

  7. cocos2d-x 从win32到android移植的全套解决方案

    引言:我们使用cocos2d-x引擎制作了一款飞行射击游戏,其中创新性地融入了手势识别功能.但是我们在移植过程中遇到了很多的问题,同时也发现网上的资料少而不全.所以在项目行将结束的时候,我们特地写了这 ...

  8. Git使用出错:Couldn‘t reserve space for cygwin‘s heap, Win32

    今天使用Git在命令行下更新代码遇到了问题,起初觉得是自己安装某软件导致冲突,从网上搜索了一下找到类似问题,成功解决问题. 错误信息如下: E:\storm-sql>git pull origi ...

  9. ATL封装IE内核启示:使用Win32/ATL建立窗口

    开发大型GUI界面程序MFC当仁不让,但如果是开发图形应用程序,并不需要大规模界面控件,没有必要链接庞大的MFC库,直接使用platform sdk会很麻烦,这时ATL中的关于Windows的封装就是 ...

  10. Win32 OpenProcess打开进程失败,返回5无权限操作

    Win32 OpenProcess打开进程失败,返回5无权限操作,相信你会碰到这样的事,在IDE中可以,单独却不可以了,其实这时就需要提权了,否则是无法打开的,OpenProcess提权至Debug即 ...

随机推荐

  1. [转帖]JMETER结果分析

    https://www.cnblogs.com/a00ium/p/10462892.html 我相信你同意:有很多方法可以收集和解释JMeter结果,你会感到迷茫. 嗯,看完这篇文章后,您将了解收集和 ...

  2. [转帖]JMeter 5.5 使用详解(持续更新中......)

    https://blog.csdn.net/qq_45138120/article/details/124056704?ops_request_misc=%257B%2522request%255Fi ...

  3. [转帖]Kafka关键参数设置

    https://www.cnblogs.com/wwcom123/p/11181680.html 生产环境中使用Kafka,参数调优非常重要,而Kafka参数众多,我们的java的Configurat ...

  4. [转帖]Debian9换源(阿里源)(Linux子系统)

    http://www.taodudu.cc/news/show-5410026.html?action=onClick 默认你已经装好Linux子系统. Step 0: 换源核心就是把/etc/apt ...

  5. css3只需一招,将网站变成灰色的

    今天大家在浏览B站,腾讯视频,等网站时,有没有发现一个现象,网站变成灰色的了. 是不是跟平常不一样了呢,这是因为今天(2020.4.4)是全国哀悼日, 所以网站这些就变成灰色的呢. 我去看了一下腾讯的 ...

  6. 【代码片段】fasthttp 中的输出使用 gzip 压缩

    作者:张富春(ahfuzhang),转载时请注明作者和引用链接,谢谢! cnblogs博客 zhihu Github 公众号:一本正经的瞎扯 直接上代码: import ( "github. ...

  7. TienChin 渠道管理-权限分配

    添加权限 如果您不想手动添加可以使用我如下的SQL,但是有一个注意点就是 parent_id 是渠道管理菜单的主键 id 即可一键插入. INSERT INTO `TienChin`.`sys_men ...

  8. 21.7 Python 使用Request库

    Request库可以用来发送各种HTTP请求,该框架的特点是简单易用,同时支持同步和异步请求,支持HTTP协议的各种方法和重定向.它还支持Cookie.HTTPS和认证等特性. Request库的使用 ...

  9. NFS实现部署Linux文件共享

    NFS 即网络文件系统,是一种使用于分布式文件系统的协议,由Sun公司开发,于1984年向外公布,功能是通过网络让不同的机器,不同的操作系统能够彼此分享各自的数据,让应用程序在客户端通过网络访问位于服 ...

  10. 尴尬:在zoom中找不到会议密码

    临时要开一个zoom会议,点击"新会议"进入,然后邀请其他与会者. "会议" - "复制邀请链接", 得到一行这样的信息(会议号已模糊处理) ...