VB6 Get System Model

Hello Experts,

I am using VB6 and I am trying to get the system model #. Similar to http://www.freevbcode.com/ShowCode.asp?ID=4571 but for VB6.

Thoughts?
triphenAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Martin LissOlder than dirtCommented:
As you've shown in the URL and some research by me shows that that's possible in VB.Net but I don't believe it's possible in VB6.
0
triphenAuthor Commented:
I am looking real hard, it looks like it's possible. I just someone to point me in the right direction...
0
Martin LissOlder than dirtCommented:
it looks like it's possible
If you can tell me why you think that, maybe I can help you look.
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

Martin LissOlder than dirtCommented:
This is a modification of something I found on the web.

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_ComputerSystem")
For Each objItem In colItems
     Debug.Print "System Name: " & objItem.Name
     Debug.Print "Manufacturer: " & objItem.Manufacturer
     Debug.Print "Model: " & objItem.Model
Next

Open in new window

0
triphenAuthor Commented:
Set objWMIService = GetObject("winmgmts:\\ComputerName\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_ComputerSystem")
For Each objItem In colItems
     Debug.Print "System Name: " & objItem.Name
     Debug.Print "Manufacturer: " & objItem.Manufacturer
     Debug.Print "Model: " & objItem.Model
Next

Open in new window


Produces error:   Compile error: Variable not defined

On: objWMIService
0
Martin LissOlder than dirtCommented:
You can either do

Dim objWMIService

or comment out Option Explicit
0
Martin LissOlder than dirtCommented:
This is better

Dim objWMIService
Dim colItems
Dim objItem
Set objWMIService = GetObject("winmgmts:\\" & "." & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_ComputerSystem")
For Each objItem In colItems
     Debug.Print "System Name: " & objItem.Name
     Debug.Print "Manufacturer: " & objItem.Manufacturer
     Debug.Print "Model: " & objItem.Model
Next

Set objWMIService = Nothing
Set colItems = Nothing

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
triphenAuthor Commented:
Got it!

  Dim info As Object
    Dim cpus_query As String
    Dim cpus_results As Object

    cpus_query = "SELECT * FROM Win32_ComputerSystem"
    Set cpus_results = _
        GetObject("Winmgmts:").ExecQuery(cpus_query)
   For Each info In cpus_results

     MsgBox (info.Model)

Open in new window

0
Martin LissOlder than dirtCommented:
The source for the above was this article.
0
Martin LissOlder than dirtCommented:
Mine works to so I hope your kind enough to accept my answer.
0
Martin LissOlder than dirtCommented:
Thanks.

In my profile you'll find links to some articles I've written that may interest you.
Marty - MVP 2009 to 2015, Experts-Exchange Top Expert Visual Basic Classic 2012 to 2014
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.