我正在研究 LOTUS Notes API,在此过程中,我遇到了这样的功能,
bytesRead = fread (Buffer, 1, (WORD) Length, hCDFile);
现在我发现了一些 C# 等效方法,例如,它在一个 while 循环中运行。在第一次迭代时,该方法似乎工作正常(当我调试 c 版本的代码和 C# 版本时,结果是相同的)。但是在第二次迭代中假设dwLengthHost = 35的值,在这个方法之前我调用了另一个方法
NSFDUMPReadFromFile(hCDFile, ref RecordTypeCanonicalPtr, sizeof (ushort))
它调用fread
函数并给出 value RecordTypeCanonicalPtr=149
。但在那之后,当稍后调用相同的方法时RecordTypeCanonicalPtr
,dwLengthHost
值会自动更改。
[DllImport("msvcrt.dll")]
public static extern UInt32 fread(ref IntPtr Buffer, uint Size, uint Count, IntPtr Stream);
private bool NSFDUMPReadFromFile(IntPtr hCDFile,
ref IntPtr Buffer,
UInt32 Length)
{
UInt32 bytesRead = NotesApi.fread(ref Buffer, 1, (uint)Length, hCDFile);
/* Read bytes from the file */
if (bytesRead == Length)
return true;
else
return false;
}