1. 不返回值的参数
  C++ 原型:
  bool    SendNewSms(char *szTel, char *szMessage);
  C#引用;
  [DllImport( "CdmaCard.dll",EntryPoint="SendNewSms")]
  public     static     extern    bool SendNewSms(string phone,string msg);
  2. 带返回值(char *)
  C++原型:
  BOOL GetCardErrorMessage(char *szErrorMessage , int errorCode);
  C#引用

 


[DllImport( "CdmaCard.dll",EntryPoint="GetCardErrorMessage")]
public     static     extern    int GetCardErrorMessage(StringBuilder msg,int errorCode);
StringBuilder buf = new StringBuilder(1024);//指定的Buf大小必须大于可能的大长度
GetCardErrorMessage(buf,1);

  3. 带返回值(其他类型)
  C++原型:
  BOOL GetSmsSaveStation (int *nSmsStation);
  C#引用

 

[DllImport( "CdmaCard.dll",EntryPoint="GetSmsSaveStation")]
public    static    extern   bool GetSmsSaveStation(ref int nStation);

  4. 传递结构体指针(C++填充)
  C++原型:


struct NET_INFO_STRUCT
{
DWORD nDurationTime; //持续时间
double nReceiveByte; //接收字节
double nSendByte;   //发送字节
};
BOOL NetGetConnectDetail(NET_INFO_STRUCT *lpNetInfo);

  C#引用

 

public struct NET_INFO_STRUCT
{
public uint nDurationTime; //持续时间
public double nReceiveByte; //接收字节
public double nSendByte;   //发送字节
}
[DllImport( "CdmaCard.dll",EntryPoint="NetGetConnectDetail")]
public    static    extern   int NetGetConnectDetail(ref NET_INFO_STRUCT pNetInfo);
NET_INFO_STRUCT netInfo = new NET_INFO_STRUCT();
NetGetConnectDetail(ref netInfo);

  5. 传递结构体数组(C++来填充)
  C++原型: