Solved

Detecting System Parameter

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
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 difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

920 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