ReadDirectoryChangesW 实现

发布于 2024-07-26 14:34:48 字数 269 浏览 7 评论 0原文

最初,我链接到此调用,以便我可以记录对某个文件的所有访问并捕获对其的所有更改。

我已经完成了几个例子,但都失败了。 即使 代码也无法为我编译。

有人可以为我提供一个小的工作片段来监视文件并记录更改吗?

或者至少有一些指示?

谢谢

Originally I was linked to this call so I could log all access to a certain file and capture all the changes to it.

I have worked through several examples and have failed. Even the code doesn't compile for me.

Can someone provide me with a small working snippet to monitor a file and record changes?

Or at least some pointers?

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

枫林﹌晚霞¤ 2024-08-02 14:35:21

您可能没有声明 ReadDirectoryChangesW 的标头,或者需要 #define _WIN32_WINNT 大于或等于 0x0400。 如果是前者,您可以手动获取 ReadDirectoryChangesW 的地址并调用:

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;

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;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文