|
-
January 7th, 2003, 03:53 PM
#1
how do I determine a fix drive on a machine?
Hi,
Is there any way to determine if a drive is a fixed drive or a network drive from a batch file or a perl script?
Thanks,
-Mehul
-
January 7th, 2003, 04:34 PM
#2
You can do it via API calls. One solution would be to write a simple program in something like C++ and return the result....
TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!)
2008, 2009,2010
In theory, there is no difference between theory and practice; in practice there is.
* Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions 
* How NOT to post a question here
* Of course you read this carefully before you posted
* Need homework help? Read this first
-
January 7th, 2003, 05:18 PM
#3
The following is a solution for Microsoft operating systems...
Code:
#include <iostream>
using std::cout;
using std::endl;
// Get logical drives
DWORD dwLogicalDrives = ::GetLogicalDrives();
if(dwLogicalDrives)
{
for(int iCnt = 0; iCnt < 32; ++iCnt)
{
memset(szDriveRoot, 0, sizeof(szDriveRoot));
if(dwLogicalDrives & (1 << iCnt))
{
// Set drive root
sprintf(szDriveRoot, "%c:\\", iCnt + 'A');
// Determine partition type
UINT uiDriveType = ::GetDriveType(szDriveRoot);
switch(uiDriveType)
{
// Unknown
case DRIVE_UNKNOWN:
cout << "Partition " << szDriveRoot << " -> " << "Unknown" << endl;
break;
// Root path invalid
case DRIVE_NO_ROOT_DIR:
cout << "Partition " << szDriveRoot << " -> " << "Root path invalid"
<< endl;
break;
// Removable drive
case DRIVE_REMOVABLE:
cout << "Partition " << szDriveRoot << " -> " << "Removable drive"
<< endl;
break;
// Fixed drive
case DRIVE_FIXED:
cout << "Partition " << szDriveRoot << " -> " << "Fixed drive"
<< endl;
break;
// Network drive
case DRIVE_REMOTE:
cout << "Partition " << szDriveRoot << " -> " << "Network drive"
<< endl;
break;
// CD-ROM
case DRIVE_CDROM:
cout << "Partition " << szDriveRoot << " -> " << "CD-ROM"
<< endl;
break;
// RAM-Disk
case DRIVE_RAMDISK:
cout << "Partition " << szDriveRoot << " -> " << "RAM-Disk"
<< endl;
break;
}
}
}
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|