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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T07:59:18+00:00 2026-06-09T07:59:18+00:00

I am trying to initialize and partition an attached virtual hard disk through the

  • 0

I am trying to initialize and partition an attached virtual hard disk through the Windows API. I have been successful using DeviceIoControl() to do so, however whenever I apply the desired drive layout Windows is automatically assigning a drive letter to the partition and popping up an annoying “Would you like to format?” dialog.

My intent is to handle the formatting and mounting of this partition later in the program, but I’m not sure how to stop this behavior. I have tried setting RecognizedPartition to FALSE, but this seems to have no effect.

Relevant code:

Layout.PartitionStyle = PARTITION_STYLE_MBR;
Layout.PartitionCount = 4;
Layout.Mbr.Signature = MY_DISK_MBR_SIGNATURE;
Layout.PartitionEntry[0].PartitionStyle = PARTITION_STYLE_MBR;
Layout.PartitionEntry[0].PartitionNumber = 1;
Layout.PartitionEntry[0].StartingOffset.QuadPart = MY_DISK_OFFSET;
Layout.PartitionEntry[0].PartitionLength.QuadPart =
   (Geom.DiskSize.QuadPart - MY_DISK_OFFSET);
Layout.PartitionEntry[0].Mbr.PartitionType = PARTITION_IFS;
Layout.PartitionEntry[0].Mbr.BootIndicator = FALSE;
Layout.PartitionEntry[0].Mbr.RecognizedPartition = FALSE;
Layout.PartitionEntry[0].Mbr.HiddenSectors =
   (MY_DISK_OFFSET / Geom.Geometry.BytesPerSector);

for (int i = 0; i < 4; i++)
{
    Layout.PartitionEntry[i].RewritePartition = TRUE;
}

if (!DeviceIoControl(hDisk, IOCTL_DISK_SET_DRIVE_LAYOUT_EX,
                     Layout, dwLayoutSz, NULL, 0, &dwReturn, NULL))
{
    // Handle error
}
DeviceIoControl(hDisk, IOCTL_DISK_UPDATE_PROPERTIES,
                NULL, 0, NULL, 0, &dwReturn, NULL);

What can I do to prevent automatic drive letter assignment?

  • 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-06-09T07:59:20+00:00Added an answer on June 9, 2026 at 7:59 am

    The only reliable way I could find to work around this issue was to stop the “Shell Hardware Detection” service while the volume was created and formatted. However, this approach is so unapologetically silly that I refused to put it into code.

    Another “hackish” option is to have the service start up and then immediately spawn itself (or a “worker” executable) in a hidden window via CreateProcess() with the CREATE_NO_WINDOW flag.

    Since this software runs as a system service and I’d rather not complicate the code for something that only happens once or twice over the lifetime of the system, I’ve just had to accept that sometimes there will occasionally be an Interactive Services Detection window pop up for a few moments while creating the partitions.

    If anyone discovers a good method for preventing the format prompt while programmatically creating and formatting a drive, I’ll happily change the accepted answer (and owe you a beer).

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

Sidebar

Related Questions

I have been trying to initialize 1 vector and 1 map in a class.
I've been trying to initialize a map of <ints, vector<ints> > using the new
I have this structure which i am trying to initialize using the following code.
I have an enumeration that I am trying to initialize from a long value
I am trying to initialize a newly created empty array by using a method.
I'm trying initialize my local rails server but I haven't been able to, because
I have a class Flight, and I'm trying initialize it, but I have a
I'm trying to initialize a RDF datastore using Jena and HSQLDB . From http://jena.sourceforge.net/DB/hsql-howto.html
g++ (GCC) 4.6.0 I have the following class and I am trying to initialize
I'm trying to initialize an array of structures to all-0's, using the below syntax:

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.