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. how to findout which drive is a cool disk?

how to findout which drive is a cool disk?

Scheduled Pinned Locked Moved C#
tutorialquestion
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.
  • F Offline
    F Offline
    Fred 34
    wrote on last edited by
    #1

    Is there any function to return the kind of drive?

    L 1 Reply Last reply
    0
    • F Fred 34

      Is there any function to return the kind of drive?

      L Offline
      L Offline
      Luc Pattyn
      wrote on last edited by
      #2

      Hi, I know three ways to get some information on physical devices: 1. using the DriveInfo class 2. using WMI, have a look at the WMI classes Win32_DiskDrive, Win32_LogicalDiskToPartition, Win32_PhysicalMedia, Win32_CDROMDrive; which ones you want depends on the information you need. warning: not everything may be available to regular users under Vista/Win7 without going trough the UAC dialog. 3. using Win32 functions (from kernel32.dll), which requires P/Invoke. Here is an example prototype:

      	/// /// Gets the drive type
      	/// 
      	/// drive name (letter colon backslash)
      	/// /// 0 (DRIVE\_UNKNOWN) The drive type cannot be determined. 
      	/// 1 (DRIVE\_NO\_ROOT\_DIR) The root path is invalid. (no volume is mounted at the path). 
      	/// 2 (DRIVE\_REMOVABLE) The disk can be removed from the drive. 
      	/// 3 (DRIVE\_FIXED) The disk cannot be removed from the drive. 
      	/// 4 (DRIVE\_REMOTE) The drive is a remote (network) drive. 
      	/// 5 (DRIVE\_CDROM) The drive is a CD-ROM drive. 
      	/// 6 (DRIVE\_RAMDISK) The drive is a RAM disk. 
      	/// 
      	\[DllImport("kernel32.dll")\]
      	public static extern int GetDriveType(string rootPathName);
      

      For each of these, I refer to the MSDN documentation, Google, and some experimentation. :)

      Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum

      Please use <PRE> tags for code snippets, they preserve indentation, and improve readability.

      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