Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 178
  • 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

Featured Post

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

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