I'am trying to create new partition and mount a volume to this new, I thought that CreateFile
let me do this, with 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
/** what u do in this directory u find it in th mount piont and vice versa**/
Buf, // output volume name buffer
BUFSIZE // size of volume name buffer
);
if (bFlag != TRUE)
{
//_tprintf( TEXT("Retrieving volume name for %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 to be mounted
);
if (!bFlag)
{
qDebug()<<"Attempt to mount failed";
qDebug()<<"error "<<GetLastError();
}
return (bFlag);
CloseHandle(handl);
I have:
handl invalid error 3
Retrieving volume name failed erorr 2
The first error is ERROR_PATH_NOT_FOUND: The system cannot find the path specified.
So how can I fix lpFileName
to make it works
thanks in advance, any help will be appreciated.