- Home /
Detecting CD-ROM drives
Im trying to integrate our current security algorithms in Unity, this would require me to detect all the cd drives on the users computer. I Found two ways to do it in C#: Using ManagementObjectSearcher to query WMI, or using System.IO.DriveInfo.GetDrives(), but I get "NotImplementedException: The requested feature is not implemented." when using either.
Cannot you try:
for (int i = (int)'a';i<(int)'z';i++) {
FileInfo f = new FileInfo(Char.ToUpper((char)i)+":\\");
if (f.Exists)
Debug.Log("File "+f.ToString()+" exists, insert code here.");
}
Also, make sure it is not in web player mode. If it is, then none of the file functions will work or compile. I noticed that if you build a web player version of your game, then running it in the editor is also considered web player mode. If you build again for pc standalone, then the editor is in pc standalone mode. I consider that a bug in Unity, there is no other way to change the mode that the editor is running with.
This method only works on windows- searching for device drivers would be more cross-platform (and after all, Unity is all about the cross-plateform). I only ever get those non-implemented exceptions when I try to modify my scripts at runtime- I'm not really sure what causes them.
@syclamoth NotImplementedExceptions are used when you declare a method but you do not implement it(it doesn't actually do anything). To make sure people know it doesn't do anything you throw a not implemented exception.
@msknapp Thanks for the suggestion but that would help me only to find every drive, without being able to decide if it is a CD-RO$$anonymous$$. Please note that the solution I am looking for only needs to work for Windows stand alone player.
Thanks
Answer by DukeW · Sep 26, 2011 at 02:40 PM
Hey, just an update, I found a solution to my problem.(Again i mention that I was only looking for a solution for Windows stand alone player). I called the following command: wmic /OUTPUT:%TEMP%\\cdRomInfo.txt PATH Win32_CDROMDrive GET /VALUE /FORMAT:csv, this outputs a csv formatted txt file in the current users temp folder wich contains a bunch of info about the CD-Rom drives. (it can also give lots of technical info about other hardware components like processor, RAM etc)
@chiuan Ill try. I created a new batch file(.bat) containing the command "wmic /OUTPUT:%TE$$anonymous$$P%\cdRomInfo.txt PATH Win32_CDRO$$anonymous$$Drive GET /VALUE /FOR$$anonymous$$AT:csv" witch basically creates a csv formatted file in the current users temp directory called cdRomInfo.txt, that contains info on all CD RO$$anonymous$$ drives Windows is aware of.I parsed the file to find the drives I was interested in using some code i found by simply googleing parsing CSV C#. And yes this can also be applied for other devices, because I am guessing that's what interests you.
Your answer
Follow this Question
Related Questions
xCode to Unity communication? 1 Answer
Can Unity3D run without hardware acceleration? 1 Answer
Baking with Beast, XEON v. i7 ? 0 Answers
access to hardware information for licensing an app. 0 Answers