首先
uses mmsystem;
然后,定义一个cdaudio设备的别名,以后通过该别名操纵光驱
在这里,定义的别名是cd
mciSendString('open cdaudio alias cd wait shareable', nil, 0, 0);
这个函数打开cddo
or
mciSendString('set cddo
or open',nil, 0, 0);
这个函数关闭cddo
or
mciSendString('set cddo
or closed',nil, 0, 0);
>>再简单的例子不可能了
Win32 API:
BOOL <font color=red>DeviceIoControl</font>(
HANDLE hDevice, // handle to device of interest
DWORD dwIoControlCode, // control code of operation to perform
LPVOID lpInBuffer, // pointer to buffer to supply input data
DWORD nInBufferSize, // size of input buffer
LPVOID lpOutBuffer, // pointer to buffer to receive output data
DWORD nOutBufferSize, // size of output buffer
LPDWORD lpBytesReturned, // pointer to variable to receive output byte count
LPOVERLAPPED lpOverlapped // pointer to overlapped structure for asynchronous operation
);
....
dwIoControlCode:
Specifies the control code for the operation.
...
Value Meaning
... ...
<font color=red>IOCTL_STORAGE_EJECT_MEDIA</font> Ejects media from a SCSI device.