The sample is made to be reusable and generate a report on various options.
The more difficult part is to find the root on the propertie we want modifie.
answer is given by the tooltips of WMI Tools\browser.htm,left panel .
Quote
********** IWbemServices ExecMethod strObjectPath ********
\\HARENG\root\cimv2:Win32_ComputerSystem.Name="HARENG"
and not only Win32_ComputerSystem
thanks Yves
always interested in a WMI example :P
Want More ?
download Scriptomatic version 2
the Win32_InstalledSoftwareElement give you all is installed on your computer (17400 lines on my computer)
Here the piece of code modify
Quote
;################################################################
Use_Object_Method PROC pobject:DWORD,pmethod:DWORD
Local phrase[400h]:BYTE
Local ObjPath:DWORD,langage,query
Local retour:DWORD ;,System,Software
mov retour,0
;no need of the object
;prepare to read propertie value
;SADR("\\HERISSON\ROOT\CIMV2:Win32_InstalledSoftwareElement.Software")
invoke MultiByteToWideChar,CP_ACP,NULL,SADR("Software"),-1,addr Software,LENGTHOF Software
lea edx,Software
invoke MultiByteToWideChar,CP_ACP,NULL,SADR("System"),-1,addr System,LENGTHOF System
lea edx,System
mov langage,BSTR("WQL")
;------ query ------------------
invoke lstrcpy,addr phrase,SADR("SELECT * FROM ")
invoke lstrcat,addr phrase,pobject ;Win32_InstalledSoftwareElement
invoke CreateBstr,addr phrase
mov query,eax
IWbemServices ExecQuery,langage,query,\
WBEM_FLAG_FORWARD_ONLY OR WBEM_FLAG_RETURN_IMMEDIATELY,\
NULL,addr pEnumerator ;IEnumWbemClassObject
NextEnumerator:
COM pEnumerator,Next,WBEM_INFINITE, 1,addr InstallEntry,addr retour ;IWbemClassObject
.if retour != 0
.if InstallEntry != 0
;invoke GenerateReportOnProperties change InstallEntry
;COM InstallEntry,Release
;jmp suite
invoke VariantInit,addr variant
COM InstallEntry,Get,addr Software,NULL,addr variant,NULL,NULL
.if eax == WBEM_S_NO_ERROR
jmp OKSoftware
.elseif eax == WBEM_E_FAILED; There is a general failure.
mov edx,0
.elseif eax == WBEM_E_NOT_FOUND ;The specified property is not found.
mov edx,0
.elseif eax == WBEM_E_OUT_OF_MEMORY ;There is not enough memory to complete the operation.
mov edx,0
.elseif eax == WBEM_E_INVALID_PARAMETER; One or more parameters is not valid.
mov edx,0
.endif
OKSoftware:
lea edx,variant
mov edx,variant.n1.n2.n3.bstrVal
invoke UtoA,variant.n1.n2.n3.bstrVal
invoke lstrcpy,addr phrase,SADR("Software: ")
invoke lstrcat,addr phrase,addr buffer
invoke lstrcat,addr phrase,addr retourligne
invoke EcrireRapport,ADDR phrase
invoke VariantClear,addr variant
;-------------------------------------------------------
comment µ
invoke VariantInit,addr variant
COM InstallEntry,Get,addr System,NULL,addr variant,NULL,NULL
invoke UtoA,variant.n1.n2.n3.bstrVal
invoke lstrcpy,addr phrase,SADR("System: ")
invoke lstrcat,addr phrase,addr buffer
invoke lstrcat,addr phrase,addr retourligne
invoke EcrireRapport,ADDR phrase
invoke VariantClear,addr variant
invoke EcrireRapport,addr retourligne
invoke VariantClear,addr variant
µ
COM InstallEntry,Release
mov InstallEntry,0
.endif
jmp NextEnumerator
.endif
suite:
COM pEnumerator,Release
comment µ
report on properties for InstallEntry = Software System
***All properties***
__PATH
__NAMESPACE
__SERVER
__DERIVATION
__PROPERTY_COUNT
__RELPATH
__DYNASTY
__SUPERCLASS
__CLASS
__GENUS
Software
System
***properties WBEM_FLAG_KEYS_ONLY ***
Software
System
***properties WBEM_FLAG_REFS_ONLY ***
Software
System
***properties WBEM_FLAG_CLASS_OVERRIDES_ONLY ***
***properties WBEM_FLAG_CLASS_LOCAL_AND_OVERRIDES ***
***properties WBEM_MASK_CLASS_CONDITION ***
***properties WBEM_FLAG_LOCAL_ONLY ***
Software
System
***properties WBEM_FLAG_PROPAGATED_ONLY ***
µ
invoke ViewRapport
closeall:
IWbemServices Release
IWbemLocator Release
invoke FreeBSTR
FindeUse_Object_Method:
mov eax,retour
ret
Use_Object_Method endp
yikes !
COM and BSTR's together !!!!
a masm programmer's nightmare :red
DAVE !!!
OK,...HUMONGEOUS LOL,...
Quote from: DAVECOM and BSTR's together !!!!
...a masm programmer's nightmare,...
DANG !!! Up until you pointed that out,...I think I was the OFFICIAL 'masm programmer's nightmare',...
...sputter,...sputter,...tremors and severly damaged ego,... :eek
well - it's probably not all that bad for Yves and other experienced programmers
just a bit over my head, for now
i will get there, some day :P
when the time comes that i want to do something that requires COM - i will dig into it