473,383 Members | 1,813 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

Problem in accessing cd drives

88 64KB
Hi friends,
I have got two problems while accessing cd drives.

FIRSTLY: I want a code example of how to detect whether the cd drive of my machine is opened or closed.

SECONDLY: I'm trying to open or close the cd drive of my machine. It's working properly if there's only one cd drive. But wut if there r more than one. The code I'm using is accessing the default cd drive only. Below is the code I'm using:

Expand|Select|Wrap|Line Numbers
  1. 'In the general declarations:
  2. '----------------------------------------
  3. Option Explicit
  4.  
  5. Private Declare Function mciSendString Lib "winmm.dll" _
  6. Alias "mciSendStringA" (ByVal lpstrCommand As String, ByVal _
  7. pstrReturnString As String, ByVal uReturnLength As Long, ByVal _
  8. wndCallback As Long) As Long
  9.  
  10.  
  11. 'The procedure that performs the cd drive door open/close operation
  12. '-------------------------------------------------------------------------------------------------
  13. Public Sub OpenOrShutCDDrive(DoorOpen As Boolean)
  14.  
  15. Dim lRet As Long
  16.  
  17. If DoorOpen Then
  18.     lRet = mciSendString("Set CDAudio Door Open", 0&, 0&, 0&)
  19. Else
  20.     lRet = mciSendString("Set CDAudio door closed", 0&, 0&, 0)
  21. End If
  22.  
  23. 'lRet will = 0 upon success, so if you want to make this 
  24. 'a function, return true if lret = 0, false otherwise
  25.  
  26. End Sub
  27.  
  28.  
  29.  
  30. 'In Button1_click event:
  31. '-----------------------------------
  32. 'Parameter for calling the following procedure will be true or false
  33. Call OpenOrShutCDDrive(True)
Now, how can I open/close the cd drive of my choice? Should I have to provide the path name of the drive then how to do it? Please help.
Feb 26 '08 #1
1 1204
debasisdas
8,127 Expert 4TB
Please find related discussion here and here .
Feb 27 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Jon1996 | last post by:
How do you access the volume label for a hard drive through C#? I am very much a beginner with C# at the moment and am developing a windows explorer program to help me learn. I have tried the...
3
by: Bonj | last post by:
I have a service which is a Windows Service, but it is running under a User account - I enter my own credentials on installing. It can access network files by specifying the full UNC path, i.e....
1
by: Shreeram Natarajan | last post by:
Hi, Can anyone tell me how to get the list of USB flash drives attached to the system programmatically using C#? Thanks Shreeram Natarajan
4
by: Jedi10180 | last post by:
I am trying to open a pdf file from a CD in my VB app. I'm using System.Diagnositcs.Process.Start to open the file, but I can't use d:\file.pdf because not all cd-rom drives are named d:\. How can...
5
by: =?Utf-8?B?SmVmZiBCZWVt?= | last post by:
Before you respond with "just use GetShortPathName" please read the rest. We have an application that places files on a file server using mapped drives as it's path of choice. The reason for...
0
by: dodger_web | last post by:
Hi, I want to setup a web server which runs IIS 6.0 + Asp.net 2.0 and windows services for unix 3.5. The asp.net is suposed to run localy, but requires files which reside on a nfs server. ...
1
by: martin lanny | last post by:
My application should periodically connect to multiple network drives to see if the certain files were created. I would do this to retrieve the list of files in UNC path //server1/backup/: ...
19
by: cj | last post by:
I'm getting terrible response times trying to pull data from VFP tables using .net--like 2 minutes! Can someone help? f:\arcust01 currently contains 187,728 records and is indexed on CUSTNO...
4
by: nmsreddi | last post by:
Hi Friends, I want to develop a windows service ,such that it should access all the Mapped drives to the server in WAN. I am using windows 2003 Server R2 ,where we an option of DFS but any...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.