最初我被链接到这个调用,所以我可以记录对某个文件的所有访问并捕获对它的所有更改。
我已经完成了几个示例,但都失败了。即使是msdn代码也无法为我编译。
有人可以为我提供一个小的工作片段来监视文件并记录更改吗?
或者至少有一些指针?
谢谢
You might not have the header that declares ReadDirectoryChangesW
, or you need to #define _WIN32_WINNT
as greater than or equal to 0x0400
. If it's the former, you can manually get the address to ReadDirectoryChangesW and call that:
HANDLE kernel32_dll_handle= LoadLibrary("kernel32.dll");
FARPROC ReadDirectoryChangesWAddress= GetProcAddress(kernel32_dll_handle, "ReadDirectoryChangesW");
typedef BOOL WINAPI (*ReadDirectoryChangesWDeclaration)(
__in HANDLE hDirectory,
__out LPVOID lpBuffer,
__in DWORD nBufferLength,
__in BOOL bWatchSubtree,
__in DWORD dwNotifyFilter,
__out_opt LPDWORD lpBytesReturned,
__inout_opt LPOVERLAPPED lpOverlapped,
__in_opt LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine
);
ReadDirectoryChangesWDeclaration ReadDirectoryChangesW= (ReadDirectoryChangesWDeclaration)ReadDirectoryChangesWAddress;