Solved

Detecting System Parameter

Posted on 1997-08-20
4
340 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

632 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