素晴らしい質問です!7 年遅れていますが、ここに多少の答えがあります。さらに重要なのは、それを見つける方法です。したがって、ReadDirectoryChangesW のドキュメント:
https://msdn.microsoft.com/en-us/library/windows/desktop/aa365465%28v=vs.85%29.aspx
パラメータセクションで、FileIOCompletionRoutine へのリンクを提供します。
https://msdn.microsoft.com/en-us/library/windows/desktop/aa364052%28v=vs.85%29.aspx
例セクションでは、完了ルーチンを使用した名前付きパイプ サーバーへのリンクを提供します。
https://msdn.microsoft.com/en-us/library/windows/desktop/aa365601%28v=vs.85%29.aspx
信じられないかもしれませんが、ReadDirectoryChangesW も使用していませんが、実際には、FileIOCompletionRoutineも使用する ReadFileEx を使用した例を示しています。
https://msdn.microsoft.com/en-us/library/windows/desktop/aa365468%28v=vs.85%29.aspx
次のコードで、これら 2 つの関数 (ReadFileEx と CompletedReadRoutine (アプリケーション定義のコールバック関数 FileIOCompletionRoutine の実装)) を使用した例を確認できます。
// CompletedWriteRoutine(DWORD, DWORD, LPOVERLAPPED)
// This routine is called as a completion routine after writing to
// the pipe, or when a new client has connected to a pipe instance.
// It starts another read operation.
VOID WINAPI CompletedWriteRoutine(DWORD dwErr, DWORD cbWritten,
LPOVERLAPPED lpOverLap)
{
LPPIPEINST lpPipeInst;
BOOL fRead = FALSE;
// lpOverlap points to storage for this instance.
lpPipeInst = (LPPIPEINST) lpOverLap;
// The write operation has finished, so read the next request (if
// there is no error).
if ((dwErr == 0) && (cbWritten == lpPipeInst->cbToWrite))
fRead = ReadFileEx(
lpPipeInst->hPipeInst,
lpPipeInst->chRequest,
BUFSIZE*sizeof(TCHAR),
(LPOVERLAPPED) lpPipeInst,
(LPOVERLAPPED_COMPLETION_ROUTINE) CompletedReadRoutine);
// Disconnect if an error occurred.
if (! fRead)
DisconnectAndClose(lpPipeInst);
}
// CompletedReadRoutine(DWORD, DWORD, LPOVERLAPPED)
// This routine is called as an I/O completion routine after reading
// a request from the client. It gets data and writes it to the pipe.
VOID WINAPI CompletedReadRoutine(DWORD dwErr, DWORD cbBytesRead,
LPOVERLAPPED lpOverLap)
{
LPPIPEINST lpPipeInst;
BOOL fWrite = FALSE;
// lpOverlap points to storage for this instance.
lpPipeInst = (LPPIPEINST) lpOverLap;
// The read operation has finished, so write a response (if no
// error occurred).
if ((dwErr == 0) && (cbBytesRead != 0))
{
GetAnswerToRequest(lpPipeInst);
fWrite = WriteFileEx(
lpPipeInst->hPipeInst,
lpPipeInst->chReply,
lpPipeInst->cbToWrite,
(LPOVERLAPPED) lpPipeInst,
(LPOVERLAPPED_COMPLETION_ROUTINE) CompletedWriteRoutine);
}
// Disconnect if an error occurred.
if (! fWrite)
DisconnectAndClose(lpPipeInst);
}
それは素晴らしい答えではありません (私は自分自身でこれらの関数を使用したいかどうかを調べただけでした)、人々が始めるのに役立つはずです.
以下も参照してください。
https://msdn.microsoft.com/en-us/library/windows/desktop/aa365261%28v=vs.85%29.aspx