VC Windows API Get the Desktop all window handle method

Source: Internet
Author: User
Tags function prototype

VC Windows API App getdesktopwindow--get desktop all window handle method

Windows API

In addition to coordinating application execution, allocating memory, managing resources, Windows is a multi-job system ... , it is also a large service center, invoking the service center of the various services (each service is a function), can help the application to open windows, graphics, use peripheral devices, and so on, because these functions serve the object is the application (application), so called Application programming Interface, referred to as API functions. The WIN32 API is the application programming interface for Microsoft Windows 32-bit platforms.

GetDesktopWindow

function Function: This function returns the handle of the desktop window. The desktop window covers the entire screen. The desktop window is an area on which you want to draw all the icons and other windows.
function prototype : HWND GetDesktopWindow (VOID)
parameter : None.
return value : The function returns a handle to the desktop window.
Quick Check : Windows nt:3.1 or above version; windows:95 or above version:;
header file : Winuser.h; library file: User32.lib.
"declaration"
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 ();

"description"
Get a window (desktop window) handle representing the entire screen
"return value"
Long, handle to the desktop window

How to get all the window handles on the desktop Create a project

New project, File--...

Writing methods
//GetDesktopWindow.cpp: Defines the entry point of the console application. #include"stdafx.h"#define_afxdll#include<afxwin.h>//how to ask Hovertree.com//Err 1 Error C1189: #error: Building MFC Application With/md[d] (CRT DLL version) requires MFC shared DLL Versi On. //Please #define _afxdll or does not use/md[d] e:\programfilesx86\microsoftvisualstudio10\vc\atlmfc\include\afx.h 24 1 GetDesktopWindowint_tmain (intARGC, _tchar*argv[]) {    //1. Get the desktop window firstcwnd* Pdesktopwnd =Cwnd::getdesktopwindow (); //2. Get a sub-windowcwnd* pWnd = pdesktopwnd->GetWindow (Gw_child); //3. Loop through all child windows under the desktop         while(PWnd! =NULL) {            //get the window class nameCString strClassName = _t (""); :: GetClassName (PWnd->getsafehwnd (), Strclassname.getbuffer ( the), the); //Get window titleCString Strwindowtext = _t (""); :: GetWindowText (PWnd->getsafehwnd (), Strwindowtext.getbuffer ( the), the); //continue to the next child windowPWnd = pwnd->GetWindow (Gw_hwndnext); }    return 0;}

Recommendation: http://www.cnblogs.com/roucheng/p/3456005.html

Http://www.cnblogs.com/roucheng/p/wendang.html

VC Windows API Get the Desktop all window handle method

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.