PC Review


Reply
 
 
Jim Heavey
Guest
Posts: n/a
 
      26th Aug 2003
Is there some way for me to identify if a particular drive is a CDROM or a
Floppy drive or a local or network drive?




-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 100,000 Newsgroups - 19 Different Servers! =-----
 
Reply With Quote
 
 
 
 
Armin Zingler
Guest
Posts: n/a
 
      26th Aug 2003
"Jim Heavey" <(E-Mail Removed)> schrieb
> Is there some way for me to identify if a particular drive is a CDROM
> or a Floppy drive or a local or network drive?


Have a look at API function GetDriveType

VS 2003:
ms-help://MS.VSCC.2003/MS.MSDNQTR.2003FEB/fileio/base/getdrivetype.htm

(see hints in signature)



--
Armin

- Links might be split into two lines. Concatenate them using notepad.
- Links might require to add a ".nnnn" after the "2003FEB", e.g.
"2003FEB.1033" for localized versions.
- Links starting with "ms-help" are URLs for the document explorer (<F1>).
Paste them in the URL textbox and press enter. Using internal help (menu
tools -> options -> environment -> help), display the "Web" toolbar that
contains the textbox.

 
Reply With Quote
 
Herfried K. Wagner [MVP]
Guest
Posts: n/a
 
      26th Aug 2003
Hello,

"Jim Heavey" <(E-Mail Removed)> schrieb:
> Is there some way for me to identify if a particular drive is a CDROM or a
> Floppy drive or a local or network drive?


Set a reference to System.Management.dll

\\\
Imports System.Management
..
..
..
Public Enum DriveType
Unknown = 0
NoRootDirectory = 1
RemoveableDisk = 2
LocalDisk = 3
NetworkDrive = 4
CompactDisk = 5
RamDisk = 6
End Enum

Public Function GetDriveType(ByVal strDrive As String) As DriveType
strDrive = "Win32_LogicalDisk='" & strDrive.Substring(0, 2) & "'"
Dim moDisk As ManagementObject = New ManagementObject(strDrive)
Return _
DirectCast( _
[Enum].Parse(GetType(DriveType),
moDisk("DriveType").ToString()), _
DriveType _
)
End Function
..
..
..
Dim astrDrives() As String = Environment.GetLogicalDrives()
Dim strDrive As String
For Each strDrive In astrDrives
MessageBox.Show( _
"Drive: " & strDrive & ControlChars.NewLine & _
"Type: " & GetDriveType(strDrive).ToString() _
)
Next strDrive
///

HTH,
Herfried K. Wagner
--
MVP · VB Classic, VB .NET
http://www.mvps.org/dotnet


 
Reply With Quote
 
Jim Heavey
Guest
Posts: n/a
 
      29th Aug 2003
Thanks, works like a champ!!!!!

"Herfried K. Wagner [MVP]" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hello,
>
> "Jim Heavey" <(E-Mail Removed)> schrieb:
> > Is there some way for me to identify if a particular drive is a CDROM or a
> > Floppy drive or a local or network drive?

>
> Set a reference to System.Management.dll
>
> \\\
> Imports System.Management
> .
> .
> .
> Public Enum DriveType
> Unknown = 0
> NoRootDirectory = 1
> RemoveableDisk = 2
> LocalDisk = 3
> NetworkDrive = 4
> CompactDisk = 5
> RamDisk = 6
> End Enum
>
> Public Function GetDriveType(ByVal strDrive As String) As DriveType
> strDrive = "Win32_LogicalDisk='" & strDrive.Substring(0, 2) & "'"
> Dim moDisk As ManagementObject = New ManagementObject(strDrive)
> Return _
> DirectCast( _
> [Enum].Parse(GetType(DriveType),
> moDisk("DriveType").ToString()), _
> DriveType _
> )
> End Function
> .
> .
> .
> Dim astrDrives() As String = Environment.GetLogicalDrives()
> Dim strDrive As String
> For Each strDrive In astrDrives
> MessageBox.Show( _
> "Drive: " & strDrive & ControlChars.NewLine & _
> "Type: " & GetDriveType(strDrive).ToString() _
> )
> Next strDrive
> ///
>
> HTH,
> Herfried K. Wagner
> --
> MVP · VB Classic, VB .NET
> http://www.mvps.org/dotnet
>
>





-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 100,000 Newsgroups - 19 Different Servers! =-----
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
PCI-E Video card shows as "Unknown" device type in Device Manager? =?Utf-8?B?U3BlY3RyZS02Mw==?= Windows XP Hardware 5 13th Oct 2007 07:25 PM
Device Type missing from Device Manager =?Utf-8?B?cmprNDI=?= Windows Vista Hardware 9 1st Jul 2007 12:52 PM
Detect device type? Tomer Microsoft Dot NET Compact Framework 2 5th Dec 2005 03:20 PM
What is this type O' device called: punkonjunk1024 Audio / Video / Home Theatre 1 5th Oct 2005 11:43 PM
Device type Ted Bobic Windows XP General 1 17th Feb 2004 03:26 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:56 PM.