Logical & Phisical Drives

  • Thread starter Thread starter javiernews via AccessMonster.com
  • Start date Start date
J

javiernews via AccessMonster.com

Hi,

Can any body help how to map a PC knowing all the Logical & Phisical Drives
in VBA (Access) ??
I need both Logical and Phisical .

Thank You !
 
To learn about the physical drives I think you'll need to use WMI. See
e.g. the article "Managing and Monitoring Disk Drives" at
http://www.microsoft.com/technet/scriptcenter/guide/sas_fsd_attu.mspx?mfr=true
which includes a sample VBScript that can easily be converted to VBA.

As I understand it, even WMI won't give you a true picture of the
physical cylinders, heads, tracks and sectors in most modern hard
drives, or of the physical drive units in a RAID array.

WMI can also get you information on logical drives: see the article
"Managing Logical Disk Drives" (in the contents pane at the same link as
above). Alternatively you can use the Drives collection of the
Scripting.FileSystemObject object, or the Windows API function
GetLogicalDrives().
 
Thank John !! very helpful the information.

Now I´m developing an application which I now in which Logical Disk is
running my application using some thing like this: Msgbox left(CurrentDb.
Name, 3)

But,........... Now I would like to know which is the Physical Disk running
my application ?????

Thnak you !
Javier
 
Ok Thank you again !! Very good

Concerning about the above link:

How to declare correctly the variables involved:


Dim strComputer as ?????
Dim objWMIService as ?
Dim colDiskDrives as ?
Dim objDrive as ?
Dim strDeviceID as ?
Dim colPartitions as ?
Dim objPartition as ?
Dim colLogicalDisks as ?
Dim objLogicalDisk as ?

Thank you !
Javier
 
Since the original is in VBScript they're all Variants there, and you
can leave them that way in VBA. At a guess, objWMIService is a
WMIService object, but maybe Object would do. strComputer is probably a
String. colDiskDrives is likely to be a Collection (but may be a
particular kind of collection: maybe simpler to declare it as Object).
And so on.
 
Very kind !

After running this code in the inmediate window I get the following
information:

Physical Disk: FUJITSU MHR2040AT -- \\.\PHYSICALDRIVE0
Disk Partition: Disk #0, Partition #0
Logical Disk: C:


Physical Disk: Pretec 01GB Tiny USB Device -- \\.\PHYSICALDRIVE1
Disk Partition: Disk #1, Partition #0
Logical Disk: E:

more......... disks
'**********************



Question 1: Which is the right Drive number ???

MsgBox "Option A = " & Right(objDrive.DeviceID, 1)

or

MsgBox "Option B = " & Mid(objPartition.DeviceID, 7, 1)


Question 2: What happen if a PC has 10 disks or more disks ? , (I No sure if
I can get 10 or more disks information with option A and option B)

Any help ?

Javier
 
I'm don't quite know what you're asking, or where Options A and B come
in. If you're not sure of the difference between drives and partitions,
you need to do some more study before trying to use code like this.

I don't know how many physical disks a modern Windows machine can be
connected to at once. There are only 26 possible drive letters, but as
well as mapping partitions and network shares to drive letters NTFS lets
you map them to an empty folder on another logical drive thus overcoming
the limitations of the alphabet.

You can probably tell that this is getting miles away from from my areas
of expertise, let alone the topic of this newsgroup. If you can't work
it out for yourself with the aid of the MSDN documentation I've pointed
you to, you'll do better to ask in a WMI forum such as
microsoft.public.windowsxp.wmi or maybe
microsoft.public.win32.programmer.wmi.

Good luck!
 
Hi John !

Thank you again for your time & support.

Lets forget for a moment about Partitions now,................... lets think
only Disk Physical Numbers

Ok explain again point Number 1

In line:

Debug.Print "Physical Disk: " & objDrive.Caption & " -- " & objDrive.DeviceID
I got the following result:
Physical Disk: FUJITSU MHR2040AT -- \\.\PHYSICALDRIVE0

I you see PHYSICALDRIVE0 last digit shows physical number disk in this case
is "0"
And this number changes for every disk,.........


Now in the following line:

Debug.Print "Disk Partition: " & objPartition.DeviceID
I got the following result:
Disk Partition: Disk #0, Partition #0

I you see shows Disk #0 which this number "0" changes again for every disk,...
......
Ok ? So I have 2 times same information.


QUESTION:
Which is the rigth disk number (Physical) or which line is better to use:
Debug.Print "Physical Disk: " & objDrive.Caption & " -- " & objDrive.DeviceID
or
Debug.Print "Disk Partition: " & objPartition.DeviceID

Hope now is clear.

Thanks
Javier
 
Hi Javier,
QUESTION:
Which is the rigth disk number (Physical) or which line is better to use:
Debug.Print "Physical Disk: " & objDrive.Caption & " -- " & objDrive.DeviceID
or
Debug.Print "Disk Partition: " & objPartition.DeviceID

The right number is the one you want to know. Remember that (for local
drives, with exceptions that needn't concern us here) a logical drive
corresponds to a partition on a physical drive. So if you want to know
the physical drive associated with a logical drive you (as far as I
know) need to first find the partitition associated with the logical
drive, and then the physical drive that contains the partition.

I have never in my life needed to write code to do this, and never
expect to. One of the reasons we have operating systems is to save
developers from having to worry about the physical details. So all I can
do is point you again to the WMI documentation.
 
Hi John !

Its a pitty you did Not answer my question.
Any way I apreciate your time.

Regards
Javier
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Back
Top