CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Jan 2009
    Posts
    399

    [RESOLVED] Find device partition type

    Is there any way to know what type is a HDD device ? I need to test if a HDD partition has a specific type: NTFS, or FAT32 or EXFAT.

    From my researches I read that there is a structure that can be filled with this information: FILE_SYSTEM_RECOGNITION_STRUCTURE, taken from here: https://docs.microsoft.com/en-us/win...em-recognition But I don't know how to fill this structure: FILE_SYSTEM_RECOGNITION_STRUCTURE. Is there another way to achieve this information ?

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,396

    Re: Find device partition type

    And where did you read that this struct contains any value that points to the type of a HDD device?
    typedef struct _FILE_SYSTEM_RECOGNITION_STRUCTURE {
    UCHAR Jmp[3];
    UCHAR FsName[8];
    UCHAR MustBeZero[5];
    ULONG Identifier;
    USHORT Length;
    USHORT Checksum;
    } FILE_SYSTEM_RECOGNITION_STRUCTURE;
    Victor Nijegorodov

  3. #3
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: Find device partition type

    Use WMI, it gives drive info plus a whole lot more.

  4. #4
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,824

    Re: Find device partition type

    Given the root directory name for the required device, use GetVolumeInformation(). The name of the type of format is returned via lpFileSystemNameBuffer.

    https://docs.microsoft.com/en-us/win...meinformationa
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++23 Compiler: Microsoft VS2022 (17.6.5)

  5. #5
    Join Date
    Jan 2009
    Posts
    399

    Re: Find device partition type

    All solution proposed by you are working well ! I've used the simplest one: https://docs.microsoft.com/en-us/win...meinformationa

    Thank you all !

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

Featured