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
Create a project by getting all the window handles on the desktop
New project, File--...
Writing methods
//GetDesktopWindow.cpp: Defines the entry point of the console application. #include "stdafx.h"#define _afxdll#include <afxwin.h>Errors 1 Error C1189: #error: Building MFC Application With/md[d] (CRT DLL version) requires MFC shared DLL vers Ion. //please #define _afxdll or do 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. Obtaining a child windowcwnd* pWnd = Pdesktopwnd->getwindow (gw_child);//3. Loop to get all child windows under the desktop while(pWnd! = NULL) {//Get 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 next child windowPWnd = Pwnd->getwindow (Gw_hwndnext); }return 0;}
VC Windows API App getdesktopwindow--get desktop all window handle method