From:	SMTP%"htolley@lardav.com" 20-NOV-1997 18:08:51.28
To:	ntdev@atria.com
CC:	
Subj:	Re: [ntdev] CD-ROM disc presence

Return-Path: owner-ntdev@atria.com
Received: by arisia.gce.com (UCX V4.1-12C, OpenVMS V7.1 VAX);
	Thu, 20 Nov 1997 18:08:42 -0500
Received: by gw.atria.com id <NAA16834@gw.atria.com> Thu, 20 Nov 1997 13:47:57 -0500    
Received: from pub.lardav.com by gw.atria.com id <NAA16798@gw.atria.com> Thu, 20 Nov 1997 13:47:49 -0500    
Received: from dino.lardav.com (mailhost.54.141.207.in-addr.arpa [207.141.54.45] (may be forged)) by pub.lardav.com (8.8.8/8.8.3) with SMTP id LAA19496 for <ntdev@atria.com>; Thu, 20 Nov 1997 11:20:58 -0700 (MST)
Received: from lardav.com by dino.lardav.com (SMI-8.6/SMI-SVR4)
	id LAA22483; Thu, 20 Nov 1997 11:47:06 -0700
Received: from LDI/SpoolDir by lardav.com (Mercury 1.21);
    20 Nov 97 11:47:07 -0700
Received: from SpoolDir by LDI (Mercury 1.30); 20 Nov 97 11:46:40 -0700
From: "Hal D. Tolley ... Sensar" <htolley@lardav.com>
Organization: Larson-Davis, Inc.
To: ntdev@atria.com
Date: Thu, 20 Nov 1997 11:46:32 MST7MDT
Subject: Re: [ntdev] CD-ROM disc presence
Reply-to: htolley@lardav.com
In-reply-to: <01bcf58c$e97ed040$fcb95ac2@ilya.any.com>
X-mailer: Pegasus Mail for Windows (v2.53/R1)
Message-ID: <2E4FCD74F3A@lardav.com>
Sender: owner-ntdev@atria.com
Precedence: bulk

> From:          "Ilya " <ilya@any.com>
> To:            <ntdev@atria.com>
> Subject:       [ntdev] CD-ROM disc presence
> Date:          Thu, 20 Nov 1997 10:18:42 +0200

> Hi 
> I'm trying to open file on compact disc in CD-ROM drive.
> If disc is not present in drive some drivers throw ASSERT MessageBox
> If it is possible to get notification about the presence of disc in drive and avoid this Assert message ?
> Ilya Shpilberg 
> ilya@any.com
> 


Try this code snipet.
Of course you will need to alter argument 1 in CreateFile
to corespond to the CD-ROM drive letter but this code has been 
verified on my system.


#include <winioctl.h>

void FooBar()
	{
	HANDLE hCD;
 	BOOL bMedia;
 	DWORD dwBytes;

 	hCD = CreateFile("\\\\.\\J:", GENERIC_READ, FILE_SHARE_READ |
 		FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 
		NULL);

 	bMedia = DeviceIoControl(hCD, IOCTL_DISK_CHECK_VERIFY, NULL, 0, 
		NULL, 0, &dwBytes, NULL);


	// if bMedia == 1 then there is a CD in the drive else not

 	CloseHandle(hCD);
 	}


-Hal
 
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
[ To unsubscribe, send email to ntdev-request@atria.com with body
UNSUBSCRIBE (the subject is ignored). ]
