Page 1 of 1

WMI Reader

Posted: Fri May 28, 2010 9:28 pm
by doctorized
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

Re: WMI Reader

Posted: Sat May 29, 2010 10:46 am
by srod
Nice. Could be useful.

Thanks. :)

Re: WMI Reader

Posted: Sat May 29, 2010 11:13 am
by doctorized
This app deals with a small problem. Procedure bstr2string is not returning right letters with
ascii 184 to 255. Any suggestions?

Re: WMI Reader

Posted: Sat May 29, 2010 11:32 am
by srod
Try :

Code: Select all

Procedure bstr2string (bstr)
  Shared result.s
  result = PeekS(bstr, -1, #PB_Unicode)
  ProcedureReturn @result
EndProcedure
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).

Re: WMI Reader

Posted: Sat May 29, 2010 12:44 pm
by doctorized
srod wrote:Try :

Code: Select all

Procedure bstr2string (bstr)
  Shared result.s
  result = PeekS(bstr, -1, #PB_Unicode)
  ProcedureReturn @result
EndProcedure
Thanx a lot again! The problem got solved. I made a small change to accept a bigger range of custom WMI classes to run.
(Now it can run expresions like: 'Select Caption from Win32_cdromdrive')

Re: WMI Reader

Posted: Sat May 29, 2010 1:19 pm
by netmaestro
Very fine contribution! Code is useful and well explained, thanks so much for this. 8)

Re: WMI Reader

Posted: Sat May 29, 2010 1:34 pm
by doctorized
netmaestro wrote:Very fine contribution! Code is useful and well explained, thanks so much for this. 8)
I believe that "knowledge is for everyone and must be for free". Enjoy!

Re: WMI Reader

Posted: Mon May 31, 2010 8:36 am
by bingo
:D thanks from germany!

Re: WMI Reader

Posted: Fri Feb 11, 2011 3:05 pm
by doctorized
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.