.Net判断系统分区类型(如判断CDRom盘符)。

来源:互联网 发布:数据库主键和索引 编辑:程序博客网 时间:2024/06/05 16:33

看到有人询问如何判断哪个分区盘符是光驱,我将自己的代码总结了一下,方法如下:

首先你要引用Scripting.dll这个组件,这是个COM组件。

        Dim MF As New Scripting.FileSystemObject
        Dim MD As Scripting.Drive

        For Each MD In MF.Drives
            If MD.DriveType = Scripting.DriveTypeConst.CDRom Then
                MsgBox("This Is CDRom", MsgBoxStyle.Information, "DriveTest")
            End If

        Next MD