📄 mslcli.c
字号:
// Client.cpp
#include <windows.h>
#include <stdio.h>
#include <conio.h>
void main(int argc, char *argv[])
{
HANDLE Mailslot;
DWORD BytesWritten;
CHAR ServerName[256];
char s[100];
FILE *f;
// Accept a command line argument for the server to send
// a message to
// if (argc < 2)
//{
// printf("Usage: client <server name>\n");
//return;
// }
// sprintf(ServerName, "\\\\%s\\Mailslot\\Myslot", argv[1]);
//printf("%s",ServerName);
if ((Mailslot = CreateFile("\\\\.\\Mailslot\\Myslot", GENERIC_WRITE,
FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL,
NULL)) == INVALID_HANDLE_VALUE)
{
printf("CreateFile failed with error %d\n", GetLastError());
return;
}
// void docfile(FILE *f){
if ((f=fopen("c:\\a.txt","r"))==NULL) printf ("Loi !");
else { while ((s[0]=getc(f))!=EOF) {
// printf("%c",s);
if (WriteFile(Mailslot,s,1,&BytesWritten, NULL) == 0) {
printf("WriteFile failed with error %d\n", GetLastError());
return;
}
}
}
fclose(f);
CloseHandle(Mailslot);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -