【发布时间】:2016-11-15 23:00:10
【问题描述】:
我用Firestreamer 创建了一个虚拟磁带库。我用 C++ 编写了一个将文件复制到该虚拟磁带的代码。但是当我尝试使用PrepareTape windows 功能准备磁带时,它失败了。下面是我调用 PrepareTape windows 函数的代码的一部分。
/*Tape Handle*/
LPCWSTR tapeName = L"\\\\.\\Tape1";
HANDLE tapeHandle = CreateFile(tapeName,
/*GENERIC_READ | GENERIC_WRITE*/ GENERIC_ALL,
0,
0,
OPEN_EXISTING,
FILE_ATTRIBUTE_ARCHIVE | FILE_FLAG_BACKUP_SEMANTICS,
0);
if (tapeHandle == NULL)
{
cout << "ERROR::Unable To Open handle for the tape in this machine the error is ::" << GetLastError() << endl;
}
else
{
wcout << "The Handle for the tape :" << tapeName << " is created successfully" << endl;
}
/*Prepare Tape*/
DWORD prepareTApeSuccess = PrepareTape(
tapeHandle,
TAPE_LOAD,
TRUE
);
if (prepareTApeSuccess == NO_ERROR)
{
cout << "Prepare Tape successsfully executed" << endl;
}
else
{
cout << "Prepare Tape Failed with the error :" << prepareTApeSuccess << endl;
}
if (!CloseHandle(tapeHandle))
{
cout << "Close handle for the file is failed with thie error" << GetLastError() << endl;
}
输出
The Handle for the tape :\\.\Tape1 is created successfully
Prepare Tape Failed with the error :1
但其余的,即其他磁带功能在相同的句柄下工作正常。我尝试使用 GetTapeStatus 函数获取磁带的状态。磁带设备已准备好接受适当的磁带访问命令而不返回错误,返回值为 NO_ERROR。
提前致谢
【问题讨论】:
标签: c++ windows backup virtual