/* * 由SharpDevelop创建。 * 用户: kst * 日期: 2019/6/5 星期三 * 时间: 11:27 * * 要改变这种模板请点击 工具|选项|代码编写|编辑标准头文件 */ using System; using System.Runtime.InteropServices; using System.Text.RegularExpressions; using System.Text; namespace PCRobot.WechatApi { /// /// Description of KstAPI. /// public class KstAPI { public const int 通信_连接成功 = 1; public const int 通信_数据到达 = 2; public const int 通信_连接断开 = 3; public const int 回调_二维码 = 1; public const int 回调_登录成功 = 2; public const int 回调_退出登陆 = 3; public const int 回调_接收消息 = 4; public const int 回调_添加好友 = 100001; public const int 回调_下载信息 = 100002; public const int 回调_建群返回 = 100003; public const int 回调_A8Key = 100004; public const int 回调_聊天对象 = 100007; public const int 回调_语音消息 = 100009; public const int 回调_文件消息 = 100010; public const int 回调_视频消息 = 100011; public const int 回调_图片消息 = 100012; public const int 回调_好友列表 = 300001; public const int 回调_群员列表 = 300002; [DllImport("KstAPI.dll",EntryPoint="#7")] public static extern int kst_DLLConnect(int Pwd,int Port); [DllImport("KstAPI.dll",EntryPoint="#6")] public static extern int kst_GetPath(ref byte str); [DllImport("KstAPI.dll",EntryPoint="#5")] public static extern int kst_CreateWx(string ExeFile,string ExeName,string DllName,int lPort); [DllImport("KstAPI.dll",EntryPoint="#1")] public static extern int kstSocket_Init(IntPtr sFun, IntPtr cFun, int buflen); [DllImport("KstAPI.dll",EntryPoint="#2")] public static extern int kstSocket_Create(string host, int sPort, int nIS); [DllImport("KstAPI.dll",EntryPoint="#3")] public static extern int kstSocket_Send(int sPoint, int sPort, byte[] buf, int buflen); [DllImport("KstAPI.dll",EntryPoint="#4")] public static extern int kstSocket_Port(int so); [DllImport("kernel32.dll",EntryPoint="RtlMoveMemory")] public static extern int RtlMoveMemory(byte[] sByte, int Source, int Length); //服务端回调 public delegate void dele_Server_CallBack(int sPoint, int so, int type, int buf, int buflen, int cso); public dele_Server_CallBack sc; //客户端回调 public delegate void dele_Client_CallBack(int so, int sPoint, int type, int buf, int buflen); public dele_Client_CallBack cc; public static string EnUnicode(string str) { StringBuilder strResult = new StringBuilder(); if (!string.IsNullOrEmpty(str)) { for (int i = 0; i < str.Length; i++) { strResult.Append("\\u"); strResult.Append(((int)str[i]).ToString("X4")); } } return strResult.ToString(); } public static string DeUnicode(string str) { string strResult = Regex.Unescape(str); return strResult; } } }