Главная страница
    Top.Mail.Ru    Яндекс.Метрика
Форум: "Система";
Текущий архив: 2003.04.17;
Скачать: [xml.tar.bz2];

Вниз

CreateFile для CDROM   Найти похожие ветки 

 
max2057   (2003-02-20 13:14) [0]

Хочу написать типа линуксового eject"a но под Windows
Для этого подходить DeviceIoControl но сначала надо получить
хендл Cdrom"a но через CreateFile что-то не получатся
Так вот как его получить ?


 
AlexRush   (2003-02-22 12:29) [1]

USES MMSystem;
procedure EjectCD;
begin
mciSendString("Set CDAudio Door Open"#0, ""#0, 0, 0);
end;

И усё.


 
AlexRush   (2003-02-22 15:37) [2]

ИЛИ
------------------------------------------------------------
eject.asm

TITLE CD-EJECT

.386
.model FLAT,STDCALL

.data
WinMMLib db "winmm.dll",0
mciSendCommandA_Name db "mciSendStringA",0
mciCommand db "Set CDAudio Door Open",0

EXTRN LoadLibraryA :proc
EXTRN GetProcAddress :proc
EXTRN ExitProcess :proc
.code

strart:
push offset WinMMLib
call LoadLibraryA
test eax,eax
jz _exit
push offset mciSendCommandA_Name
push eax
call GetProcAddress
test eax,eax
jz _exit
xchg eax,ebx

xor eax,eax
push eax
push eax
push eax
push offset mciCommand
call ebx
_exit:
push eax
call ExitProcess
end strart
------------------------------------------------------------

X:\> TASM32 /m /la /x /ml /D_TASM_ eject.asm
X:\> TLINK32 -Tpe -aa -c -o eject.obj,eject,,X:\Path\To\My\import32.lib,

И ТОГО - 4 Kb


 
ZZ   (2003-02-23 16:19) [3]

max2057
А ты напиши как не получается

Цитатка из MSDN
Disk Devices
Volume handles may be opened as noncached at the discretion of the file system, even when the noncached option is not specified with CreateFile. You should assume that all Microsoft file systems open volume handles as noncached. The restrictions on noncached I/O for files apply to volumes as well.

A file system may or may not require buffer alignment even though the data is noncached. However, if the noncached option is specified when opening a volume, buffer alignment is enforced regardless of the file system on the volume. It is recommended on all file systems that you open volume handles as noncached and follow the noncached I/O restrictions.

Windows NT/2000 or later: You can use the CreateFile function to open a disk drive or a partition on a disk drive. The function returns a handle to the disk device; that handle can be used with the DeviceIOControl function. The following requirements must be met in order for such a call to succeed:

The caller must have administrative privileges for the operation to succeed on a hard disk drive.
The lpFileName string should be of the form \\.\PHYSICALDRIVEx to open the hard disk x. Hard disk numbers start at zero. For example:
String Meaning
\\.\PHYSICALDRIVE2 Obtains a handle to the third physical drive on the user"s computer.


For an example showing how to open a physical drive, see Calling DeviceIoControl on Windows NT/2000.

The lpFileName string should be \\.\x: to open a floppy drive x or a partition x on a hard disk. For example:
String Meaning
\\.\A: Obtains a handle to drive A on the user"s computer.
\\.\C: Obtains a handle to drive C on the user"s computer.


There is no trailing backslash in a drive name. The string "\\.\c:\" refers to the root directory of drive C.

On Windows 2000 or later, you can also open a volume by referring to its unique volume name. In this case also, there should be no trailing backslash on the unique volume name.

Note that all I/O buffers should be sector aligned (aligned on addresses in memory that are integer multiples of the volume"s sector size), even if the disk device is opened without the FILE_FLAG_NO_BUFFERING flag. Depending the disk, this requirement may not be enforced.

Windows 95/98/Me: This technique does not work for opening a logical drive. Specifying a string in this form causes CreateFile to return an error.

The dwCreationDisposition parameter must have the OPEN_EXISTING value.
When opening a floppy disk or a partition on a hard disk, you must set the FILE_SHARE_WRITE flag in the dwShareMode parameter.



AlexRush
А что будет если у меня 2 CD-ROM"а?



Страницы: 1 вся ветка

Форум: "Система";
Текущий архив: 2003.04.17;
Скачать: [xml.tar.bz2];

Наверх




Память: 0.46 MB
Время: 0.007 c
14-54869
Supreme 2
2003-04-01 23:16
2003.04.17
Чё с МАСЯНЕЙ????? Гляньте сайт! Это чё, прикол??


4-54942
NewEdik
2003-02-17 21:53
2003.04.17
Отступ в ComboBox


3-54529
Yuraz
2003-04-01 09:24
2003.04.17
Просмотр данных о функциях в Oracle.


14-54863
Lucky Startik
2003-04-01 17:25
2003.04.17
Возможности DELPHI


1-54601
diww
2003-04-07 17:00
2003.04.17
как узнать тип ошибки?





Afrikaans Albanian Arabic Armenian Azerbaijani Basque Belarusian Bulgarian Catalan Chinese (Simplified) Chinese (Traditional) Croatian Czech Danish Dutch English Estonian Filipino Finnish French
Galician Georgian German Greek Haitian Creole Hebrew Hindi Hungarian Icelandic Indonesian Irish Italian Japanese Korean Latvian Lithuanian Macedonian Malay Maltese Norwegian
Persian Polish Portuguese Romanian Russian Serbian Slovak Slovenian Spanish Swahili Swedish Thai Turkish Ukrainian Urdu Vietnamese Welsh Yiddish Bengali Bosnian
Cebuano Esperanto Gujarati Hausa Hmong Igbo Javanese Kannada Khmer Lao Latin Maori Marathi Mongolian Nepali Punjabi Somali Tamil Telugu Yoruba
Zulu
Английский Французский Немецкий Итальянский Португальский Русский Испанский