zoukankan      html  css  js  c++  java
  • 用C#调用C++DLL时的字符串指针参数传递问题

    下面是C++中的函数原型和调用方法  
      CMPP_API   dpl_status_t   cmpp_connect_to_ismg(char   *host,dpl_port_t   port,conn_desc   *conn);  
       
      stat   =   cmpp_connect_to_ismg("211.130.24.51",7800,&conn);//建立与ISMG服务器的连接  
       
      用C#怎么调用呢?
       示例:
       
      [   DllImport(   "api.dll",   CharSet=CharSet.Ansi)] //   EntryPoint="cmpp_connect_to_ismg",  

      public   static   extern   int   cmpp_connect_to_ismg(   ref   string   host,short   port,[MarshalAs(UnmanagedType.LPStruct)]   ref   conn_desc   conn);

       //@@无符号short//  

       
      调用  
       
      string   ipstr="211.138.24.51";  
      stat   =   esp.cmpp_connect_to_ismg(ipstr,7890,ref   conn);//建立与ISMG服务器的连接  
  • 相关阅读:
    Centos下 安装和测试kafka
    Java枚举
    Java 数组
    Java变量
    Java标识符
    Java修饰符
    java 基本语法
    Java 基础语法
    Java开发工具
    JAVA 发展历史
  • 原文地址:https://www.cnblogs.com/chillsrc/p/1285211.html
Copyright © 2011-2022 走看看