開發環境:WinXP Pro(SP
接口庫版本: CMPP
該例程演示了如何在C#裡面調用VC
由於我使用C#剛兩天
CMPP
在C#裡面如何調用API應用
下面是C#下面的完整的調用代碼
//Class
using System;
// 該名稱空間包含了在Visual C#中調用API的一些必要集合
using System
// 使用Sleep方法需要的命名空間
using System
namespace CMPPAPI_Sample_CSharp
{
[StructLayout(LayoutKind
public struct CMPP_HEAD
{
public uint nTotalLength;
public uint nCommandId;
public uint nSeqId;
}
[StructLayout(LayoutKind
public struct CMPP_CONNECT
{
[MarshalAs(UnmanagedType
public string sSourceAddr;
[MarshalAs(UnmanagedType
public string sAuthSource;
public byte cVersion;
public uint nTimeStamp;
}
[StructLayout(LayoutKind
public struct CMPP_CONNECT_RESP
{
public byte uchStatus;
[MarshalAs(UnmanagedType
public string sAuthISMG;
public byte cVersion;
}
[StructLayout(LayoutKind
public struct CMPP_SUBMIT_RESP
{
public long nMsgid;
public byte uchResult;
}
[StructLayout(LayoutKind
public struct CMPP_STATUS_REPORT
{
public long nMsgid;
[MarshalAs(UnmanagedType
public string sStat;
[MarshalAs(UnmanagedType
public string sSubmitTime;
[MarshalAs(UnmanagedType
public string sDoneTime;
[MarshalAs(UnmanagedType
public string sDestTerminalId;
public uint nSmscSeq;
}
[StructLayout(LayoutKind
public struct CMPP_MO_MSGCONTENT
{
[MarshalAs(UnmanagedType
public string sMsgcontent;
public CMPP_STATUS_REPORT csr;
}
[StructLayout(LayoutKind
public struct CMPP_DELIVER
{
public long nMsgid;
[MarshalAs(UnmanagedType
public string sDestid;
[MarshalAs(UnmanagedType
public string sServiceid;
public byte uchTppid;
public byte uchTpudhi;
public byte uchMsgfmt;
[MarshalAs(UnmanagedType
public string sSrcterminalid;
public byte uchRegisteredDelivery;
public byte uchMsglength;
public CMPP_MO_MSGCONTENT mo_msg;
[MarshalAs(UnmanagedType
public string sReserved;
}
From:http://tw.wingwit.com/Article/program/net/201311/12324.html