Уважаемые авторы вопросов! Большая просьба сообщить о результатах решения проблемы на этой странице. Иначе, следящие за обсуждением, возможно имеющие аналогичные проблемы, не получают ясного представления об их решении. А авторы ответов не получают обратной связи. Что можно расценивать, как проявление неуважения к отвечающим от автора вопроса.
24-08-2004 16:59
статьи Q98080,Q137176 и выдержка из справочника прерываний MSDOS:
----------1308-------------------------------
INT 13 - DISK - GET DRIVE PARAMETERS (PC,XT286,CONV,PS,ESDI,SCSI)
AH = 08h
DL = drive (bit 7 set for hard disk)
Return: CF set on error
AH = status (07h) (see AH=01h)
CF clear if successful
AH = 00h
BL = drive type (AT/PS2 floppies only)
01h 360K
02h 1.2M
03h 720K
04h 1.44M
06h ??? (checked by 386MAX v6.01)
CH = low eight bits of maximum cylinder number
CL = maximum sector number (bits 5-0)
high two bits of maximum cylinder number (bits 7-6)
DH = maximum head number
DL = number of drives
ES:DI -> drive parameter table (floppies only)
Notes: may return successful even though specified drive is greater than the
number of attached drives of that type (floppy/hard); check DL to
ensure validity
for systems predating the IBM AT, this call is only valid for hard
disks, as it is implemented by the hard disk BIOS rather than the
ROM BIOS
Toshiba laptops with HardRAM return DL=02h when called with DL=80h,
but fail on DL=81h. The BIOS data at 40h:75h correctly reports 01h.
SeeAlso: AH=15h,INT 1E,INT 41
может быть прояснят картину - функция 1308 возвращает DPT только для флопиков, для винтов можно якобы посмотреть геометрию, но учитывая особенности современных винтов (LBA, да еще и число цилиндров превышает оговоренные 1024), то использование этой функции наверное бессмысленно
хм.. да, действительно, что-то я проглядел... но в общем-то тоже не особая проблема - за 5 минут ищется в MSDN:
const
VWIN32_DIOC_DOS_INT13=4;
type
_DEVIOCTL_REGISTERS=packed record
reg_EBX:DWORD;
reg_EDX:DWORD;
reg_ECX:DWORD;
reg_EAX:DWORD;
reg_EDI:DWORD;
reg_ESI:DWORD;
reg_Flags:DWORD;
end;
DEVIOCTL_REGISTERS=_DEVIOCTL_REGISTERS;
PDEVIOCTL_REGISTERS=^DEVIOCTL_REGISTERS;
function DoIOCTL(preg:PDEVIOCTL_REGISTERS):Boolean;
var hDevice:THandle;
cb:DWORD;
begin
preg.reg_Flags := $08000; // assume error (carry flag set)
Result:=FALSE;
hDevice := CreateFile('\\\\.\\vwin32', GENERIC_READ,
FILE_SHARE_READ or FILE_SHARE_WRITE,nil,OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL, 0);
if (hDevice = INVALID_HANDLE_VALUE) then exit
else
Result := DeviceIoControl(hDevice, VWIN32_DIOC_DOS_INT13,
preg, sizeof(preg^), preg, sizeof(preg^), cb, nil);
CloseHandle(hDevice);
end;
function GetDiskType(nDrive:Cardinal, SizeKb: DWORD):Boolean;
var
reg:DEVIOCTL_REGISTERS;
begin
reg.reg_EAX := $01500; // IOCTL for block devices
reg.reg_EDX := nDrive; // receives media ID info
Result:=DoIOCTL(@reg);
Result:=Result and ((reg.reg_Flags and $08000)=0) and ((reg.reg_EAX and $FF00)=$0000);
if ((reg.reg_EAX and $FF00)=$0300) then
SizeKb:=((reg.reg_ECX and $ffff)*$10000+reg.reg_EDX)/2
else
SizeKb:=0;
end;
{
INT 13 - DISK - GET DISK TYPE (XT 1/10/86 or later,XT286,AT,PS)
AH = 15h
DL = drive number (bit 7 set for hard disk)
Return: CF clear if successful
AH = type code
00h no such drive
01h floppy without change-line support
02h floppy with change-line support
03h hard disk
CX:DX = number of 512-byte sectors
CF set on error
AH = status (see AH=01h)
SeeAlso: AH=08h,AH=16h,AH=17h,AH=19h"SCSI"
}
device unit numbers for Interrupt 13h:
Value Description
00 - 7Fh Floppy disk drive (00 for the first floppy drive, 01 for the second, and so on).
80 - FFh Hard disk drive (80 for the first hard disk drive, 81 for the second, and so on).
Ну и еще в справочнике функций MSDOS. Проверить правда этот код не могу - нет у меня 9х...
А можно еще BPB получать для всех логических дисков и получать их физ.номер, но так могут быть видны не все размеры, или с помощью того же INT13 считывать MBR и его разбирать...
Вопрос был задан конкретно: Получить список всех физических дисков в Win 9x, а не логических про что писал AG. В Win NT все просто а вот в 9x нужно использовать vwin32, но вот с какими параметрами я так и не могу разобраться
begin
{ fill list }
Clear;
Integer(DriveBits) := GetLogicalDrives;
for DriveNum := 0 to 25 do
begin
if not (DriveNum in DriveBits) then Continue;
DriveChar := Char(DriveNum + Ord('a'));
DriveType := TDriveType(GetDriveType(PChar(DriveChar + ':\')));
if TextCase = tcUpperCase then
DriveChar := Upcase(DriveChar);
Я думаю, здесь будет уместно процитировать справку:
PSS ID Number: Q125712
Authored 02-Feb-1995 Last modified 06-Apr-1995
The information in this article applies to:
- Microsoft Win32 Software Development Kit (SDK)
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
The chapter "Device I/O Control in Windows 95" describes the procedures for
using DeviceIoControl() in Windows 95, and contains a description of the MS-
DOS IOCTL functions supported by the VWIN32 VxD.
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 a complete list of IOCTLs, see the description of the DeviceIoControl()
function in the Microsoft Windows Programmer's Reference, Volume 3.
Если вы заметили орфографическую ошибку на этой странице, просто выделите ошибку мышью и нажмите Ctrl+Enter. Функция может не работать в некоторых версиях броузеров.