469,106 Members | 2,353 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,106 developers. It's quick & easy.

Detecting IDE Devices in Visual Basic Help

hi,

i am trying to make a very simple program that will just detect
and output your currently connected IDE devices. It will look
something like this:

IDE PRIMARY MASTER:
IDE PRIMARY SLAVE:

IDE SECONDARY MASTER:
IDE SECONDARY SLAVE:

And it will just show you what you have connected.
I have been researching for hours and hours for how to
do this and I've come up with NOTHING!

Is this even possible?

I know what you're going to say, why do that when you
can just see the same information in your BIOS when
your computer boots up. I know I can do that, but
I want a way to do it in windows.

Any and all help you can give me (no matter how small), even
a push in the right direction will be appreciated.

Thanks for your help.

-jasper
Jul 17 '05 #1
1 2790
"jasper" <sd**********@as9df7as9df7.com> wrote

i am trying to make a very simple program that will just detect
and output your currently connected IDE devices. It will look
something like this:

IDE PRIMARY MASTER:
IDE PRIMARY SLAVE:

IDE SECONDARY MASTER:
IDE SECONDARY SLAVE:

And it will just show you what you have connected.
I have been researching for hours and hours for how to
do this and I've come up with NOTHING!

Is this even possible?

This should get you started. It may have more than you wanted
to know about your drives, but it was basically a copy and paste
from a scripting resource. Take note of the ExecQuery, as it is
'similar' to SQL (a _small_ subset, to say the least) so that you can
tailor the query to return just the properties you want, or include
a WHERE clause to return just those whose InterfaceType is IDE,
etc....

Paste the code below into a Form, add a button and remove
Option Explicit, if present. (Not advised, but for the demo....)
For further studies, locate tutorials on WMI scripting.

LFS

Private Sub Command1_Click()

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colDiskDrives = objWMIService.ExecQuery _
("SELECT * FROM Win32_DiskDrive")

For Each objDiskDrive In colDiskDrives
Debug.Print vbCrLf

' Might these be what you want?
Debug.Print "Caption: " & objDiskDrive.Caption
Debug.Print "Interface Type: " & objDiskDrive.InterfaceType
Debug.Print "Device ID: " & objDiskDrive.DeviceID

Debug.Print "Bytes Per Sector: " & _
objDiskDrive.BytesPerSector
For Each strCapability In objDiskDrive.Capabilities
Debug.Print "Capabilities: " & strCapability
Next
Debug.Print "Index: " & objDiskDrive.Index
Debug.Print "Manufacturer: " & objDiskDrive.Manufacturer
Debug.Print "Media Loaded: " & objDiskDrive.MediaLoaded
Debug.Print "Media Type: " & objDiskDrive.MediaType
Debug.Print "Model: " & objDiskDrive.Model
Debug.Print "Name: " & objDiskDrive.Name
Debug.Print "Partitions: " & objDiskDrive.Partitions
Debug.Print "PNP DeviceID: " & objDiskDrive.PNPDeviceID
Debug.Print "SCSI Bus: " & objDiskDrive.SCSIBus
Debug.Print "SCSI Logical Unit: " & _
objDiskDrive.SCSILogicalUnit
Debug.Print "SCSI Port: " & objDiskDrive.SCSIPort
Debug.Print "SCSI TargetId: " & objDiskDrive.SCSITargetId
Debug.Print "Sectors Per Track: " & _
objDiskDrive.SectorsPerTrack
Debug.Print "Size: " & objDiskDrive.Size
Debug.Print "Status: " & objDiskDrive.Status
Debug.Print "Total Cylinders: " & _
objDiskDrive.TotalCylinders
Debug.Print "Total Heads: " & objDiskDrive.TotalHeads
Debug.Print "Total Sectors: " & objDiskDrive.TotalSectors
Debug.Print "Total Tracks: " & objDiskDrive.TotalTracks
Debug.Print "Tracks Per Cylinder: " & _
objDiskDrive.TracksPerCylinder
Next

End Sub



-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 100,000 Newsgroups - 19 Different Servers! =-----
Jul 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by jasper | last post: by
3 posts views Thread by Casey Entzi | last post: by
4 posts views Thread by Bradley Grant | last post: by
6 posts views Thread by scorpion53061 | last post: by
3 posts views Thread by regtrashcan | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by kglaser89 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.