Board index » delphi » Device Handles

Device Handles

Hi,

In the help file on CreateFile it says that you can get a handle on a
device by using a string like '\\.\A:' and then says that you can't use
that method under Win95. Does anyone know how you do get a device handle
under Win95?

Regards, Barry.

 

Re:Device Handles


In message <Pine.SOL.3.91.960927031358.19994D-100000-100000@sirius>, Alcock <ba...@herts.ac.uk>
said:

Quote
> In the help file on CreateFile it says that you can get a handle on a
> device by using a string like '\\.\A:' and then says that you can't use
> that method under Win95. Does anyone know how you do get a device handle
> under Win95?

From the Win95 Knowledge Base...

-------------------------------------------------------------------------
The information in this article applies to:

 - Microsoft Win32 Application Programming Interface (API) included with:

    - Microsoft Windows 95 version 4.0
-------------------------------------------------------------------------

SUMMARY
=======

Windows 95 does not support opening disk drives or disk partitions with
CreateFile(), as Windows NT does. Windows 95 also does not support the
DeviceIoControl() IOCTL APIs, as Windows NT does. Instead, low-level disk
access in Windows 95 can be achieved through DeviceIoControl() calls to the
VWIN32 VxD.

MORE INFORMATION
================

Windows NT supports obtaining a handle to a disk drive or disk partition
by using CreateFile() and specifying the name of the drive or partition
as the filename (e.g. "\\.\PHYSICALDRIVE0" or "\\.\C:"). This handle can
then be used in the DeviceIoControl() Win32 API.

Windows 95 differs in the following ways:

1. Obtaining a disk drive or disk partition handle is not supported.
   The call to CreateFile() will fail, and GetLastError() will return
   error code 2, ERROR_FILE_NOT_FOUND.

2. The DeviceIoControl IOCTL functions (such as IOCTL_DISK_FORMAT_TRACKS)
   are not supported. These IOCTLs require the handle to a disk drive or
   disk partition and thus can't be used.

3. DeviceIoControl() is called using a handle to a VxD rather than a
   handle to a disk drive or disk partition. Obtain a handle to
   VWIN32.VXD by using CreateFile( "\\\\.\\VWIN32", ... ). Use this
   handle in calls to DeviceIoControl() to perform volume locking
   (Int 21h Function 440Dh, Subfunctions 4Ah and 4Bh), and then to
   perform BIOS calls (Int 13h), Absolute Disk Reads/Writes (Int 25h
   and 26h), or MS-DOS IOCTL functions (Int 21h Function 440Dh).

REFERENCES
==========

For information on using DeviceIoControl() in Windows 95 and the IOCTL
functions supported by the VWIN32 VxD, please see the help file "Windows 95
Guide to Programming". Go to "Using Windows 95 features" and select "Using
Device I/O Control."

For information on using CreateFile() to obtain disk drive or disk
partition handles under Windows NT, see the description for CreateFile()
in the Microsoft Windows Programmer's Reference, Volume 3.

For information on Windows 95 extensions to the MS-DOS interrupts, please
see the help file "Windows 95 Guide to Programming." Go to "Using Microsoft
MS-DOS Extensions" and select "Exclusive Volume Locking", then "About
Exclusive Volume Locking", then "Exclusive Use Lock".

For a complete list of IOCTLs, see the description of the DeviceIoControl()
function in the Microsoft Windows Programmer's Reference, Volume 3.

Additional reference words: 4.00
KBCategory: kbprg
KBSubcategory: BseFileio
=============================================================================
Copyright Microsoft Corporation 1995.

-----------------------------------------------------------------------
Steve Rencontre               |  st...@dstrip.demon.co.uk (business)
If it works, it's obsolete.   |  steve...@cix.compulink.co.uk (private)
-----------------------------------------------------------------------

Other Threads