I am currently looking to replace all my code that uses WMI with equivalent win32 api calls. I am doing this because i have noticed that WMI calls take much longer to perform than win32 api calls. Some examples can be seen below:
Listing services:
Listing Printers:
Listing Windows Users:
Is it possible to replace all wmi calls? As a general rule, is every task available in WMI possible to perform with winapi calls?
I have already managed to replace most of my wmi code but i have the following left:
I am having some difficulty with enumerating network adapters in particular.
Its also worth mentioning that i am using python (2.7) to perform all these calls (using ctypes, windll and win32 api libraries such as win32net, win32service etc...).
Q: Is it possible to replace all wmi calls?
A: Most of the WMI queries can be replaced with WinAPI methods, with a few exceptions.
Q: As a general rule, is every task available in WMI possible to perform with winapi calls?
A: No, not all the WMI classes have WinAPI equivalents. For example, the IIS related tasks only can be performed using the IIS WMI Provider. Also, there are no WinAPI methods to enumerate the restore points, and so on.
For you pending tasks you can use these WinAPI methods:
GetAdaptersInfo
functionDeviceIoControl
method with the IOCTL_DISK_GET_DRIVE_LAYOUT_EX control code