Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Cd Detection to start App

Cd Detection to start App

Scheduled Pinned Locked Moved C#
csharpquestionvisual-studio
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    antoine orchus tech
    wrote on last edited by
    #1

    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!"

    M 1 Reply Last reply
    0
    • A antoine orchus tech

      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!"

      M Offline
      M Offline
      Meysam Mahfouzi
      wrote on last edited by
      #2

      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!

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups