c++ - WinApi: Access denied when creating disk -


i'm running following code administrator privileges:

handle hdevice = invalid_handle_value;  // handle drive examined  bool bresult = false;                 // results flag dword junk = 0;                     // discard results  hdevice = createfilew(l"\\\\.\\physicaldrive0",          // drive open     0,                // no access drive     file_share_read | // share mode     file_share_write,     null,             // default security attributes     open_existing,    // disposition     0,                // file attributes     null);            // not copy file attributes  if (hdevice == invalid_handle_value)    // cannot open drive {     std::cout << "invalid handle" << std::endl;     return -1; } std::cout << "handle " << hdevice << std::endl;  drive_layout_information_ex        drv_layout_info_ex; create_disk        disk; int                n;  zeromemory(&disk, sizeof(create_disk)); disk.partitionstyle = partition_style_mbr; disk.mbr.signature = 0x7b060725; bresult = ::deviceiocontrol(hdevice, ioctl_disk_create_disk, &disk,     sizeof(create_disk), null,     0, &junk, null); if (!bresult) {     std::cout << "ioctl_disk_create_disk failed due " << getlasterror() << std::endl;     return false; } 

i output:

handle 00000048 ioctl_disk_create_disk failed due 5 

which access denied. problem?


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -