Solved

Check CDROM has a cd in it

Posted on 2001-09-04
6
171 Views
Last Modified: 2013-12-03
i have a function in VB to get all cd rom drives and list them, how can i make sure it has a cd in it before listing all files etc?
0
Comment
Question by:Kunt
  • 2
6 Comments
 
LVL 31

Expert Comment

by:Zoppo
ID: 6456608
Hi Kunt,

you could simply call some function which fails if no cd is in drive, i.e. GetDiskFreeSpace.

ZOPPO
0
 

Author Comment

by:Kunt
ID: 6459119
yeh, thats what i already do, i was wondering if there is nice tidy function for it?
0
 
LVL 31

Expert Comment

by:Zoppo
ID: 6459768
well, I didn't find an extra function for this ... some samples use something like

HANDLE  hCD;
hCD = CreateFile ("\\\\.\\F:", GENERIC_READ,
 FILE_SHARE_READ|FILE_SHARE_WRITE,
 NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL,
 NULL);
if (hCD != INVALID_HANDLE_VALUE)
{
 // ok, disk in drive...
}
CloseHandle (hCD);

further I found you can handle message WM_DEVICECHANGE which is sent
to top-level windows whenever a disk is inserted/removed and some other
reasons.

ZOPPO      
0
 

Accepted Solution

by:
modulo earned 0 total points
ID: 10680069
PAQed, with points refunded (50)

modulo
Community Support Moderator
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows a few slightly more advanced techniques for Windows 7 gadget programming, including how to save and restore user settings for your gadget and how to populate the "details" panel that is displayed in the Windows 7 gadget gallery.  …
This article surveys and compares options for encoding and decoding base64 data.  It includes source code in C++ as well as examples of how to use standard Windows API functions for these tasks. We'll look at the algorithms — how encoding and decodi…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

816 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now