2004-10-21 04:59:01 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <windows.h>
|
|
|
|
#include <tchar.h>
|
|
|
|
|
|
|
|
#define BUFSIZE 1024
|
|
|
|
#define MAILSLOT_TIMEOUT 1000
|
|
|
|
|
|
|
|
|
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
|
|
|
HANDLE hMailslot;
|
|
|
|
LPSTR lpszMailslotName = "\\\\.\\MAILSLOT\\mymailslot";
|
|
|
|
LPSTR lpszTestMessage = "Mailslot test message!";
|
|
|
|
DWORD cbLength, cbWritten;
|
2005-05-07 21:24:31 +00:00
|
|
|
|
2004-10-21 04:59:01 +00:00
|
|
|
hMailslot = CreateFile(lpszMailslotName,
|
|
|
|
GENERIC_WRITE,
|
|
|
|
FILE_SHARE_READ,
|
|
|
|
(LPSECURITY_ATTRIBUTES)NULL,
|
|
|
|
OPEN_EXISTING,
|
|
|
|
FILE_ATTRIBUTE_NORMAL,
|
|
|
|
(HANDLE)NULL);
|
|
|
|
printf("hMailslot %x\n", (DWORD)hMailslot);
|
|
|
|
if (hMailslot == INVALID_HANDLE_VALUE)
|
|
|
|
{
|
|
|
|
printf("CreateFile() failed\n");
|
|
|
|
return 0;
|
|
|
|
}
|
2005-05-07 21:24:31 +00:00
|
|
|
|
2004-10-21 04:59:01 +00:00
|
|
|
cbLength = (ULONG)strlen(lpszTestMessage)+1;
|
2005-05-07 21:24:31 +00:00
|
|
|
|
2004-10-21 04:59:01 +00:00
|
|
|
WriteFile(hMailslot,
|
|
|
|
lpszTestMessage,
|
|
|
|
cbLength,
|
|
|
|
&cbWritten,
|
|
|
|
NULL);
|
2005-05-07 21:24:31 +00:00
|
|
|
|
2004-10-21 04:59:01 +00:00
|
|
|
CloseHandle(hMailslot);
|
2005-05-07 21:24:31 +00:00
|
|
|
|
2004-10-21 04:59:01 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* EOF */
|
|
|
|
|