Solved

Detecting System Parameter

Posted on 1997-08-20
4
298 Views
Last Modified: 2008-03-17
Is there a way in C++ or VB to detect a substitute logical drive as well as create a substitute drive.
Also, setting and retreiving environment variables.
0
Comment
Question by:rian
  • 2
  • 2
4 Comments
 
LVL 4

Expert Comment

by:md041797
ID: 1167827
What's the OS?  There is no standard way in C++.  It depends on using the OS API.
0
 

Author Comment

by:rian
ID: 1167828
The Operating System will be Windows NT Server 4.0
0
 
LVL 4

Accepted Solution

by:
md041797 earned 50 total points
ID: 1167829
use this to get all drives:

DWORD GetLogicalDriveStrings(

    DWORD nBufferLength,      // size of buffer
    LPTSTR lpBuffer       // address of buffer for drive strings
   );

The GetDriveType function determines whether a disk drive is a removable, fixed, CD-ROM, RAM disk, or network drive.

UINT GetDriveType(

    LPCTSTR lpRootPathName       // address of root path
   );


The GetVolumeInformation function returns information about a file system and volume whose root directory is specified. This will show you if two drive letters map to the same volume.

BOOL GetVolumeInformation(

    LPCTSTR lpRootPathName,      // address of root directory of the file system
    LPTSTR lpVolumeNameBuffer,      // address of name of the volume
    DWORD nVolumeNameSize,      // length of lpVolumeNameBuffer
    LPDWORD lpVolumeSerialNumber,      // address of volume serial number
    LPDWORD lpMaximumComponentLength,      // address of system's maximum filename length
    LPDWORD lpFileSystemFlags,      // address of file system flags
    LPTSTR lpFileSystemNameBuffer,      // address of name of file system
    DWORD nFileSystemNameSize       // length of lpFileSystemNameBuffer
   );

This is probably what you're after though:
The QueryDosDevice function lets an application obtain information about MS-DOS device names. The function can obtain the current mapping for a particular MS-DOS device name. The function can also obtain a list of all existing MS-DOS device names.

MS-DOS device names are stored as symbolic links in the Windows NT object name space. The code that converts an MS-DOS path into a corresponding Windows NT path uses these symbolic links to map MS-DOS devices and drive letters. The QueryDosDevice function provides a mechanism whereby a Win32-based application can query the names of the symbolic links used to implement the MS-DOS device namespace as well as the value of each specific symbolic link.

DWORD QueryDosDevice(

    LPCTSTR lpDeviceName,      // address of MS-DOS device name string
    LPTSTR lpTargetPath,      // address of buffer for storing query results  
    DWORD ucchMax       // maximum storage capacity of buffer  
   );      
 

The DefineDosDevice function lets an application define, redefine, or delete MS-DOS device names.

MS-DOS device names are stored as symbolic links in the object name space in 32-bit versions of Windows. The code that converts an MS-DOS path into a corresponding path in 32-bit versions of Windows uses these symbolic links to map MS-DOS devices and drive letters. The DefineDosDevice function provides a mechanism whereby a Win32-based application can modify the symbolic links used to implement the MS-DOS device name space.

BOOL DefineDosDevice(

    DWORD dwFlags,      // flags specifying aspects of device definition  
    LPCTSTR lpDeviceName,      // pointer to MS-DOS device name string  
    LPCTSTR lpTargetPath      // pointer to MS-DOS or path string for 32-bit Windows  
   );      
 

0
 

Author Comment

by:rian
ID: 1167830
Thanks md
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now