CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Dec 2014
    Posts
    8

    USB Flash drive Partitioning

    I want to make 2 partitions in usb flash drive. How can a usb can be partitioned using c++, even if all partitions are not shown in windows OS.

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

    Re: USB Flash drive Partitioning

    For dealing with partitions I would suggest you look at some of the free software available rather than trying to write your own. I use Minitool Partition Wizard http://www.partitionwizard.com/
    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)

  3. #3
    Join Date
    Dec 2014
    Posts
    8

    Re: USB Flash drive Partitioning

    Quote Originally Posted by 2kaud View Post
    For dealing with partitions I would suggest you look at some of the free software available rather than trying to write your own. I use Minitool Partition Wizard http://www.partitionwizard.com/
    I need code in c++ please

  4. #4
    Join Date
    Dec 2014
    Posts
    8

    Re: USB Flash drive Partitioning

    I need code in c++ please

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

    Re: USB Flash drive Partitioning

    In Windows there is the DeviceIoControl() function (http://msdn.microsoft.com/en-us/libr...=vs.85%29.aspx). The Disk Management Control codes (http://msdn.microsoft.com/en-us/libr...=vs.85%29.aspx) include codes to get partition info and to set partition info (http://msdn.microsoft.com/en-us/libr...=vs.85%29.aspx).
    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)

  6. #6
    Join Date
    Apr 2000
    Location
    Belgium (Europe)
    Posts
    4,626

    Re: USB Flash drive Partitioning

    if you mean a memory stick. then those aren't partitioned, there's no provision for them to be partitioned. You could, in theory, design your own driver for a memory stick and do whatever you want, but it wouldn't be compatible with anything else.

    If you mean a USB based harddisk or SSD, then that's just normal disk partitioning whether it's USB or SATA or SAS or whatever system driving the drive.
    You can access that from C++ but you'd still have to do a lot of the low level stuff on your own. This would be your entrypoint for creating something like this;
    http://msdn.microsoft.com/en-us/libr...(v=vs.85).aspx

Tags for this Thread

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