Solved

Detecting System Parameter

Posted on 1997-08-20
4
318 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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

822 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