• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 180
  • Last Modified:

Check CDROM has a cd in it

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
Kunt
Asked:
Kunt
  • 2
1 Solution
 
ZoppoCommented:
Hi Kunt,

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

ZOPPO
0
 
KuntAuthor Commented:
yeh, thats what i already do, i was wondering if there is nice tidy function for it?
0
 
ZoppoCommented:
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
 
moduloCommented:
PAQed, with points refunded (50)

modulo
Community Support Moderator
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now