Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 692613
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T02:40:08+00:00 2026-05-14T02:40:08+00:00

I have those partitions (in Windows) for example: Hard Disk 1 – Partition C,

  • 0

I have those partitions (in Windows) for example:

Hard Disk 1 - Partition C, Partition D
Hard Disk 2 - Partition E

Is there any way in a program language to know if for example partition C and partition D are in one physical hard disk without WMI?

I don’t want to use WMI because it’s slow – for this example, it took for me 0.5 seconds. I need it to be fast.

Thank you.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T02:40:08+00:00Added an answer on May 14, 2026 at 2:40 am

    I don’t know of any other managed way to get disk partition information.
    You may use the Win32 API using P/Invoke from C#. However, you shouldn’t unless it’s absolutely necessary.

    The Win32 function you’ll need is called DeviceIoControl(). The API documentation can be found at http://msdn.microsoft.com/en-us/library/aa363216(VS.85).aspx. Call DeviceIoControl() with the control code IOCTL_STORAGE_GET_DEVICE_NUMBER and you’ll get the physical disk drive for the given partition device handle. The device handle for the partition can be retrieved using CreateFile() API.

    However, using DeviceIoControl() is cumbersome and you will most likely have to make different versions for the 32-bit and 64-bit versions of Windows.

    To retrieve all partitions you may use the managed code System.IO.DriveInfo like this:

    var x = from di in DriveInfo.GetDrives()
            where (di.DriveType == DriveType.Fixed)
            select di;
    
    foreach (DriveInfo di in x)
    {
        // Call DeviceIoControl() using the partition name from di.Name and the IOCTL_STORAGE_GET_DEVICE_NUMBER  control code to retrieve the physical disk
    }
    

    It seems pinvoke.net has some signatures for C#.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have Windows 7 and Ubuntu 10.10 partitions on my hard drive, and have
Suppose multiple Modal Windows shown above each other. All of those have ShowInTaskbar =
At work, we have one of those nasty communal urinals. There is no flush
I have set of non-unique numbers and would like to partition those numbers into
I have a conceptual question. Suppose I have a procedure (any language) which takes
There are 16 partitions for a fact table. All 16 of them have the
I have those maps in my repository. public IQueryable<AwType> GetAwTypes() { return from awt
I have those two tables: client: id (int) #PK name (varchar) client_category: id (int)
Suppose that I have those three files: a.h //a.h header #include <stdio.h> int int_variable;
Say i have those 3 arrays : Product(milk,candy,chocolate) Colors(white,red,black) Rating(8,7,9) How to create a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.