GUI ScreenIO for Windows

 ScreenIO.com


QueryDosDevice

This API returns the information about DOS devices, such as Drive Letters, Printer Ports, etc.  With this API you can find out if a drive letter exists on the computer, and if it points at a local physical device or is mapped to a network share.  You can also find out if other dos devices exist such as LPT1, LPT2, COM1, COM2, etc. 

You call this API with a device name and you are provided with the information indicating the local or remote device to which it is attached. Some Operating systems such as Windows 95 return no information.  Others return more than the current mapping of the drive.  For instance, Windows Vista and Windows 7 will return the current mapping (if the drive is mapped to a network resource, and one or more the Prior mappings separated by low values in the returned values.  Actual machine names to which drives are mapped may come back as numeric strings in some versions of windows.

If Printer Ports are captured and routed to a remote printer this will be reflected in the returned values.

If Called with low-values in the device name field you will be a returned a survey of all devices attached to this machine.  See below.

This is useful for finding CDrom Drives on the system, and determining their drive letters.  It is recommended that if you need this API you should experiment to determine the exact nature of the returned information.  

Client/Server issues

The API may be used to obtain information about a Device on either the client or the server.  To interrogate devices on the server:

     SET WIN32API-EXECUTE-API-ON-SERVER TO TRUE

Files

Files available to copy to your system:

Usage

     COPY WIN32API.
     COPY QUERYDOS.

* ------------------------: Call the API.

     SET API-QUERYDOSDEVICE TO TRUE.

     MOVE LOW-VALUES TO DOS-DRIVE-MAPPING
     MOVE LENGTH OF DOS-DRIVE-MAPPING TO DOS-MAPPING-SIZE
     MOVE 'F:' TO DOS-DEVICE-NAME
     
     CALL 'GSWINAPI' USING WIN32API-PARMS
                           DOS-DEVICE-NAME
                           DOS-MAPPING-SIZE
                           DOS-DEVICE-MAPPING
                           WIN32API-D
                           WIN32API-E
                           WIN32API-F.
                        

Parameters specific to this function

DOS-DEVICE-NAME

This field must be set to the device name about which you wish to obtain information.  Do not use trailing back slashes.  Do use trailing colon.

Examples Include:  C:  H:  COM1:  LPT2:

If this field is initialized to low-values, this API will return a list of devices in the system, separated by low-values.

DOS-MAPPING-SIZE

You must set this to the size of the area provided for returning information about a device.

DOS-DEVICE-MAPPING

This area will be returned with the current mapping of this DOS device.  For drive letters, the mapping may contain more than one mapping, each separated by low values.  The first such mapping is the current one, and subsequent mappings are prior mappings.  (Not all operating systems show prior mappings).  The end of all mappings and prior mappings is indicated by two consecutive low-values.

If you initialize DOS-DEVICE-NAME to low-values, a list of all devices in the system will be returned.  Not JUST hard drives, but also Ports etc.  This list can be rather long, as devices are not returned with Drive Letters, but rather in the form \Device\Harddisk\Volume1 or \Device\Floppy.  

This is why this area is so large (2048 bytes).  On extensively equipped servers you might get a long list of devices, including many hard drives, many com ports etc.  In this case WIN32API-FAILED may be true upon return, and DOS-MAPPING-SIZE will indicate the amount of space required.  You will then need to lengthen the DOS-DEVICE-MAPPING field.  

WIN32API-PARMS - Used in all GSWINAPI calls

This argument is standard for all CALLs to GSWINAPI. It is used to select the desired API or function, and to return the status of the operation.

WIN32API-RC

Used to return the status of a call to GSWINAPI.  A value of zero is a failure, any other value indicates success.

NOTE: If the API succeeds, WIN32API-RC will contain the number of bytes returned in DOS-DEVICE-MAPPING excluding the final low-value.

Recommended usage is to test the 88-level value WIN32API to see if it worked, then to use the text error message to see why it failed.

* ------------------------: If function failed,
*                         :   display the error in a message box.
*
     IF WIN32API-FAILED
       MOVE WIN32API-ERROR-TEXT TO panel-MESSAGE-TEXT
       SET panel-MESSAGE-IN-MESSAGEBOX TO TRUE.

WIN32API-ERROR-CODE

Error code that was returned by Windows.  This is not generally useful unless you have the Windows Platform SDK documentation available to you.

WIN32API-ERROR-TEXT

Plain-text error message that describes why the operation failed.

WIN32API-A through WIN32API-F

The number of these present varies depending on how many arguments are used by the desired function.  These are not used, but must be present because this CALL requires seven arguments.


2000-2019 Norcom, all rights reserved 

TOC

Send feedback to Norcom