Get information about the Windows API

Source: Internet
Author: User

1. Window information

MS provides us with a function to open a particular desktop and enumerate the desktop windows.

Hdesk = OpenDesktop (lpszdesktop, 0, FALSE, desktop_enumerate);

Open our default defaults desktop;

Enumdesktopwindows (Hdesk, (wndenumproc) enumwindowproc, 0);

Enumeration opens all windows on the desktop and is implemented by the callback function.

BOOL __stdcall Enumwindowproc (HWND, LPARAM);

In the callback function, we can get the title of the window and the related process, thread information;

GetWindowText (HWnd, Szwindowtext, Dwmaxcount);

GetWindowThreadProcessId (HWnd, &dwpid);

2. Device driver information (service and device driver similar, do not repeat here)

The device driver information is managed by the Service Control Manager (SCM), and I want to open the Service Control Manager and enumerate all the device drives.

OpenSCManager (null, NULL, sc_manager_all_access);

Open the Service Control Manager with all permissions;

EnumServicesStatus (Schmanager, Dwdevicetype, Dwdevicestate,

Enumstatus, Dwbufsize, &dwbytesneeded, &dwdevicesreturned, &dwresumehandle)

Enumerates the current status of all devices;

Closeservicehandle (Schmanager);

Remember to close the service handle at the end of the visit;

OpenService (Schmanager, Szdevicename, service_all_access);

Open a specific device drive;

QueryServiceConfig (Schdevice, Lpdeviceconfig, 1024 * 8, &dwbytesneeded);

Query the service configuration information of the drive;

QueryServiceStatus (Schdevice, &devicestatus);

Query the current status of the device driver;

QueryServiceConfig2 (Schdevice, Service_config_description, (LPBYTE) lpdevicedescription, 8*1024, &dwbytesneeded )

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.