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 )