?
Solved

Programmatically Identifying difference between Desktop and Laptop

Posted on 2004-09-23
2
Medium Priority
?
1,035 Views
Last Modified: 2008-02-01
Does anyone know if there might be a way to identify the difference between a desktop and a laptop programmatically.
I'm open to any suggestion using WMI, WSH, Registry, Files, etc. (even external apps).
0
Comment
Question by:xy15973
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 3

Expert Comment

by:thunder_moose
ID: 12131367
Hi there,

Yes this is possible with WMI. The code to do it is as follows:

Dim oEnclosures, oEnclosure, iEncType

Set oEnclosures = GetObject("winmgmts:").InstancesOf("Win32_SystemEnclosure")
For Each oEnclosure In oEnclosures
     iEncType = oEnclosure.ChassisTypes(0)
     If num = 3 then
        MsgBox "This is a desktop"
     Else
        If Num = 9 Then MsgBox "This is a laptop"
     End If
Next

The values for Enclose type is as follows:
1 = Other
2 = Unknown
3 = Desktop
4 = Low Profile Desktop
5 = Pizza Box
6 = Mini Tower
7 = Tower
8 = Portable
9 = Laptop
10 = Notebook
11 = Hand Held
12 = Docking Station
13 = All in One
14 = Sub Notebook
15 = Space-Saving
16 = Lunch Box
17 = Main System Chassis
18 = Expansion Chassis
19 = Sub Chassis
20 = Bus Expansion Chassis
21 = Peripheral Chassis
22 = Storage Chassis
23 = Rack Mount Chassis
24 = Sealed-Case PC

So you might have to change it to something like
If num >= 7 Then Desktop
If (num >=8) and (num <= 14) Then Laptop
Or something to that effect.

To run, paste in a text file, tweak to your liking, save as .vbs and run from the command line with: cscript filename.vbs

Hope that helps,
TM
0
 
LVL 1

Accepted Solution

by:
martin_watts earned 2000 total points
ID: 12131429
There are two differences between desktops and laptops that are quite easy to detect. One is the presence of a PCMIA slot, the other is the existence of multiple hardware configurations (docked and undocked).

The existence of PCMIA ports is probably the easiest to detect. In the registry, you can look for the key HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\PCMIA. If it exists, the machine has PCMIA ports and therefor must be a laptop.

You can also look in HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Pcmia. This key exists on both desktops and laptops, but the latter have a subkey for each enabled PCMIA slot (0000, 0001, 0002 etc.)

Note that the above mentioned keys exist on a Windows NT/2000 system. On older Windows 98 type systems, the keys you would be looking for could be stored differently.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month14 days, 20 hours left to enroll

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question