Cd Detection to start App
-
Hi! Here is my question What is the code or method to detect the application's CD when the user install or start the application? Since the application must access the videos that are in the CD, I need the app to automatically detect where it's cd is, and if possible, have the cd's file uncopyable ;) Thanks! Antoine ps.: I'm writing a c# app with Visual Studio 2002 Ent, .NET 1.1, on winXP and for WinXP/2K. This by our hands that dream, "I shall find a way or make one!"
-
Hi! Here is my question What is the code or method to detect the application's CD when the user install or start the application? Since the application must access the videos that are in the CD, I need the app to automatically detect where it's cd is, and if possible, have the cd's file uncopyable ;) Thanks! Antoine ps.: I'm writing a c# app with Visual Studio 2002 Ent, .NET 1.1, on winXP and for WinXP/2K. This by our hands that dream, "I shall find a way or make one!"
First retrieve logical disks, If one of them has driveType 5 then it is a cdrom. Try to locate a file that you know your cd-rom contains. you should also use System.Management in your code, i mean add it in references section of your project. Here is the code:
ManagementClass disks = New ManagementClass("Win32_LogicalDisk");
ManagementObjectCollection moc = disks.GetInstances();
ManagementObject mo;
foreach(mo in moc){
if(mo["DriveType"].ToString() == "5"){
if(System.IO.File.Exists(mo["Name"].ToString + "\somefile.ext"){
MessageBox.Show("Correct disk in cdrom drive")
}
}
}
disks.Dispose()I hope this helps
Don't forget, that's
Persian Gulf
not Arabian gulf!