// MailSlotTest.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include #include #include #include #include int main(int argc, char* argv[]) { HANDLE TheMailSlot; char path[255]; char buffer[255]; DWORD NumberOfBytes; CHAR ServerName[256]; CHAR SlotName[256]; printf("\nEnter Server name: "); cin>>ServerName; printf("\nEnter slot name: "); cin>>SlotName; sprintf(path, "\\\\%s\\Mailslot\\%s", ServerName, SlotName); if ((TheMailSlot=CreateMailslot(path,0,MAILSLOT_WAIT_FOREVER,NULL)) ==INVALID_HANDLE_VALUE) { printf("Unable to create mailslot!\n"); GetLastError(); return 0; } printf("Server with name %s is started!\n",path); while(ReadFile(TheMailSlot,buffer,255,&NumberOfBytes,NULL)!=0) { printf("\nAccepted: "); buffer[NumberOfBytes]=0; printf("%s",buffer); } getch(); return 0; }