c++函數(shù)轉(zhuǎn)c#函數(shù)示例程序分享
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
using System.Windows.Forms;
namespace FDEP
{
/// <summary>
/// 羅旭成
/// 深證通函數(shù)轉(zhuǎn)換
/// </summary>
public class ImportDLL
{
#region * 常量定義
//*****************************************************************
//協(xié)議類型常量
//名稱 定義值 說(shuō)明
//MR_PROTOCOLTYPE_MRSTANDAND 0x01 FDEP規(guī)定的標(biāo)識(shí)業(yè)務(wù)協(xié)議
//MR_PROTOCOLTYPE_SELFCUSTOM 0xFF 用戶自定義協(xié)議類型
/// <summary>
/// 協(xié)議類型常量
/// </summary>
public const uint MR_PROTOCOLTYPE_MRSTANDAND = 0x01; // SBSP標(biāo)準(zhǔn)業(yè)務(wù)協(xié)議。
public const uint MR_PROTOCOLTYPE_SELFCUSTOM = 0xFF; // 用戶自定義協(xié)議類型。
//*****************************************************************
//消息標(biāo)識(shí)位常量
//名稱 定義值 說(shuō)明
//MR_MSGFLAG_PERSIST 0x01 持久消息標(biāo)志,用于可靠傳輸。目前暫不支持
//MR_MSGFLAG_COMPRESS 0x02 壓縮標(biāo)志,需進(jìn)行壓縮傳輸
/// <summary>
/// 消息標(biāo)志位常量
/// </summary>
public const uint MR_MSGFLAG_PERSIST = 0x01; // 持久消息標(biāo)志,用于可靠傳輸。
public const uint MR_MSGFLAG_COMPRESS = 0x02; // 壓縮標(biāo)志,需進(jìn)行壓縮傳輸。
//*****************************************************************
//長(zhǎng)度常量
//名稱 定義值 說(shuō)明
//MR_MAXLEN_ADDR 64 用戶標(biāo)識(shí)及應(yīng)用標(biāo)識(shí)的最大長(zhǎng)度
//MR_MAXLEN_PKGID 64 消息包標(biāo)識(shí)的最大長(zhǎng)度
//MR_MAXLEN_USERDATA 256 用戶保留數(shù)據(jù)的最大長(zhǎng)度
//MR_FIXLEN_EXPIREDABSTIME 20 過(guò)期絕對(duì)時(shí)間固定長(zhǎng)度
/// <summary>
/// 消息標(biāo)志位常量
/// </summary>
public const int MR_MAXLEN_ADDR = 64; // 用戶標(biāo)識(shí)及應(yīng)用標(biāo)識(shí)的最大長(zhǎng)度。
public const int MR_MAXLEN_PKGID = 64; // 消息包標(biāo)識(shí)的最大長(zhǎng)度。
public const int MR_MAXLEN_USERDATA = 256; // 用戶保留數(shù)據(jù)的最大長(zhǎng)度。
public const int MR_FIXLEN_EXPIREDABSTIME = 20; // 過(guò)期絕對(duì)時(shí)間固定長(zhǎng)度。
//*****************************************************************
//函數(shù)返回錯(cuò)誤值
//MR_ERRCODE_OK 0
//MR_ERRCODE_PARAMERR -1
//MR_ERRCODE_CONNERR -2
//MR_ERRCODE_TIMEEXPIRED -3
//MR_ERRCODE_TIMEOUT -4
//MR_ERRCODE_NOMSG -5
//MR_ERRCODE_BUFTOOSHORT -6
//MR_ERRCODE_BUFTOOBIG -7
//MR_ERRCODE_SYSERROR -8
#endregion
#region * 結(jié)構(gòu)體的定義
/// <summary>
/// 用來(lái)表示一條消息的各種屬性
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public struct STUsgProperty
{
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = MR_MAXLEN_ADDR)]
public string m_szSourceUserID;//MR_MAXLEN_ADDR 源用戶標(biāo)識(shí),以“\0”結(jié)尾的字符串
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = MR_MAXLEN_ADDR)]
public string m_szSourceAppID;//MR_MAXLEN_ADDR 源應(yīng)用標(biāo)識(shí),以“\0”結(jié)尾的字符串
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = MR_MAXLEN_ADDR)]
public string m_szDestUserID;//MR_MAXLEN_ADDR 目的用戶標(biāo)識(shí),以“\0”結(jié)尾的字符串
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = MR_MAXLEN_ADDR)]
public string m_szDestAppID;//MR_MAXLEN_ADDR 目的應(yīng)用標(biāo)識(shí),以“\0”結(jié)尾的字符串
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = MR_MAXLEN_PKGID)]
public string m_szPkgID;//MR_MAXLEN_PKGID 消息包的包標(biāo)識(shí),以“\0”結(jié)尾的字符串,或者由用戶調(diào)用MrCreatePkgID函數(shù)生成,或者為空(即'\0')
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = MR_MAXLEN_PKGID)]
public string m_szCorrPkgID;//MR_MAXLEN_PKGID 相關(guān)包標(biāo)識(shí),以“\0”結(jié)尾的字符串,供用戶自用
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = MR_MAXLEN_USERDATA)]
public string m_szUserData1;//MR_MAXLEN_USERDATA 用戶數(shù)據(jù)1,以“\0”結(jié)尾的字符串,供用戶自用
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = MR_MAXLEN_USERDATA)]
public string m_szUserData2;//MR_MAXLEN_USERDATA 用戶數(shù)據(jù)2,以“\0”結(jié)尾的字符串,供用戶自用
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = MR_FIXLEN_EXPIREDABSTIME)]
public string m_szExpiredAbsTime;//MR_FIXLEN_EXPIREDABSTIME 該消息的過(guò)期時(shí)間,以“\0”結(jié)尾的字符串,格式為“YYYY-MM-DD HH:MM:SS”。也可以置空,此時(shí)如果目的用戶不在線,或者目的應(yīng)用未連接,則消息立即過(guò)期。
public byte m_ucFlag;//消息標(biāo)識(shí),有8個(gè)二進(jìn)制位組成,各位含義如下:位0 --為1表示持久消息,需可靠傳輸,暫不支持;
//位1 --為1表示消息需壓縮傳輸
public byte m_ucProtocolType;//協(xié)議類型標(biāo)識(shí),取值可以是下列之一:MR_PROTOCOLTYPE_MRSTANDAND 0x01 FDEP規(guī)定的標(biāo)準(zhǔn)業(yè)務(wù)協(xié)議
//MR_PROTOCOLTYPE_SELFCUSTOM 0xFF 用戶自定義協(xié)議類型
}
/// <summary>
/// 用來(lái)定義與接入客戶端建立連接所需的各種信息
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public struct STUConnInfo
{
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 16)]
public string m_szMRIP;//接入客戶端消息路由器的IP地址,以"\0"結(jié)尾的字符串,格式為“xxx.xxx.xxx.xxx”
public UInt16 m_usMRPort;//接入客戶端消息路由器的連接端口
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 16)]
public string m_szMRIPBak;//備用消息路由器的IP地址,不設(shè)置備用消息路由器時(shí)可以為空
public UInt16 m_usMRPortBak;//備用消息路由器的連接端口,不設(shè)置備用消息路由器時(shí)可以為0
}
#endregion
#region * 函數(shù)的定義
/// <summary>
/// 定義的回調(diào)函數(shù)
/// </summary>
/// <param name="psPkg">要發(fā)送的消息包緩沖區(qū)</param>
/// <param name="iPkgLen">緩沖區(qū)中的消息包長(zhǎng)度</param>
/// <param name="pMsgPropery">消息包屬性</param>
/// <param name="pvUserData">供回調(diào)函數(shù)使用的用戶數(shù)據(jù)</param>
/// <returns></returns>
[UnmanagedFunctionPointerAttribute(CallingConvention.StdCall)]
public delegate int OnReceiveCallBack(string psPkg, int iPkgLen, ref STUsgProperty pMsgPropery, IntPtr pvUserData);
//typedef int (*OnReceiveCallBack)(const char* psPkg, int iPkgLen, const STUMsgProperty* pMsgPropery, void* pvUserData);
/// <summary>
/// 1.初始化,獲取相關(guān)資源,并嘗試與接入客戶端FDAP建立連接
/// </summary>
/// <param name="psAppID">本應(yīng)用的應(yīng)用標(biāo)識(shí)</param>[in]
/// <param name="psPasswd">本應(yīng)用在接入客服端設(shè)置的密碼,密碼必須與預(yù)設(shè)的匹配才能繼續(xù)</param>[in]
/// <param name="onReceive">接收到消息包時(shí)的回調(diào)函數(shù)</param>[in]
/// <param name="oConnInfo">接入客戶端連接信息</param>[in]
/// <param name="pvUserData">供回調(diào)函數(shù)使用的用戶數(shù)據(jù)</param>[in]
/// <returns>NULL 初始化失敗 非NULL 初始化成功,返回一個(gè)連接句柄,給句柄將作為其他函數(shù)調(diào)用的參數(shù)</returns>
[DllImport("mrapi.dll", EntryPoint = "MrInit", CallingConvention = CallingConvention.StdCall, SetLastError = true, CharSet = CharSet.Ansi)]
public static extern IntPtr MrInit(string psAppID, string psPasswd, OnReceiveCallBack onReceive, STUConnInfo oConnInfo, IntPtr pvUserData);
//void* _stdcall MrInit(const char* psAppID, const char* psAppPasswd,OnReceiveCallBack onReceive,const STUConnInfo oConnInfo, void* pvUserData);
/// <summary>
/// 2.初始化,獲取相關(guān)資源,并嘗試與接入客戶端FDAP建立連接
/// </summary>
/// <param name="psUserCertID">本應(yīng)用的用戶標(biāo)識(shí)</param>[in]
/// <param name="psAppID">本應(yīng)用的應(yīng)用標(biāo)識(shí)</param>[in]
/// <param name="psPasswd">本應(yīng)用在接入客服端設(shè)置的密碼,密碼必須與預(yù)設(shè)的匹配才能繼續(xù)</param>[in]
/// <param name="onReceive">接收到消息包時(shí)的回調(diào)函數(shù)</param>[in]
/// <param name="oConnInfo">接入客戶端連接信息</param>[in]
/// <param name="pvUserData">供回調(diào)函數(shù)使用的用戶數(shù)據(jù)</param>[in]
/// <returns>NULL 初始化失敗 非NULL 初始化成功,返回一個(gè)連接句柄,給句柄將作為其他函數(shù)調(diào)用的參數(shù)</returns>
[DllImport("mrapi.dll", EntryPoint = "MrInit1", CallingConvention = CallingConvention.StdCall, SetLastError = true, CharSet = CharSet.Ansi)]
public static extern IntPtr MrInit1(string psUserCertID, string psAppID, string psPasswd, OnReceiveCallBack onReceive, STUConnInfo oConnInfo, IntPtr pvUserData);
/// <summary>
/// 3.連接FDAP時(shí)的初始化函數(shù)。該函數(shù)對(duì)FDEAPI進(jìn)行初始化,分配獲取相關(guān)資源,并嘗試與接入客戶端建立通信連接
/// </summary>
/// <param name="pHandle">函數(shù)返回的句柄,該句柄將作為其他函數(shù)調(diào)用的參數(shù)</param>[out]
/// <param name="psUserCertID">本應(yīng)用的用戶標(biāo)識(shí)</param>[in]
/// <param name="psAppID">本應(yīng)用的應(yīng)用標(biāo)識(shí)</param>[in]
/// <param name="psPasswd">本應(yīng)用在接入客戶端設(shè)置的密碼,密碼必須與預(yù)設(shè)的匹配才能繼續(xù)</param>[in]
/// <param name="pMsgProperty">消息包屬性</param>[in]
/// <param name="onReceive">接收到消息包時(shí)的回調(diào)函數(shù)</param>[in]
/// <param name="oConnInfo">接入客戶端連接信息</param>[in]
/// <param name="pvUserData">供回調(diào)函數(shù)使用的用戶數(shù)據(jù)</param>[in]
/// <param name="iThreadCount">調(diào)用回頭函數(shù)OnReceive的線程數(shù)目</param>[in]
/// <returns>無(wú)</returns>
[DllImport("mrapi.dll", EntryPoint = "MrInit1Ex1", CallingConvention = CallingConvention.StdCall, SetLastError = true, CharSet = CharSet.Ansi)]
public static extern IntPtr MrInit1Ex1(out IntPtr pHandle, string psUserCertID, string psAppID, string psPasswd, ref STUsgProperty pMsgProperty, OnReceiveCallBack onReceive, STUConnInfo oConnInfo, IntPtr pvUserData, int iThreadCount);
/// <summary>
/// 4.連接FDAP時(shí)的初始化函數(shù)。該函數(shù)對(duì)FDEAPI進(jìn)行初始化,分配獲取相關(guān)資源,并嘗試與接入客戶端建立通信連接
/// </summary>
/// <param name="pHandle">函數(shù)返回的句柄,該句柄將作為其他函數(shù)調(diào)用的參數(shù)</param>[out]
/// <param name="psAppID">本應(yīng)用的應(yīng)用標(biāo)識(shí)</param>[in]
/// <param name="psPassws">本應(yīng)用在接入客戶端設(shè)置的密碼,密碼必須與預(yù)設(shè)的匹配才能繼續(xù)</param>[in]
/// <param name="pOnRecvMsgPropery">這是回調(diào)函數(shù)OnReceive的接收條件,如果不需要任何條件,則可以填NULL</param>[in]
/// <param name="onReceive">接收到消息包時(shí)的回調(diào)函數(shù)</param>[in]
/// <param name="pConnInfo">接入客戶端連接信息</param>[in]
/// <param name="pvUserData">供回調(diào)函數(shù)使用的用戶數(shù)據(jù)</param>[in]
/// <param name="iThreadCount">調(diào)用回頭函數(shù)OnReceive的線程數(shù)目</param>
/// <returns>無(wú)</returns>
[DllImport("mrapi.dll", EntryPoint = "MrInit2", CallingConvention = CallingConvention.StdCall, SetLastError = true, CharSet = CharSet.Ansi)]
public static extern IntPtr MrInit2(out IntPtr pHandle, string psAppID, string psPassws, ref STUsgProperty pOnRecvMsgPropery, OnReceiveCallBack onReceive, ref STUConnInfo pConnInfo, IntPtr pvUserData, int iThreadCount);
//void* _stdcall MrInit2(void** ppHandle, const char* psAppID, const char* psAppPasswd, STUMsgProperty* pOnRecvMsgPropery,OnReceiveCallBack onReceive,const STUConnInfo* pConnInfo, void* pvUserData, int iThreadCount);
/// <summary>
/// 5.判斷與交換中樞的連接是否正常
/// </summary>
/// <param name="pHandle">連接句柄,調(diào)用MrInit時(shí)返回的值</param>
/// <returns>0不正常 1正常</returns>
[DllImport("mrapi.dll", EntryPoint = "MrIsLinkOK", CallingConvention = CallingConvention.StdCall, SetLastError = true, CharSet = CharSet.Ansi)]
public static extern int MrIsLinkOK(IntPtr pHandle);
//int _stdcall MrIsLinkOK(void* pHandle)
/// <summary>
/// 6.消息包標(biāo)識(shí)生成函數(shù)
/// </summary>
/// <param name="pHandle">連接句柄,調(diào)用MrInit時(shí)返回的值</param>[in]
/// <param name="szPkgID">生成的消息包標(biāo)識(shí)</param>[out]
/// <returns>0 成功 其他 失敗</returns>
[DllImport("mrapi.dll", EntryPoint = "MrCreatePkgID", CallingConvention = CallingConvention.StdCall, SetLastError = true, CharSet = CharSet.Ansi)]
public static extern int MrCreatePkgID(IntPtr pHandle, StringBuilder szPkgID);
//int _stdcall MrCreatePkgID(void* pHandle,char szPkgID[MR_MAXLEN_PKGID])
/// <summary>
/// 7.消息包發(fā)送函數(shù)
/// </summary>
/// <param name="pHandle">連接句柄,調(diào)用MrInit時(shí)返回的值</param>[in]
/// <param name="psPkg">要發(fā)送的消息包緩沖區(qū)</param>[in]
/// <param name="iPkgLen">緩沖區(qū)中的消息包長(zhǎng)度</param>[in]
/// <param name="pMsgPropery">消息包屬性</param>[in/out]
/// <param name="iMillSecTimeo">以毫米為單位的接收最大超時(shí)時(shí)間</param>[in]
/// <returns>0 成功 其他 失敗</returns>
[DllImport("mrapi.dll", EntryPoint = "MrSend", CallingConvention = CallingConvention.StdCall, SetLastError = true, CharSet = CharSet.Ansi)]
public static extern int MrSend(IntPtr pHandle, string psPkg, int iPkgLen, ref STUsgProperty pMsgPropery, int iMillSecTimeo);
//int _stdcall MrSend(void* pHandle,const char* psPkg,int iPkgLen,STUsgProperty* pMsgPropery,int iMillSecTimeo);
/// <summary>
/// 8.消息包接收函數(shù)1
/// </summary>
/// <param name="pHandle">連接句柄,調(diào)用MrInit時(shí)返回的值</param>[in]
/// <param name="ppsPkg">雙指針,返回包所指向的內(nèi)存</param>[out]
/// <param name="piOutPkgLen">接收到消息包的實(shí)際長(zhǎng)度</param>[out]
/// <param name="pMsgPropery">接收條件</param>[in/out]
/// <param name="iMillSecTimeo">以毫米為單位的接收最大超時(shí)時(shí)間</param>[in]
/// <returns>0 成功 其他 失敗</returns>
[DllImport("mrapi.dll", EntryPoint = "MrReceive1", CallingConvention = CallingConvention.StdCall, SetLastError = true, CharSet = CharSet.Ansi)]
public static extern int MrReceive1(IntPtr pHandle, out IntPtr ppsPkg, out int piOutPkgLen, ref STUsgProperty pMsgPropery, int iMillSecTimeo);
//int _stdcall MrReceive1(void* pHandle, char** ppsPkg, int* piOutPkgLen, STUMsgProperty* pMsgPropery, int iMillSecTimeo);
/// <summary>
/// 9.消息包內(nèi)存釋放函數(shù)
/// </summary>
/// <param name="psPkg">由MrReceivel1函數(shù)的第二個(gè)參數(shù)返回的指針</param>[in]
/// <returns>無(wú)</returns>
[DllImport("mrapi.dll", EntryPoint = "MrReceive1_FreeBuf", CallingConvention = CallingConvention.StdCall, SetLastError = true, CharSet = CharSet.Ansi)]
public static extern IntPtr MrReceive1_FreeBuf(string psPkg);
//void _stdcall MrReceive1_FreeBuf(char* psPkg);
/// <summary>
/// 10.消息包瀏覽函數(shù)
/// </summary>
/// <param name="pHandle">連接句柄,調(diào)用MrInit時(shí)返回的值</param>[in]
/// <param name="piOutPkgLen">接收到消息包的實(shí)際長(zhǎng)度</param>[out]
/// <param name="pMsgPropery">接收條件</param>[in/out]
/// <param name="iMillSecTimeo">以毫米為單位的接收最大超時(shí)時(shí)間</param>[in]
/// <returns>0 成功 其他 失敗</returns>
[DllImport("mrapi.dll", EntryPoint = "MrBrowse", CallingConvention = CallingConvention.StdCall, SetLastError = true, CharSet = CharSet.Ansi)]
public static extern int MrBrowse(IntPtr pHandle, out int piOutPkgLen, ref STUsgProperty pMsgPropery, int iMillSecTimeo);
//int _stdcall MrBrowse(void* pHandle, int* piOutPkgLen, STUMsgProperty* pMsgPropery, int iMillSecTimeo);
/// <summary>
/// 11.消息包接收函數(shù)2
/// </summary>
/// <param name="pHandle">連接句柄,調(diào)用MrInit時(shí)返回的值</param>[in]
/// <param name="ppsPkg">雙指針,返回包所指向的內(nèi)存</param>[out]
/// <param name="piOutPkgLen">接收到消息包的實(shí)際長(zhǎng)度</param>[out]
/// <param name="iBufLenIn">消息包緩沖區(qū)大小</param>[out]
/// <param name="pMsgPropery">接收條件</param>[in/out]
/// <param name="iMillSecTimeo">以毫米為單位的接收最大超時(shí)時(shí)間</param>[in]
/// <returns>0 成功 其他 失敗</returns>
[DllImport("mrapi.dll", EntryPoint = "MrReceive2", CallingConvention = CallingConvention.StdCall, SetLastError = true, CharSet = CharSet.Ansi)]
public static extern int MrReceive2(IntPtr pHandle, out IntPtr ppsPkg, out int piOutPkgLen, out int iBufLenIn, ref STUsgProperty pMsgPropery, int iMillSecTimeo);
//int _stdcall MrReceive2(void* pHandle, char** ppsPkg, int* piOutPkgLen, int* iBufLenIn, STUMsgProperty* pMsgPropery, int iMillSecTimeo);
/// <summary>
/// 12.消息包接收函數(shù)3
/// </summary>
/// <param name="pHandle">連接句柄,調(diào)用MrInit時(shí)返回的值</param>[in]
/// <param name="ppsPkg">雙指針,返回包所指向的內(nèi)存</param>[out]
/// <param name="piOutPkgLen">接收到消息包的實(shí)際長(zhǎng)度</param>[out]
/// <param name="piErrSXCode">交換錯(cuò)誤的原因碼</param>[out]
/// <param name="pMsgPropery">接收條件</param>[in/out]
/// <param name="iMillSecTimeo">以毫米為單位的接收最大超時(shí)時(shí)間</param>[in]
/// <returns>0 成功 其他 失敗</returns>
[DllImport("mrapi.dll", EntryPoint = "MrReceive3", CallingConvention = CallingConvention.StdCall, SetLastError = true, CharSet = CharSet.Ansi)]
public static extern int MrReceive3(IntPtr pHandle, out IntPtr ppsPkg, out int piOutPkgLen, out int piErrSXCode, ref STUsgProperty pMsgPropery, int iMillSecTimeo);
//int _stdcall MrReceive3(void* pHandle, char** ppsPkg, int* piOutPkgLen, int* piErrSXCode, STUMsgProperty* pMsgPropery, int iMillSecTimeo);
/// <summary>
/// 13.消息包接收函數(shù)4
/// </summary>
/// <param name="pHandle">連接句柄,調(diào)用MrInit時(shí)返回的值</param>[in]
/// <param name="ppsPkg">雙指針,返回包所指向的內(nèi)存</param>[out]
/// <param name="piOutPkgLen">接收到消息包的實(shí)際長(zhǎng)度</param>[out]
/// <param name="piErrSXCode">交換錯(cuò)誤的原因碼</param>[out]
/// <param name="pMsgPropery">接收條件</param>[in/out]
/// <param name="iMillSecTimeo">以毫米為單位的接收最大超時(shí)時(shí)間</param>[in]
/// <returns>0 成功 其他 失敗</returns>
[DllImport("mrapi.dll", EntryPoint = "MrReceive4", CallingConvention = CallingConvention.StdCall, SetLastError = true, CharSet = CharSet.Ansi)]
public static extern int MrReceive4(IntPtr pHandle, out IntPtr ppsPkg, out int piOutPkgLen, out int piErrSXCode, ref STUsgProperty pMsgPropery, int iMillSecTimeo);
//int _stdcall MrReceive4(void* pHandle, char** ppsPkg, int* piOutPkgLen, int* piErrSXCode, STUMsgProperty* pMsgPropery, int iMillSecTimeo);
/// <summary>
/// 14.釋放資源
/// </summary>
/// <param name="pHandle">連接句柄,調(diào)用MrInit時(shí)返回的值</param>
/// <returns>無(wú)</returns>
[DllImport("mrapi.dll", EntryPoint = "MrDestroy", CallingConvention = CallingConvention.StdCall, SetLastError = true, CharSet = CharSet.Ansi)]
public static extern IntPtr MrDestroy(IntPtr pHandle);
//void _stdcall MrDestroy(void* pHandle)
/// <summary>
/// 15.取得本API的版本號(hào)
/// </summary>
/// <param name="psBufVersion">返回的版本號(hào)</param>
/// <param name="iBufLen">版本號(hào)長(zhǎng)度</param>
/// <returns>無(wú)</returns>
[DllImport("mrapi.dll", EntryPoint = "MrGetVersion", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Ansi)]
public static extern IntPtr MrGetVersion(StringBuilder psBufVersion, int iBufLen);
//void _stdcall MrGetVersion(char* psBufVersion,int iBufLen);
/// <summary>
/// 16.注冊(cè)包下推條件
/// </summary>
/// <param name="pHandle">連接句柄,調(diào)用MrInit時(shí)返回的值<</param>
/// <param name="pMsgPropery">消息的結(jié)構(gòu)實(shí)體</param>
/// <param name="iType">0 增加一個(gè)條件 1 刪除一個(gè)條件 2 清空所有條件</param>
/// <returns>0 成功 其他 失敗</returns>
[DllImport("mrapi.dll", EntryPoint = "MrRegRecvCondition", CallingConvention = CallingConvention.StdCall, SetLastError = true, CharSet = CharSet.Ansi)]
public static extern int MrRegRecvCondition(IntPtr pHandle, ref STUsgProperty pMsgPropery, int iType);
//int _stdcall MrRegRecvCondition(void* pHandle,STUMsgProperty* pMsgPropery,int iType);
#endregion
}
}
- C# 調(diào)用C++寫的dll的實(shí)現(xiàn)方法
- C++調(diào)用C#的DLL實(shí)現(xiàn)方法
- C++與C#互調(diào)dll的實(shí)現(xiàn)步驟
- C#調(diào)用C++版本dll時(shí)的類型轉(zhuǎn)換需要注意的問(wèn)題小結(jié)
- C++聯(lián)合體轉(zhuǎn)換成C#結(jié)構(gòu)的實(shí)現(xiàn)方法
- c++與c#的時(shí)間轉(zhuǎn)換示例分享
- C#統(tǒng)計(jì)C、C++及C#程序代碼行數(shù)的方法
- C++調(diào)用C#的DLL程序?qū)崿F(xiàn)方法
- C#如何調(diào)用原生C++ COM對(duì)象詳解
相關(guān)文章
Unity Undo實(shí)現(xiàn)原理和使用方法詳解
本文將詳細(xì)介紹Unity Undo實(shí)現(xiàn)原理和使用方法,并提供多個(gè)使用例子,幫助開(kāi)發(fā)者更好地理解和應(yīng)用該功能,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2023-07-07Unity3D移動(dòng)端實(shí)現(xiàn)搖一搖功能
這篇文章主要為大家詳細(xì)介紹了基于Unity3D移動(dòng)端實(shí)現(xiàn)搖一搖功能,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2019-10-10MVC設(shè)定默認(rèn)路由為指定的Area下的某個(gè)action
今天小編就為大家分享一篇關(guān)于MVC設(shè)定默認(rèn)路由為指定的Area下的某個(gè)action,小編覺(jué)得內(nèi)容挺不錯(cuò)的,現(xiàn)在分享給大家,具有很好的參考價(jià)值,需要的朋友一起跟隨小編來(lái)看看吧2019-01-01c# Invoke和BeginInvoke 區(qū)別分析
這篇文章主要介紹了c# Invoke和BeginInvoke 區(qū)別分析,需要的朋友可以參考下2014-10-10關(guān)于C#基礎(chǔ)知識(shí)回顧--反射(三)
在前面例子中,由于MyClass類型的對(duì)象是顯示創(chuàng)建的,因此使用反射技術(shù)來(lái)調(diào)用MyClass上的方法沒(méi)有任何優(yōu)勢(shì)--以普通的方式調(diào)用對(duì)象上的方法會(huì)簡(jiǎn)單的多2013-07-07基于WebClient實(shí)現(xiàn)Http協(xié)議的Post與Get對(duì)網(wǎng)站進(jìn)行模擬登陸和瀏覽實(shí)例
這篇文章主要介紹了基于WebClient實(shí)現(xiàn)Http協(xié)議的Post與Get對(duì)網(wǎng)站進(jìn)行模擬登陸和瀏覽的方法,以實(shí)例形式詳細(xì)分析了WebClient模擬POST與GET登陸與瀏覽的過(guò)程,對(duì)于C#項(xiàng)目開(kāi)發(fā)來(lái)說(shuō)具有不錯(cuò)的參考借鑒價(jià)值,需要的朋友可以參考下2014-11-11C#實(shí)現(xiàn)AddRange為數(shù)組添加多個(gè)元素的方法
這篇文章主要介紹了C#實(shí)現(xiàn)AddRange為數(shù)組添加多個(gè)元素的方法,實(shí)例分析了AddRange方法的使用技巧,需要的朋友可以參考下2015-06-06