我正在尝试创建新分区并将卷安装到这个新分区,我认为CreateFile
让我这样做,使用以下代码:
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);
我有:
handl invalid error 3
Retrieving volume name failed erorr 2
第一个错误是ERROR_PATH_NOT_FOUND:系统找不到指定的路径。那么我该如何解决lpFileName
才能使其正常工作
在此先感谢,任何帮助将不胜感激。