1
2
3 #include <windows.h>
4
5
main(int argc,char * argv[])6 int main(int argc, char *argv[])
7 {
8 HANDLE hMailslot;
9 CHAR chBuf[512];
10 BOOL fResult;
11 DWORD cbRead;
12 LPTSTR lpszMailslotName = "\\\\.\\mailslot\\mymailslot";
13
14 hMailslot = CreateMailslot(lpszMailslotName,
15 512,
16 MAILSLOT_WAIT_FOREVER,
17 NULL);
18 for (;;)
19 {
20 fResult = ReadFile(hMailslot,
21 chBuf,
22 512,
23 &cbRead,
24 NULL);
25 if (fResult == FALSE)
26 {
27 printf("ReadFile() failed!\n");
28 CloseHandle(hMailslot);
29 return 0;
30 }
31
32 printf("Data read: %s\n", chBuf);
33 }
34
35 CloseHandle(hMailslot);
36
37 return 0;
38 }
39
40 /* EOF */
41