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?