Go Back   PCMech Forums > Help & Discussion > Web Design / Development

Need Some Help? Type Your Keywords Here:

Reply
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Old 07-02-2001, 11:50 PM   #1
Member (6 bit)
 
Join Date: Jun 2001
Location: My house
Posts: 62
Talking Ok please don't flame me lol

Hi i'm really new to c++ (i can only do basic stuff so far) but i was wondering if there was somehow a way to make a program open your cd tray???
MightyPOOsticK is offline   Reply With Quote
Old 07-11-2001, 02:36 PM   #2
Member (10 bit)
 
Join Date: Apr 2001
Location: Michigan
Posts: 850
Send a message via ICQ to HackinCowboy
The program is actually quite simple once you understand the code. Try this..

#include

void __fastcall Open()
{
DWORD bytes;
HANDLE hDevice = CreateFile("\\\\.\\D:", GENERIC_READ, FILE_SHARE_READ ,
NULL, OPEN_EXISTING, FILE_ATTRIBUTE_READONLY, NULL);
DeviceIoControl(hDevice,IOCTL_DISK_EJECT_MEDIA,NULL,0, NULL, 0, &bytes,
(LPOVERLAPPED) NULL);
CloseHandle(hDevice);
}

void __fastcall Close()
{
DWORD bytes;
HANDLE hDevice = CreateFile("\\\\.\\D:", GENERIC_READ, FILE_SHARE_READ ,
NULL, OPEN_EXISTING, FILE_ATTRIBUTE_READONLY, NULL);
DeviceIoControl(hDevice,IOCTL_DISK_LOAD_MEDIA,NULL,0, NULL, 0, &bytes,
(LPOVERLAPPED) NULL);
CloseHandle(hDevice);
}
HackinCowboy is offline   Reply With Quote
Old 07-12-2001, 04:45 AM   #3
SQL nutcase
 
mosquito's Avatar
 
Join Date: Sep 2000
Location: Belgium
Posts: 1,136
Send a message via AIM to mosquito
Euh, not every CD Drive is Drive D.
mosquito is offline   Reply With Quote
Old 07-12-2001, 11:59 AM   #4
Member (12 bit)
 
Paul Victorey's Avatar
 
Join Date: Mar 1999
Location: MN or WI
Posts: 3,017
Yeah, if you wanted to open a CD, you need to decide to get the drive letter by:

a) A registry value, saved after you query the user as to the CD drive they prefer
-or-
b) Enumerate the drives and check each drive's type (and then open ALL CDROM drives)
-or-
c) Same as b), but open only the first CDROM
-or-
d) Hardcode the letter (not recommended for a program you're distributing, but easiest for your own use).

If you're installing the program from a CD initially, it's easy to simply use the letter of the drive they installed from.
__________________
Paul M. Victorey
------------------
I am not responsible for any problems that may arise as a result of following my advice. This includes, but is not limited to, computer failure, loss of data, nuclear war, famine, boils, no clean laundry, your daughter running off with a biker gang, or armageddon. Take my advice at your own risk.
Paul Victorey is offline   Reply With Quote
Old 07-12-2001, 02:31 PM   #5
SQL nutcase
 
mosquito's Avatar
 
Join Date: Sep 2000
Location: Belgium
Posts: 1,136
Send a message via AIM to mosquito
I think the best way to do it is enumerate the cd drives, and query the user if there is more than one drive.
mosquito is offline   Reply With Quote
Reply

Bookmarks

Still Need Help? Type Your Keywords Here:


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 05:01 AM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
SEO by vBSEO 3.6.0 PL2