Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How Do I convert a string to an objects name? 1

Status
Not open for further replies.

DTJeff

Programmer
Dec 9, 2003
37
0
0
GB
Hi,

I'm currently writing a WMI application to retrieve information from a remote machine.

As part of this, I'd quite like to create the "core" of the application without any of the WMI querys etc in the app, but rather have them called from an external database, so that extra functions could be added just by adding records to the database.

This leaves me with one problem - How do I convert a string to an objects name.

Heres my code:
Code:
Dim objWMI
Dim colCurrentClass
Dim objCurrentClass
Dim strComputer As String
Dim intTotalMemory As Integer
strComputer = Me.TextBox2.Text
objWMI = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
colCurrentClass = objWMI.ExecQuery("Select * from  Win32_CDROMDrive")
For Each objCurrentClass In colCurrentClass
TextBox1.Text = TextBox1.Text & vbCrLf & "CDROM:" & vbCrLf
TextBox1.Text = TextBox1.Text & vbCrLf "Caption:" & objCurrentClass.caption
Next
The bits I need to retrieve would be the wmi string, the wmi sql query (both of which i have no problems doing), but how would I convert a string which says "Caption" into the objCurrentClass.caption object?

Thanks.

Jeff.
 
mmmm,

That kind of works, but it means that I have to compile everything into a dll file, which would kind of negate the my main point. I really want the data held in a database, mainly so that an end user could add new items if they wanted to (and knew about wmi).

I'm sure there must be a way to do it. (or am i missing something from that page?)
 
why compile into a dll?

Christiaan Baes
Belgium

If you want to get an answer read this FAQ faq796-2540
There's no such thing as a winnable war - Sting
 
Ah - My fault! (doh!)

I mistook the "reference &= "interfaces.dll"" line and didnt read it properly - sorry!

(note to self - read information properly in future :) )

Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top