VC Windows API应用之GetDesktopWindow ——获得桌面所有窗口句柄的方法
来源:互联网 发布:图标比例累加数据图 编辑:程序博客网 时间:2024/04/28 01:57
Windows API
Windows 这个多作业系统除了协调应用程序的执行、分配内存、管理资源…之外, 它同时也是一个很大的服务中心,调用这个服务中心的各种服务(每一种服务就是一个函数),可以帮应用程式达到开启视窗、描绘图形、使用周边设备等目的,由于这些函数服务的对象是应用程序(Application), 所以便称之为 Application Programming Interface,简称 API 函数。WIN32 API也就是Microsoft Windows 32位平台的应用程序编程接口。
GetDesktopWindow
函数功能:该函数返回桌面窗口的句柄。桌面窗口覆盖整个屏幕。桌面窗口是一个要在其上绘制所有的图标和其他窗口的区域。
函数原型:HWND GetDesktopWindow(VOID)
参数:无。
返回值:函数返回桌面窗口的句柄。
速查:Windows NT:3.1以上版本;Windows:95以上版本:;
头文件:Winuser.h;库文件:user32.lib。
【声明】
vb
Public Declare Function GetDesktopWindow Lib “user32” Alias “GetDesktopWindow” () As Long
vb_net
Public Declare Function GetDesktopWindow Lib “user32” Alias “GetDesktopWindow” () As Integer
c#
[DllImport(“user32.dll”, EntryPoint = “GetDesktopWindow”, CharSet = CharSet.Auto, SetLastError = true)]
static extern IntPtr GetDesktopWindow();
【说明】
获得代表整个屏幕的一个窗口(桌面窗口)句柄
【返回值】
Long,桌面窗口的句柄
获得桌面所有窗口句柄的方法
创建项目
文件->新建->项目…
编写方法
// GetDesktopWindow.cpp : 定义控制台应用程序的入口点。#include "stdafx.h"#define _AFXDLL#include <afxwin.h>//错误 1 error C1189: #error : Building MFC application with /MD[d] (CRT dll version) requires MFC shared dll version. //Please #define _AFXDLL or do not use /MD[d] e:\programfilesx86\microsoftvisualstudio10\vc\atlmfc\include\afx.h 24 1 GetDesktopWindowint _tmain(int argc, _TCHAR* argv[]){ //1.先获得桌面窗口 CWnd* pDesktopWnd = CWnd::GetDesktopWindow(); //2.获得一个子窗口 CWnd* pWnd = pDesktopWnd->GetWindow(GW_CHILD); //3.循环取得桌面下的所有子窗口 while(pWnd != NULL) { //获得窗口类名 CString strClassName = _T(""); ::GetClassName(pWnd->GetSafeHwnd(),strClassName.GetBuffer(256),256); //获得窗口标题 CString strWindowText = _T(""); ::GetWindowText(pWnd->GetSafeHwnd(),strWindowText.GetBuffer(256),256); //继续下一个子窗口 pWnd = pWnd->GetWindow(GW_HWNDNEXT); } return 0;}
- VC Windows API应用之GetDesktopWindow ——获得桌面所有窗口句柄的方法
- C# Windows API应用之GetDesktopWindow ——获得桌面所有窗口句柄的方法
- VC中获得窗口句柄的方法总结
- vc获得窗口句柄
- vc获得窗口句柄
- Sessions, Window Stations and Desktops(GetDesktopWindow函数得到的桌面句柄, 是Csrss.exe创建的一个窗口)
- Windows下获得窗口实例句柄的3种方法
- C# Windows API应用之FlashWindowEx ——实现窗口闪烁的方法
- 获得窗口句柄方法
- win32 API窗口句柄的获得——我的经验
- win32 API窗口句柄的获得——我的经验
- MFC获得窗口句柄的方法
- 窗口句柄的获得
- 窗口句柄的获得
- 窗口句柄的获得
- 窗口句柄的获得
- 窗口句柄的获得
- 窗口句柄的获得
- 第八章4次
- Spring Aop 日志拦截应用
- MySQL_5.1.50绿色版安装成服务的步骤
- 漫谈数据库锁
- Majority Element
- VC Windows API应用之GetDesktopWindow ——获得桌面所有窗口句柄的方法
- Maven多环境配置实战 filter
- Git教程:安装Git
- 什么叫敏捷开发?
- eclipse 快捷键
- Git教程:创建版本库
- 第五周项目1--深复制体验3
- 关于给TEXTVIEW加链接Linkify.addLinks点击访问的错误
- 3SumClosest