title: How to open a partition handle to get its information on a dynamic disk?
body: <p>For the purpose of logging in my application I need to get information about physical partitions on the disk, such as the info provided in <a href="https://msdn.microsoft.com/en-us/library/windows/desktop/aa365448%28v=vs.85%29.aspx?f=255&amp;MSPPError=-2147217396" rel="nofollow noreferrer">PARTITION_INFORMATION_EX</a>. I have no problem doing it for "Basic disks" using the following method:</p>
  
  <p>First let's assume the following drive configuration:</p>
  
  <p><a href="https://i.stack.imgur.com/Xxdiv.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Xxdiv.png" alt="enter image description here"></a></p>
  
  <p>Then the following code works fine:</p>
  
  <pre><code>//Say, if I want to get info for partion 1 on disk 0 (or volume C:)
  HANDLE hPart = ::CreateFile(L"\\\\?\\GLOBALROOT\\Device\\Harddisk0\\Partition1", 
      GENERIC_READ, 
      FILE_SHARE_READ | FILE_SHARE_WRITE, NULL,
      OPEN_EXISTING,  0, NULL);
  if(hPart != INVALID_HANDLE_VALUE)
  {
      PARTITION_INFORMATION_EX pix = {0};
      DWORD bytesReturned = 0;
      if(::DeviceIoControl(hPart, IOCTL_DISK_GET_PARTITION_INFO_EX, NULL, 0, &amp;pix, sizeof(pix), &amp;bytesReturned, NULL))
      {
          //Got info OK
      }
  
      ::CloseHandle(hPart);
  }
  </code></pre>
  
  <p>But if I try to retrieve the info on a "dynamic partition", say, disk 2, partition 1 (or 2nd half of spanned volume F:) and I try to use <code>"\\\\?\\GLOBALROOT\\Device\\Harddisk2\\Partition1"</code> in a call to <code>CreateFile</code>, it fails with error code 2, or <code>ERROR_FILE_NOT_FOUND</code>.</p>
  
  <p>So the question is, how do I retrieve partition info on a dynamic disk?</p>