Re: Understanding WMI coding



Javan wrote:
Some short background. I took one semister of basic and C++ in school.
(classes taken in 94-95 just basic not VB and just C++ not Visual C++)
[...]
Set objShell = CreateObject("WScript.Shell")
variable=objShell.RegRead("registrykey")

Only having one semester of C++, they probably didn't cover any (or only
very few) object oriented techniques. (BTW, Visual C++ is just a
development environment, compiler, and debugger, not a different language)

If they covered structs in your C++ class but failed to mention classes
then take heart, a class (which you instantiate as an object) is nearly
the same except member vars can have multiple types and classes have
methods or member functions. There are scoping and typing differences
too, but we're already far enough off topic :)

So, in the above two lines of code, "objShell" is NOT a variable. It is
an object or instance of the Shell class. "RegRead" just happens to be
one method (out of many) in the "Shell" class; you can think of it as a
function if you wish but ppl will wonder ;) You can think of each
instance of an object as it's own namespace. Consider that
objShell.RegRead() is just a function with a String type argument that
returns a String (but you must use RegRead because the "variable" that
it reads inside objShell is private and you can't read it directly)

The main thing to consider is that WMI is not a language, it's an API
and object model, or collection of these classes and methods that you
use and manipulate through VB Scripting, or Perl, or Jscript, or even
C++ or ... Basically, learning WMI is analogous to learning what
stdio.cout << ""; or other things in the standard library do.

^
|
| [ But usually you would just "#include <stdio>;" ]
|_____[ and "using namespace std;" so as not to write ]
[ the "stdio." part every time. cout is ]
[ actually a method. ]

VBScript will, of course, be hiding these low level details from you but
the OO concepts of objects and their methods are the same. I think you
maybe almost knew all this before, but the semantics were getting in the
way. ;)

~Jason

--
.