0

I am trying to enumerate the MFT to get list of file names.

This code works when used in a Win32 project:

MFT_ENUM_DATA med;
med.StartFileReferenceNumber = 0;
med.LowUsn = 0;
med.HighUsn = ujd.NextUsn;
BYTE pData[sizeof(DWORDLONG) + 0x10000];
DWORD cb;
while (DeviceIoControl(handleToVolume, FSCTL_ENUM_USN_DATA, &med, sizeof(med),
  pData, sizeof(pData), &cb, NULL) != FALSE) {
 //do the processing
}

But when I use the same code in C++/CLI, DeviceIoControl gives false and GetLastError gives ERROR_INVALID_FUNCTION. When the same code is translated into C#, it works.

Any idea what is happening?

4

1 回答 1

0

检查你是否有这个定义:

#define FSCTL_ENUM_USN_DATA 
 CTL_CODE(FILE_DEVICE_FILE_SYSTEM,44,METHOD_NEITHER,FILE_READ_DATA)

并替换FILE_READ_DATAFILE_ANY_ACCESS

于 2017-05-27T20:56:57.690 回答