wmi query with advapi32.dll

Share your advanced PureBasic knowledge/code with the community.
User avatar
bingo
Enthusiast
Enthusiast
Posts: 210
Joined: Fri Apr 02, 2004 12:21 pm
Location: germany/thueringen
Contact:

wmi query with advapi32.dll

Post by bingo »

is undocumented but similar
IoWmiOpenBlock = WmiOpenBlock in advapi32.dll 8)
IoWmiQueryAllDataA = WmiQueryAllDataA ...

http://msdn.microsoft.com/en-us/library/aa490467.aspx

sample code ... (xp/vista)

Code: Select all

OpenLibrary(0, "advapi32.dll")

f1 = GetFunction(0,"WmiOpenBlock")
f2 = GetFunction(0,"WmiQueryAllDataA")
f3 = GetFunction(0,"WmiCloseBlock")

memsize.l = 5000
membuffer.l = AllocateMemory(memsize)

#WMIGUID_QUERY = 1

;init
Debug CallFunctionFast(f1,?MSSmBios_RawSMBiosTables,#WMIGUID_QUERY,@wmiblock.l)

;query
Debug CallFunctionFast(f2,wmiblock,@memsize,membuffer)

;close
Debug CallFunctionFast(f3,wmiblock)

CloseLibrary(0)

;save wmi-data
If CreateFile(0,"d:\wmi.bin")
WriteData(0,membuffer,memsize)
CloseFile(0)
EndIf

FreeMemory(membuffer)

End

DataSection ;test it
MSWmi_PnPDeviceId:
Data.l $c7bf35d2
Data.w $aadb,$11d1
Data.b $bf,$4a,$00,$a0,$c9,$06,$29,$10
MSSmBios_RawSMBiosTables:
Data.l $8f680850
Data.w $a584,$11d1
Data.b $bf,$38,$00,$a0,$c9,$06,$29,$10
MSDiskDriver_Geometry:
Data.l $25007f51
Data.w $57c2,$11d1
Data.b $a5,$28,$00,$a0,$c9,$06,$29,$10
EndDataSection
interesting... and read the wmicore.mof and wmidata.h from wdk !

test it : WmiQuerySingleInstance , WMIExecuteMethod :lol:
["1:0>1"]
User avatar
idle
Always Here
Always Here
Posts: 5919
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Post by idle »

I'm sure I'll want that someday and then I'll forget where to find it!
Post Reply