📄 动态链接库.cpp
字号:
#include "stdafx.h"
#include"stdio.h"
extern "C" __declspec(dllexport) void chuansong(HANDLE hPipeHandle1);
BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
return TRUE;
}
void chuansong(HANDLE hPipeHandle1)
{int err;
char p[50];
char q[50];
BOOL rc;
DWORD BytesRead,BytesWrite;
BytesRead=20;//yhy add
printf("Handle in dll =%d\n",hPipeHandle1);
rc=ReadFile(hPipeHandle1,p,BytesRead,&BytesRead,(LPOVERLAPPED)NULL);//yhy add从管道中读取数据
if (rc==0 && BytesRead==0 )
{ err=GetLastError();
printf("Server Read Pipe Fail!err=%d\n",err);
// exit(3);
}
else
{
printf("Server Read Pipe Success!\n");
printf("客户方发送的消息为in dll:%s\n",p);
}
rc=strcmp(p,"end");
//if (rc==0) break;
strcpy(q,"abcdef!");
BytesWrite=strlen(q);//yhy add
rc=WriteFile(hPipeHandle1,q,BytesWrite,&BytesWrite,(LPOVERLAPPED)NULL);//yhy add
if (rc==0) printf("Server Write Pipe Fail!\n");
else printf("Server Write Pipe Success!\n");
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -