Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 06-08-2005, 04:42 PM   #1 (permalink)
DJMaze
Senior Contributor
 
DJMaze's Avatar
 
Join Date: Mar 2005
Posts: 651
DJMaze is on a distinguished road
Detect CD drive

i have small testing script to eject/load a cd drive.
Code:
#include "stdafx.h"
#include "windows.h"
#include "Winioctl.h"
#include "stdlib.h"

int main(int argc, char* argv[])
{
	HANDLE drive_file;
	BOOL   success;
	DWORD  temp;
        
	char drive_letter[7] = "\\\\.\\D:";

	// Open Target Drive
	drive_file = CreateFile(drive_letter, GENERIC_READ, 
                                        FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, 
                                        OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);

	if (drive_file != INVALID_HANDLE_VALUE) {
		while (success) {
			// Eject or Load the CD
			success = DeviceIoControl(drive_file, IOCTL_STORAGE_EJECT_MEDIA, NULL, 0, NULL, 0, &temp, NULL);
			if (success) {
				Sleep(2000);
				success = DeviceIoControl(drive_file, IOCTL_STORAGE_LOAD_MEDIA, NULL, 0, NULL, 0, &temp, NULL);
				if (success) Sleep(2000);
			}
		}
	}
	return 0;
}
Shure i could walk thru D to Z or use GetLogicalDrives()/GetLogicalDriveStrings() and then GetDriveType() == DRIVE_CDROM

But isn't there a easier way ?
DJMaze is offline   Reply With Quote
Old 06-17-2005, 06:12 AM   #2 (permalink)
DJMaze
Senior Contributor
 
DJMaze's Avatar
 
Join Date: Mar 2005
Posts: 651
DJMaze is on a distinguished road
Nobody who has a trick ?
DJMaze is offline   Reply With Quote
Old 06-17-2005, 08:45 AM   #3 (permalink)
redhead
Newbie
 
redhead's Avatar
 
Join Date: Jun 2002
Location: Denmark
Posts: 1,694
redhead is on a distinguished road
I would say
Code:
eject("/dev/cdrom");
bu tthen again, I come from a *nix environment..
__________________
Don't worry Ma'am, We're university students, We know what We're doing.
-----
If you pull the pin, Mr.Grenade would no longer be your friend.
-----
01000111 01101111 00100000 01000011 00100000 00100001
redhead is offline   Reply With Quote
Old 06-17-2005, 05:43 PM   #4 (permalink)
DJMaze
Senior Contributor
 
DJMaze's Avatar
 
Join Date: Mar 2005
Posts: 651
DJMaze is on a distinguished road
Quote:
Originally Posted by redhead
I would say
Code:
eject("/dev/cdrom");
bu tthen again, I come from a *nix environment..
hmm i only used
Code:
umount /dev/brain
DJMaze is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
1GB Jump Drive - USB 2.0 sde Lounge 1 02-25-2005 05:18 PM
What do you drive? w00t Lounge 16 12-27-2002 04:39 PM
how do i zero out a drive? sde Linux / BSD / OS X 11 08-22-2002 07:44 AM
errors, .. hard drive related? sde Linux / BSD / OS X 1 07-31-2002 08:29 PM
detect o/s .. sde PHP 1 05-09-2002 04:59 PM


All times are GMT -8. The time now is 11:58 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting