Quantcast
Channel: VBForums - API
Viewing all articles
Browse latest Browse all 168

How do I determine what type of drive I've opened?

$
0
0
If I use CreateFile with a drive such "\\.\c:" (a logical drive, starting with the first sector of the first partition of the harddrive), or "\\.\physicaldrive0" (the first harddrive starting with the first sector), I know I'm getting a harddrive (and thus with 512bytes per sector). And if I use "\\.\f:" (my computer's optical drive, handled as a logical drive) or "\\.\scsi0:" (my computer's optical drive, handled as a physical drive) I know I'm getting an optical drive (and thus with 4096bytes per sector).

However, there's no guaranty that those designations will be the same on another computer. So if I use CreateFile with any random drive to open it for raw access, I'm going to need a method to determine what type of drive it is (optical or non-optical, and thus 4096byte sectors or 512byte sectors), because unlike with files, raw access to a drive requires sector alignment for all read and write operations.

Is there an API function that I can pass the hFile handle to, that when the handle is associated with a drive (not a file) the function will return to me a value that identifies what type of drive it is (or better yet, exactly what the bytes-per-sector for the drive is)?

Viewing all articles
Browse latest Browse all 168

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>