This is a small program I made. It shows data from every WMI class.
Get it from: http://kc2000labs.shadowtavern.com/pb/z ... r_4.41.zip
WMI Reader
- doctorized
- Addict
- Posts: 882
- Joined: Fri Mar 27, 2009 9:41 am
- Location: Athens, Greece
WMI Reader
Last edited by doctorized on Sat Jan 14, 2017 12:07 pm, edited 1 time in total.
- doctorized
- Addict
- Posts: 882
- Joined: Fri Mar 27, 2009 9:41 am
- Location: Athens, Greece
Re: WMI Reader
This app deals with a small problem. Procedure bstr2string is not returning right letters with
ascii 184 to 255. Any suggestions?
ascii 184 to 255. Any suggestions?
Re: WMI Reader
Try :
When converting to/from Ansi/Unicode you should use combinations of PokeS() and PeekS() because these will take the current Ansi code-page into account etc. Your methods of poking individual 16-bit values will not do this and will produce incorrect results (as you discovered) for character codes in excess of 127 (Ascii).
Code: Select all
Procedure bstr2string (bstr)
Shared result.s
result = PeekS(bstr, -1, #PB_Unicode)
ProcedureReturn @result
EndProcedure
I may look like a mule, but I'm not a complete ass.
- doctorized
- Addict
- Posts: 882
- Joined: Fri Mar 27, 2009 9:41 am
- Location: Athens, Greece
Re: WMI Reader
Thanx a lot again! The problem got solved. I made a small change to accept a bigger range of custom WMI classes to run.srod wrote:Try :Code: Select all
Procedure bstr2string (bstr) Shared result.s result = PeekS(bstr, -1, #PB_Unicode) ProcedureReturn @result EndProcedure
(Now it can run expresions like: 'Select Caption from Win32_cdromdrive')
- netmaestro
- PureBasic Bullfrog
- Posts: 8451
- Joined: Wed Jul 06, 2005 5:42 am
- Location: Fort Nelson, BC, Canada
Re: WMI Reader
Very fine contribution! Code is useful and well explained, thanks so much for this. 

BERESHEIT
- doctorized
- Addict
- Posts: 882
- Joined: Fri Mar 27, 2009 9:41 am
- Location: Athens, Greece
Re: WMI Reader
I believe that "knowledge is for everyone and must be for free". Enjoy!netmaestro wrote:Very fine contribution! Code is useful and well explained, thanks so much for this.
- doctorized
- Addict
- Posts: 882
- Joined: Fri Mar 27, 2009 9:41 am
- Location: Athens, Greece
Re: WMI Reader
If I compile my code in Unicode then it fails to run, MessageRequester "unable to call IWbemLocator::ConnectServer" pops up.
Does anyone know why? It must have to do with the "root\cimv2" string that is passed as variable but how can it be fixed?
Edit
PROBLEM SOLVED.
See the new code that supports unicode and non-unicode compilation.
Does anyone know why? It must have to do with the "root\cimv2" string that is passed as variable but how can it be fixed?
Edit
PROBLEM SOLVED.
See the new code that supports unicode and non-unicode compilation.