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 6627137
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T21:58:40+00:00 2026-05-25T21:58:40+00:00

I want to get a list of physical storage devices. I’ve seen some code

  • 0

I want to get a list of physical storage devices.
I’ve seen some code but that actually loops and does something like brute force.
I want to know what is the general way of getting the list of physical storage disks.

I’ve found CreateFile(). But I cannot understand how to use it properly. I need a non-wmi solution. and it’s better if it doesn’t query registry.

  • 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-25T21:58:41+00:00Added an answer on May 25, 2026 at 9:58 pm

    I’ve used the following code, that enumerates all the volumes and then looks for their corresponding physical drives:

    #include <windows.h>
    #include <commctrl.h>
    #include <winioctl.h>
    
    typedef struct _STORAGE_DEVICE_NUMBER {
      DEVICE_TYPE  DeviceType;
      ULONG  DeviceNumber;
      ULONG  PartitionNumber;
    } STORAGE_DEVICE_NUMBER, *PSTORAGE_DEVICE_NUMBER;
    
    void PrintVolumes()
    {
        char volName[MAX_PATH];
        HANDLE hFVol;
        DWORD bytes;
    
        hFVol = FindFirstVolume(volName, sizeof(volName));
        if (!hFVol)
        {
            printf("error...\n");
            return;
        }
        do
        {
            size_t len = strlen(volName);
            if (volName[len-1] == '\\')
            {
                volName[len-1] = 0;
                --len;
            }
    
            /* printf("OpenVol %s\n", volName); */
            HANDLE hVol = CreateFile(volName, 0, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL);
            if (hVol == INVALID_HANDLE_VALUE)
                continue;
    
            STORAGE_DEVICE_NUMBER sdn = {0};
            if (!DeviceIoControl(hVol, IOCTL_STORAGE_GET_DEVICE_NUMBER, NULL,
                        0, &sdn, sizeof(sdn), &bytes, NULL))
            {
                printf("error...\n");
                continue;
            }
            CloseHandle(hVol);
    
            printf("Volume Type:%d, Device:%d, Partition:%d\n", (int)sdn.DeviceType, (int)sdn.DeviceNumber, (int)sdn.PartitionNumber);
            /* if (sdn.DeviceType == FILE_DEVICE_DISK)
                printf("\tIs a disk\n");
                */
        } while (FindNextVolume(hFVol, volName, sizeof(volName)));
        FindVolumeClose(hFVol);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to get a list of files in a directory, but I want
I want to get a list of all available datasets (that I'd creat in
I want to get a list of all sub-directories within a directory. If that
I want to get a list of applications and their output ports for some
I want to get a list of all words in a Lucene index that
I want o get a list of all the radio buttons that are contained
I want to get list from server it is taking some time So at
I want to get a list of objects which doesn't have some style name
I want to get a list of result sets and columns that i can
I want to get list of Domino Servers on the network, and accordingly login

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.