小编itc*_*chy的帖子

通过管道在c ++和c#之间进行通信

我想通过管道将数据从ac#应用程序发送到c ++应用程序.这就是我所做的:

这是c ++客户端:

#include "stdafx.h"
#include <windows.h>
#include <stdio.h>


int _tmain(int argc, _TCHAR* argv[]) {

  HANDLE hFile;
  BOOL flg;
  DWORD dwWrite;
  char szPipeUpdate[200];
  hFile = CreateFile(L"\\\\.\\pipe\\BvrPipe", GENERIC_WRITE,
                             0, NULL, OPEN_EXISTING,
                             0, NULL);

  strcpy(szPipeUpdate,"Data from Named Pipe client for createnamedpipe");
  if(hFile == INVALID_HANDLE_VALUE)
  { 
      DWORD dw = GetLastError();
      printf("CreateFile failed for Named Pipe client\n:" );
  }
  else
  {
      flg = WriteFile(hFile, szPipeUpdate, strlen(szPipeUpdate), &dwWrite, NULL);
      if (FALSE == flg)
      {
         printf("WriteFile failed for Named Pipe client\n");
      }
      else
      {
         printf("WriteFile …
Run Code Online (Sandbox Code Playgroud)

c# c++ ipc

6
推荐指数
1
解决办法
8999
查看次数

标签 统计

c# ×1

c++ ×1

ipc ×1