c++ - Creating new partition disk winapi -


i'am trying create new partition , mount volume new, thought createfile let me this, code :

lpctstr lpfilename=l"\\\\.\\device\\harddisk0\\partition3"; handle handl=createfile( lpfilename,                             generic_read | generic_write,                             file_share_read | file_share_write,                             null,                             create_always,                             file_attribute_normal,                             null  );    if (handl==invalid_handle_value)    {    qdebug()<<"handl invalid"<<" error"<<getlasterror();}      bool success = definedosdevice(ddd_raw_target_path,l"i:",l"\\device\\harddisk0\\partition3");    if(!success)        qdebug()<<" definedosdevice failed "<<getlasterror();      bflag = getvolumenameforvolumemountpoint(                l"i:\\", // input volume mount point or directory                /** u in directory u find in th mount piont , vice versa**/                   buf, // output volume name buffer               bufsize  // size of volume name buffer            );    if (bflag != true)    {       //_tprintf( text("retrieving volume name %s failed.\n"), argv[2] );       qdebug()<<"retrieving volume name failed.      "<<getlasterror();       return (-2);    }     qdebug()<<"volume name"<<qstring::fromwchararray(buf);        bool fresult = definedosdevice (                          ddd_raw_target_path|ddd_remove_definition|                          ddd_exact_match_on_remove, l"i:",                          l"\\device\\harddisk0\\partition3");     if (!fresult)                 qdebug()<<"definedosdevice failed  "<< getlasterror();       bflag = setvolumemountpoint(l"d:\\mydirexample\\example\\", // mount point                                /** should b empty**/                                 buf // volume mounted                                );     if (!bflag)       {         qdebug()<<"attempt mount failed";         qdebug()<<"error "<<getlasterror();       }     return (bflag);      closehandle(handl); 

i have:

handl invalid  error 3  retrieving volume name failed  erorr  2 

the first error error_path_not_found: system cannot find path specified. how can fix lpfilename make works

thanks in advance, appreciated.

there is, used shredder. tricky part managing large_integer filepointer (used choose sector). need use handle device using createfile() first. after have done lock drive fsctl_lock_volume, use setfilepointerex set sector , create new 1 ioctl_disk_set_partition_info_ex.

cheers ;)

edited few times - wasn't sure if ioctl_disk_set_partition_info needed too, not, can set type ioctl_disk_set_partition_info_ex well.


Comments

Popular posts from this blog

Android Prevent Bluetooth Pairing Dialog -

VBA function to include CDATA -