相关疑难解决方法(0)

如何使用命名管道在c ++ .dll和C#app之间发送消息?

我正在用C++编写注入的.dll,我想使用命名管道与C#app进行通信.

现在,我在C#app中使用内置的System.IO.Pipe .net类,我正在使用C++中的常规函数​​.

我没有太多的C++经验(阅读:这是我的第一个C++代码..),我在C#中经验丰富.

似乎与服务器和客户端的连接正常,唯一的问题是messaged没有被发送.我尝试将.dll作为服务器,C#app作为服务器,使管道方向InOut(双工)但似乎没有工作.

当我尝试将.dll发送到C#应用程序发送消息的服务器时,我使用的代码是这样的:

DWORD ServerCreate() // function to create the server and wait till it successfully creates it to return.
{
    hPipe = CreateNamedPipe(pipename,//The unique pipe name. This string must have the following form:  \\.\pipe\pipename
    PIPE_ACCESS_DUPLEX, 
    PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE | PIPE_NOWAIT, //write and read and return right away
    PIPE_UNLIMITED_INSTANCES,//The maximum number of instances that can be created for this pipe
    4096 , // output time-out 
    4096 , // input time-out 
    0,//client time-out 
    NULL);

   if(hPipe== INVALID_HANDLE_VALUE)
   {
    return …
Run Code Online (Sandbox Code Playgroud)

c# c++ pipe

5
推荐指数
1
解决办法
1万
查看次数

标签 统计

c# ×1

c++ ×1

pipe ×1