Help Me PLease

fainaqvi

Member
Joined
Aug 23, 2005
Messages
5
Programming Experience
1-3
Hi,

any one please help me my problem is

How can i find out Specific CD ROM Path with CD Label.In other words i create a software but i wanna restrict it to run meanz if my software CD is in CD ROM then software hv to run otherwise it give u error no CD Found IN CD ROM Please insert CD.if u hv any code sample please tell me
 
Last edited by a moderator:
Ok, i guess it is best if you are checking certain file stored on CD/DVD ... if it's not there you can abort your app otherwise, it is going to run. You could use a CurDir function (Explanation: CURDIR reports the current directory) to get drive information from whereever the program was launched from but there are many users that have turned off autorun so you should care to get info about CD/DVD rom manualy.

This GetDriveType API function will help you to find first CD drive.

VB.NET:
Private[/color][/size][size=2][color=#0000ff]Declare[/color][/size][size=2][color=#0000ff]Function[/color][/size][size=2][color=#000000] GetDriveType [/color][/size][size=2][color=#0000ff]Lib[/color][/size][size=2][color=#000000] "kernel32" [/color][/size][size=2][color=#0000ff]Alias[/color][/size][size=2][color=#000000] "GetDriveTypeA" ([/color][/size][size=2][color=#0000ff]ByVal[/color][/size][size=2][color=#000000] nDrive [/color][/size][size=2][color=#0000ff]As[/color][/size][size=2][color=#0000ff]String[/color][/size][size=2][color=#000000]) [/color][/size][size=2][color=#0000ff]As[/color][/size][size=2][color=#0000ff]Integer

'let me know if you need a help to use this func.

Later just check if there is a file you are looking for. Or much easier start new process against certain file. If process is nothing close your app.

Sorry about my english i know i sound like a Mr. Miyagi cast from the movie "The Karate Kid" :D


Cheers ;)
 
Thankx for ur reply but im still in problem

Hi,
Thankx for ur reply but sir im still in problem problem is that i jst want to know that how can i get only CD ROM path in VB.Net like i want CD Letter jst for my software because the database is on CD i jst want thta when my software start its auto detect the my CD in CD ROM
Help me plz
 
VB.NET:
Private Declare Function GetDriveType Lib "kernel32" Alias "GetDriveTypeA" (ByVal nDrive As String) As Integer

Private Const DRIVE_CDROM = 5 

Private Function FirstCDDrive() As String

Dim ascA As Integer = 65

Dim ascZ As Integer = ascA + 25

Dim i As Integer

For i = ascA To ascZ

If GetDriveType(Chr(i) & ":\") = DRIVE_CDROM Then

FirstCDDrive = Chr(i) & ":\"

Exit For

End If

Next

End Function

this is the function how to find cd/dvd drive ... then just check for the files you have stored on cd. Wait a minute ... you said that DB is stored on CD !? it doesn't make much sense to me because you cannot work with such db except read only but probaly you know something more than i know

Cheeers ;)
 
Hi
thankx again ur code solve my half problem sir but if some person hv 2 cd romz or hv 1 cd rom and 1 CD writer and he insert cd in writer then ? because i run this code on my pc it jst detect cd rom not writer i insert my cd in writer but its not detecting my cd.
thankx
 
You could alter the code a little to try each CD drive for a certain file on the CD, like he was saying. So run through each CD drive his code finds and check each for a special file you put on it. The one with that file is the one with your CD in it.

Edit: You were saying how to check the label of the CD to verify that it's your CD. While that works as a verification, it's better to check for a special file you put on there because there is a possibility that some other CD could have the same label. Then making the assumption that it's yours could run into trouble.

Maybe a combination of the CD label and a special file is best. But if your file (name, location, and perhaps it's content) is specific enough you should have no problem identifying that it's your CD.
 
Last edited:
i have a similiar question regarding detecting drive types

how would one check the see if a particular drive is Removable Media (as in Flash Drive, Pen Drive, Etc..)

of course with it being removable media the flash drive wont always be plugged in but if it is plugged in, how would i go about seeing if it's there?
 
JuggaloBrotha said:
i have a similiar question regarding detecting drive types

how would one check the see if a particular drive is Removable Media (as in Flash Drive, Pen Drive, Etc..)

of course with it being removable media the flash drive wont always be plugged in but if it is plugged in, how would i go about seeing if it's there?
I haven't looked at this stuff in detail JB, but I think it's the place for you to start: http://msdn.microsoft.com/library/d...t/fs/removable_storage_manager.asp?frame=true
 
Back
Top