//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
# include & lt; Comdef. H>
# include & lt; Wbemidl. H>
# include & lt; stdio.h>
# include & lt; Iostream>
# include & lt; string>
using namespace std;
Char * AllWmiClasses []=
{
"Win32_1394Controller,"
"Win32_BaseBoard,"
"Win32_Battery,"
"Win32_BIOS,"
"Win32_Bus,"
"Win32_CacheMemory,"
"Win32_CDROMDrive,"
"Win32_CurrentProbe,"
"Win32_DesktopMonitor,"
"Win32_DeviceMemoryAddress,"
"Win32_DiskDrive,"
"Win32_DisplayConfiguration,"
"Win32_DisplayControllerConfiguration,"
"Win32_DMAChannel,"
"Win32_Fan,"
"Win32_FloppyController,"
"Win32_FloppyDrive,"
"Win32_HeatPipe,"
"Win32_IDEController,"
"Win32_InfraredDevice,"
"Win32_IRQResource,"
"Win32_Keyboard,"
"Win32_MemoryArray,"
"Win32_MemoryDevice,"
"Win32_MotherboardDevice,"
"Win32_NetworkAdapter,"
"Win32_NetworkAdapterConfiguration,"
"Win32_OnBoardDevice,"
"Win32_ParallelPort,"
"Win32_PCMCIAController,"
"Win32_PhysicalMemory,"
"Win32_PhysicalMemoryArray,"
"Win32_PnPEntity,"
"Win32_PointingDevice,"
"Win32_PortableBattery,"
"Win32_PortConnector,"
"Win32_PortResource,"
"Win32_POTSModem,"
"Win32_PowerManagementEvent,"
"Win32_Printer,"
"Win32_PrinterConfiguration,"
"Win32_PrintJob,"
"Win32_Processor,"
"Win32_Refrigeration,"
"Win32_SerialPort,"
"Win32_SerialPortConfiguration,"
"Win32_SMBIOSMemory,"
"Win32_SoundDevice,"
"Win32_SystemEnclosure,"
"Win32_SystemMemoryResource,"
"Win32_SystemSlot,"
"Win32_TapeDrive,"
"Win32_TemperatureProbe,"
"Win32_UninterruptiblePowerSupply,"
"Win32_USBController,"
"Win32_VideoConfiguration,"
"Win32_VideoController,"
"Win32_VoltageProbe,"
NULL
};
Void GetWmiInfo (TStrings * lpList, WideString wsClass)
{
IWbemLocator * pWbemLocator=NULL;
If (CoCreateInstance (CLSID_WbemAdministrativeLocator, NULL, CLSCTX_INPROC_SERVER | CLSCTX_LOCAL_SERVER, IID_IUnknown, (void * *) & amp; PWbemLocator)==S_OK)
{
IWbemServices * pWbemServices=NULL;
UnicodeString wsNamespace=(L "root \ \ cimv2");
If (pWbemLocator - & gt; ConnectServer (wsNamespace c_str (), NULL, NULL, NULL, 0, NULL, NULL, & amp; PWbemServices)==S_OK)
{
IEnumWbemClassObject * pEnumClassObject=NULL;
UnicodeString wsWQL=L "WQL wsQuery=WideString" the Select * from "(L) + wsClass;
If (pWbemServices - & gt; ExecQuery (wsWQL c_str (), wsQuery c_str (), WBEM_FLAG_RETURN_IMMEDIATELY, NULL, & amp; PEnumClassObject)==S_OK)
{
IWbemClassObject * pClassObject=NULL;
ULONG uCount=1, uReturned;
If (pEnumClassObject - & gt; The Reset ()==S_OK)
{//MessageBox (NULL, "enter1" L, L "aabb", MB_OK);
Int iEnumIdx=0;
While (pEnumClassObject - & gt; Next (WBEM_INFINITE uCount, & amp; PClassObject, & amp; UReturned)==S_OK)
{
LpList - & gt; Add (" -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - [" + IntToStr (iEnumIdx) + "] -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- ");
//MessageBox (NULL, "enter2" L, L "aab", MB_OK);
SAFEARRAY * pvNames=NULL;
If (pClassObject - & gt; GetNames (NULL, WBEM_FLAG_ALWAYS | WBEM_MASK_CONDITION_ORIGIN, NULL, & amp; PvNames)==S_OK)
{
Long VBL, vbu;
SafeArrayGetLBound (pvNames, 1, & amp; VBL);
SafeArrayGetUBound (pvNames, 1, & amp; Vbu);
For (long independence idx=VBL; Idx<=vbu; Idx++)
{
Long aidx=independence idx;
Would be * wsName=0;
The VARIANT vValue;
VariantInit (& amp; VValue);
SafeArrayGetElement (pvNames, & amp; Aidx, & amp; WsName);
BSTR bs=SysAllocString (wsName);
HRESULT hRes=pClassObject - & gt; Get (bs, 0, & amp; VValue, NULL, 0);
SysFreeString (bs);
If (hRes==S_OK)
{
AnsiString s;
The Variant v=* (Variant *) & amp; VValue;
If (v.I sArray ())
{
For (int I=says v. rrayLowBound (); I