Results 1 to 8 of 8

Thread: how to get all the drives in a computer?

  1. #1

    Thread Starter
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729

    how to get all the drives in a computer?

    how do i do that? do i have to use api for it?
    \m/\m/

  2. #2
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704
    I believe you can use the System.Management.ManageMentClass to retrieve that information.

    I remember seeing an excerpt on MSDN where it retrieved all drives using 3 lines of code, something akin to below:

    Code:
    using System;
    using System.Management;
    // Disktypes - NoRoot = 1; Removable = 2; LocalDisk = 3; Network = 4; CD = 5; RAMDrive = 6;
    public class Wmis {
    public static void Main() {
    ManagementClass disks = new ManagementClass("Win32_LogicalDisk");
    ManagementObjectCollection moc = disks.GetInstances();
    foreach(ManagementObject mo in moc)
    {
    Console.WriteLine("Disk type\t{0}", mo["DriveType"].ToString());
    mo.Dispose();
    }
    disks.Dispose();
    }
    }

  3. #3

    Thread Starter
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    ty all try it when i get home
    \m/\m/

  4. #4
    Frenzied Member dynamic_sysop's Avatar
    Join Date
    Jun 2003
    Location
    Ashby, Leicestershire.
    Posts
    1,142
    VB Code:
    1. Dim strDrives As String() = Environment.GetLogicalDrives()
    2.         Dim drive As String
    3.         For Each drive In strDrives
    4.             Console.WriteLine(drive)
    5.         Next
    ~
    if a post is resolved, please mark it as [Resolved]
    protected string get_Signature(){return Censored;}
    [vbcode][php] please use code tags when posting any code [/php][/vbcode]

  5. #5
    Addicted Member GSIV's Avatar
    Join Date
    Jun 2002
    Location
    Texas, USA
    Posts
    213
    dynamic_sysop, you're like an encyclopedia of useful stuff. Thanks for contributing so generously in the forums.

  6. #6
    Addicted Member GSIV's Avatar
    Join Date
    Jun 2002
    Location
    Texas, USA
    Posts
    213
    And you too Nemaroller

  7. #7
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704
    Oh, if you ever want to see some funny stuff, just do a search by username, and click to the last page of the search result.

  8. #8
    Frenzied Member
    Join Date
    Nov 2003
    Posts
    1,489
    Originally posted by GSIV
    dynamic_sysop, you're like an encyclopedia of useful stuff. Thanks for contributing so generously in the forums.
    no kidding. He has the best answers!! Where do you get your info from? I look at the msdn and can't decrypt it for crap!!


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width