old_flsystem/PCRobot/WxRobot/API/KstAPI.cs

99 lines
3.1 KiB
C#
Raw Permalink Normal View History

2022-09-20 03:10:29 +00:00
/*
* SharpDevelop创建
* kst
* : 2019/6/5
* : 11:27
*
* |||
*/
using System;
using System.Runtime.InteropServices;
using System.Text.RegularExpressions;
using System.Text;
namespace WxRobot
{
/// <summary>
/// Description of KstAPI.
/// </summary>
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;
}
}
}