| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | CD Changer eject/retract |
HB> Thanks Jeff. IOCTL is a little (a LOT) beyond my league at the moment :(
// sample C program to eject cdrom.
// Shows 1) How to open a physical disk in "DASD" mode
// 2) How to use an IOCTL.
#include
#include
#include
#define INCL_DOS
#define INCL_DOSDEVIOCTL
#define INCL_NOPMAPI
#include
HFILE opendrive(char *drstr, char mode)
{
HFILE fh;
ULONG usAction, stat;
ULONG open_mode;
ULONG bCmd;
open_mode = OPEN_FLAGS_DASD | OPEN_SHARE_DENYREADWRITE
| OPEN_FLAGS_WRITE_THROUGH | OPEN_FLAGS_FAIL_ON_ERROR
| OPEN_FLAGS_NOINHERIT;
if(mode == 'w')
open_mode |= OPEN_ACCESS_READWRITE;
stat = DosOpen(drstr, /* filename to open */
&fh, /* address of file handle */
&usAction, /* address to store action taken */
0L, /* size of new file */
0, /* file's attribute */
FILE_OPEN, /* action to take if file exists */
open_mode, /* file's open mode */
0L); /* Reserved */
if(stat){
switch(stat){
case 15:
printf("Drive %s is invalid.\n", drstr);
break;
case 21:
printf("Drive %s is not ready.\n", drstr);
break;
case 32:
printf("Drive %s is currently locked by another
process.\n", drstr);
break;
case 65:
printf("Drive %s is a network drive.\n", drstr);
break;
default:
printf("error %d opening drive %s\n", stat, drstr);
}
exit(3);
}
return(fh);
}
int main(void)
{
HFILE hf;
APIRET rc;
ULONG ulPinout, ulDinout;
LONG ID_code;
hf = opendrive("J:", 'r');
ulPinout = sizeof(ID_code);
ulDinout = 0;
// the ID_code is what most people miss. It must be "CD01"
ID_code = 0x31304443L; // "CD01"
rc = DosDevIOCtl(hf,
IOCTL_CDROMDISK,
CDROMDISK_EJECTDISK,
&ID_code, sizeof(ID_code), &ulPinout, /* parms */
NULL, 0, &ulDinout); /* data */
if(rc)
printf("sys%04u: CDROMDISK_EJECTDISK error\n", rc);
exit(0);
}
--- Maximus/2 3.00
* Origin: Sol 3 * Toronto * V.32 * (905)858-8488 (1:259/414)SEEN-BY: 50/99 270/101 620/243 625/100 711/401 409 410 413 430 808 809 934 SEEN-BY: 711/955 712/407 515 624 628 713/888 800/1 @PATH: 259/414 400 99 250/99 3615/50 396/1 270/101 712/515 711/808 934 |
|
| SOURCE: echomail via fidonet.ozzmosis.com | |
Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.