Click here to Skip to main content
15,889,216 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
AnswerRe: Get moving mouse position Pin
freakyit11-Oct-09 22:36
freakyit11-Oct-09 22:36 
GeneralRe: Get moving mouse position Pin
Luc Pattyn12-Oct-09 0:20
sitebuilderLuc Pattyn12-Oct-09 0:20 
GeneralRe: Get moving mouse position Pin
freakyit12-Oct-09 1:04
freakyit12-Oct-09 1:04 
QuestionGetting cd/dvd drive information Pin
offroaderdan11-Oct-09 4:42
offroaderdan11-Oct-09 4:42 
AnswerRe: Getting cd/dvd drive information Pin
Henry Minute11-Oct-09 5:12
Henry Minute11-Oct-09 5:12 
GeneralRe: Getting cd/dvd drive information Pin
offroaderdan11-Oct-09 5:39
offroaderdan11-Oct-09 5:39 
GeneralRe: Getting cd/dvd drive information Pin
Henry Minute11-Oct-09 6:00
Henry Minute11-Oct-09 6:00 
AnswerRe: Getting cd/dvd drive information [modified] Pin
Luc Pattyn11-Oct-09 6:12
sitebuilderLuc Pattyn11-Oct-09 6:12 
Apart from WMI, there is no managed code only solution to this. However you could use P/Invoke technology to call a native function inside kernel32.dll; in C# it would look somewhat like this:

C#
// start file with
using System.Runtime.InteropServices;		// DllImport

// and inside one class, put:

[DllImport("kernel32.dll")]
public static extern int GetDriveType(string rootPathName);

public void CheckAllDrives() 
    foreach(string deviceLetter in Environment.GetLogicalDrives()) {
        if (GetDriveType(deviceLetter)==5) Console.WriteLine(deviceLetter+" is a CD or DVD drive");
    }
}


and in VB.NET it would resemble this (not tested):

VB
' start file with
Imports System.Runtime.InteropServices         ' DllImport

' and inside one class, put:

Declare Shared int GetDriveType Lib "kernel32.dll" (ByVal rootPathName As String)

public Sub CheckAllDrives()
    For Each(deviceLetter as String in Environment.GetLogicalDrives())
        if (GetDriveType(deviceLetter) = 5) Console.WriteLine(deviceLetter & " is a CD or DVD drive");
    Next
End Sub



BTW: there might be multiple CD/DVD drives in a system.

Smile | :)

Luc Pattyn

I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages

Local announcement (Antwerp region): Lange Wapper? Neen!


modified on Sunday, October 11, 2009 12:18 PM

AnswerRe: Getting cd/dvd drive information Pin
Alan N11-Oct-09 6:43
Alan N11-Oct-09 6:43 
GeneralRe: Getting cd/dvd drive information Pin
offroaderdan11-Oct-09 6:53
offroaderdan11-Oct-09 6:53 
GeneralRe: Getting cd/dvd drive information Pin
Alan N12-Oct-09 5:01
Alan N12-Oct-09 5:01 
Questionapplication server implementation Pin
Ryan Minor11-Oct-09 2:07
Ryan Minor11-Oct-09 2:07 
AnswerRe: application server implementation Pin
Eddy Vluggen11-Oct-09 3:16
professionalEddy Vluggen11-Oct-09 3:16 
Question.NET Framework Pin
CeremBeyazit10-Oct-09 9:10
CeremBeyazit10-Oct-09 9:10 
AnswerRe: .NET Framework Pin
Not Active10-Oct-09 10:27
mentorNot Active10-Oct-09 10:27 
AnswerRe: .NET Framework Pin
Luc Pattyn10-Oct-09 10:57
sitebuilderLuc Pattyn10-Oct-09 10:57 
QuestionSetting the form location manually Pin
lbs.allies9-Oct-09 23:58
lbs.allies9-Oct-09 23:58 
AnswerRe: Setting the form location manually Pin
Luc Pattyn10-Oct-09 1:05
sitebuilderLuc Pattyn10-Oct-09 1:05 
AnswerRe: Setting the form location manually Pin
Shameel19-Oct-09 0:14
professionalShameel19-Oct-09 0:14 
QuestionProblems with visual studio 2003 Pin
shylock18-Oct-09 8:28
shylock18-Oct-09 8:28 
AnswerRe: Problems with visual studio 2003 Pin
Suresh Suthar9-Oct-09 18:39
professionalSuresh Suthar9-Oct-09 18:39 
QuestionStrong Signing Assembly Effection desired functionality Pin
vineetrawathcl8-Oct-09 0:11
vineetrawathcl8-Oct-09 0:11 
AnswerRe: Strong Signing Assembly Effection desired functionality Pin
Rob Graham10-Oct-09 4:59
Rob Graham10-Oct-09 4:59 
QuestionMany .NET Frameworks related files installed on my computer , which one to remove ? Pin
unitecsoft7-Oct-09 13:42
unitecsoft7-Oct-09 13:42 
AnswerRe: Many .NET Frameworks related files installed on my computer , which one to remove ? Pin
Not Active7-Oct-09 14:21
mentorNot Active7-Oct-09 14:21 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.