Here's some background: what I really need is a fast way to get from a
drive letter such as C: to the WMI properties of the underlying
physical drive (Model, Signature, etc.) I currently do this by
navigating through Win32_LogicalDiskToPartition and
Win32_DiskDriveToDiskPartition, but it's unacceptably slow for our
purposes (more than a second). Now, an API call to QueryDosDevice gets
me from C: to \Device\HarddiskVolume1 really quickly. All I need now
is a fast way to get from there to PHYSICALDRIVE0 and then I'm home
free. Or just a fast way to get there from C: in the first place :)
Any help would be greatly appreciated.
Daniel
> Win32_DiskDriveToDiskPartition, but it's unacceptably slow for our
> purposes (more than a second). Now, an API call to QueryDosDevice gets
> me from C: to \Device\HarddiskVolume1 really quickly. All I need now
> is a fast way to get from there to PHYSICALDRIVE0 and then I'm home
> free.
If you already use the Win32-API I would recommend to use first
GetVolumeNameForVolumeMountPoint() to acquire the internal volume name.
Remove the backslash at the end and use it with CreateFile() to get a
handle of the volume. Use the handle with
DeviceIoControl(volumeHandle,IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS,...)
After that you have the physical drive(s) numbers (a partition may me span
more that one physical drive). Prepend "\\.\PHYSICALDRIVE" to the drive
number and you have what you want.
Jan
Thank you very much. I set about following your instructions, but ran
into the following in the MSDN documentation for CreateFile: the caller
must have administrative privileges in order to open a volume.
Unfortunately, most of our users do not have administrative privileges.
Is there another way?
Thanks again,
Daniel
> must have administrative privileges in order to open a volume.
> Unfortunately, most of our users do not have administrative privileges.
It's a bit worrying if non-Admin users need direct access to physical
drives!
--
Gerry Hickman (London UK)
They don't, of course, and this is quite beside the point. The question
is simply how to get the /path/ of the physical drive given a drive
letter. (The standard way via WMI is too slow to be useful in the
present case.) The ultimate goal is to read a couple of hardware
properties (such as serial number) suitable for anchoring a software
license to a particular PC.
Jan helpfully suggested a series of API calls that would do the trick.
Unfortunately, since CreateFile appears to require admin rights, I
can't use this precise sequence. I hope there is another sequence that
can work (possibly via the DOS device name mentioned in the subject
header). Your suggestions to this effect would be most welcome.
Daniel
--
Jim Vierra
<dont_spa...@yahoo.com> wrote in message
news:1117263430.3...@g47g2000cwa.googlegroups.com...
I looked at it but it seems designed for streaming audio/video and
looks pretty complicated.
The company I'm working with already has a licensing solution; the
trouble is that it takes > 1 second to match the license against the
hardware it's running on, hence my search for a fast way to identify
which physical drive is associated with a drive letter.
Daniel
See RMS here
http://www.microsoft.com/resources/documentation/windowsserv/2003/all/rms/en-us/InitExp_4.mspx
You can also use Software Policies in GP to manage software usage by host
and by user. It's as granular as you want it to be.
--
Jim Vierra
<dont_spa...@yahoo.com> wrote in message
news:1117474085.6...@z14g2000cwz.googlegroups.com...
> Anything can be put under DRM from what I have seen, It is designed to
> support streaming and other forms of licensing.
Anyone who attempts to put a DRM lock on their software deserves to have
it broken. One of the main problems with DRM is that it usually ends up
locking out the legitimate user when they change their hardware, while
the hacked version carries on working for years.
The issue in most cases is proving to a vendor that you can control
distribution. If you have a legitimate system for this and the software is
key driven then I would think RMS would make managing use very much easier.
The ability to report usage would be valuable in many cases.
--
Jim Vierra
"Gerry Hickman" <gerry...@yahoo.co.uk> wrote in message
news:eDqvOxiZ...@TK2MSFTNGP12.phx.gbl...
So I need:
\\.\PHYSICALDRVIE2 -> G:\
and
G:\ to \\.\PHYSCICALDRIVE2
However, I am kind of stumped. Your code would really help me a lot.
Please e-mail me at qbasicer[a-t]]gmail[d-o-t]]com
QueryDosDevice() converts D: to \Device\CdRom0 so I iterate from A: to Z:
until I get a match on the device name:
for (char disk = 'A'; disk <= 'Z'; ++disk) {
string diskPath = string(&disk, 1) + ":";
WCHAR buf[1000];
if (QueryDosDevice(Utf16String(diskPath), buf, 1000) != 0) {
string device = Utf16String(buf).str();
if (device == drive.device) {
drive.drive = diskPath;
break;
}
}
}