求教Createfile函数在MFC中的使用?
这个是我再控件上添加的响应函数UpdateData(TRUE);
int j;
unsigned char buf[512];
OVERLAPPED overlap;
HANDLE hFile = CreateFile(_T("\\\\.\\PhysicalDrive0"),//打开磁盘
GENERIC_READ|GENERIC_WRITE,
FILE_SHARE_READ,
NULL,
OPEN_EXISTING,
0,//FILE_FLAG_OVERLAPPED,
NULL);
DWORD RSize=0;
overlap.OffsetHigh = (DWORD)( 63*512ull / 0x100000000ull );//读取磁盘的偏移
overlap.Offset = (DWORD)( 63*512ull % 0x100000000ull );
ReadFile(hFile, buf, 512, &RSize, &overlap);//读取磁盘
CloseHandle(hFile);
for(j=0;j<512;j++)
{
CString buf1[1000]={0};
if(buf[j]/16%16==0)
{
buf1[j].Format(_T("0%X "),buf[j]);
if((j+1)%16==0&&(j+1))
{
buf1[j].Format(_T("0%X"),buf[j]);
}
}
else
{
buf1[j].Format(_T("%2X "),buf[j]);
if((j+1)%16==0&&(j+1))
{
buf1[j].Format(_T("%2X"),buf[j]);
}
}
m_sector+=buf1[j];//将数据赋值给控件上添加的局部变量
}
UpdateData(FALSE);
但是在调试的过程中发现打开磁盘读取时buf数组赋值完全不正确全部都是CC,想请问一下是哪里出了问题?
调试的截图如下: