Getting specific disk information

Uranium-235

Member
Joined
May 23, 2022
Messages
5
Programming Experience
1-3
So I need to see if a specific disk in USB removable (flash drive) or USB removable hard disk

DiskInfo provides this, but the disk type for a removable hard drive is the same as fixed hard disk

So I started delving into querying WMI. Win32_DiskDrive does separate them, but has no information for the drive letter. Win32_LogicalDisk does, but I see no common entries that can query LogicalDisk from DiskDrive, DiskVolume or DiskPartition. Did a lot of google searching and going through the query returns that are possible with each one. Is there a way to do this?
 
The reason they're not the same in WMI is that they are not the physically the same. A single physical disk can have multiple logical drives on it, so there's no one-to-one correspondence. I don't know exactly where the information is that you need but I do know that there are Win32_DiskDrive, Win32_LogicalDisk and Win32_DiskPartition classes as well as Win32_DiskDriveToDiskPartition and Win32_LogicalDiskToPartition classes that relate them. It seems likely that you can get everything you need using those.
 
I've been going through those four (not the D2D or D2P). tested tons of returns from each and there are no common returns that can link from physical to partition, or vise versa

The other two are...confusing when I looked them up
 
The other two are...confusing when I looked them up
They are they links. That's my point. It's like adding a third table to create a many-to-many relationship in a database.
 
Research the "Associators of" wmi query.
 
ah found it. aaaand trying to figure it out. Examples from M$ are a bit outdated

There is no Win32_DiskDrivetoLogicalDisk. So I have to go through partitions, get the logical disk, then get the physical disk?
 
Back
Top