Personal micro-channel Hook-C # Demo development SDK

Basic information class

Access to personal information
to obtain information from the network group members
to obtain personal information from the network
to obtain public information number
to obtain information group
acquiring group member information
to obtain information about a single Friend

Friends operations

Modification friend Remarks
Add Friend
Remove Friend
agree plus friend requests
agreed to invite friends into the group
transfer to receive friends

Group operating classes

Remove and exit
saved to / out of the address book
whether group members nickname
change my nickname in this group
modification notice
to modify the name of the group
kicked out of the group members
to invite friends into the group
to create a group chat

send Message

Send a business card
hair link
send pictures
issued a document
made a video
send gif
texting

Receive information

Receive text messages
receive a picture message
is received business cards
to receive video
receiving expressions
receive location
to receive a system message
is received revocation message
is received other messages

Demo Minamoto码

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace WxHookDemo
{
    public partial class FormMain : Form
    {
        public delegate void AcceptCallbackFunc(uint dwClientId);
        public delegate void RecvCallbackFunc(uint dwClientId, IntPtr intPtr, uint dwSize);
        public delegate void CloseCallbackFunc(uint dwClientId);
        private static AcceptCallbackFunc m_AcceptCallbackFunc;
        private static RecvCallbackFunc m_RecvCallbackFunc;
        private static CloseCallbackFunc m_CloseCallbackFunc;
        // 引入DLL导出函数
        [DllImport("WxLoader.dll")]
        public static extern bool InitWeChatSocket(AcceptCallbackFunc acceptCallback,
            RecvCallbackFunc recvCallback, CloseCallbackFunc closeCallback);
        [DllImport("WxLoader.dll")]
        public static extern uint InjectWeChat(String strDllPath);
        [DllImport("WxLoader.dll")]
        public static extern bool SendWeChatData(uint dwClienId, String strJsonData);
        [DllImport("WxLoader.dll")]
        public static extern bool DestroyWeChat();
        // 建一个主窗口的实例,让静态方法可以访问
        public static FormMain Instance = null;
        // 存一个clientId,用于发送消息 (多客户端自己来维护clientId)
        public static uint WxClientId = 0;
        // 注入成功回调
        static void WxAcceptCallback(uint dwClientId)
        {
            FormMain.WxClientId = dwClientId;
            FormMain.Instance.textBoxLog.BeginInvoke(new Action(() => { FormMain.Instance.textBoxLog.AppendText("Accept\n"); }));
        }
        // 接收消息回调
        static void WxRecvCallback(uint dwClient, IntPtr intPtr, uint dwSize)
        {
            String recvData = Marshal.PtrToStringAnsi(intPtr);
            FormMain.Instance.Invoke(new Action<String>(FormMain.Instance.textBoxLog.AppendText), recvData + "\n");
        }
        // 关闭回调
        static void WxCloseCallback(uint dwClient)
        {
            FormMain.Instance.Invoke(new Action<String>(FormMain.Instance.textBoxLog.AppendText), "Close\n");
        }
        public FormMain()
        {
            InitializeComponent();
            Control.CheckForIllegalCrossThreadCalls = false;
        }
        private void buttonOpen_Click(object sender, EventArgs e)
        {
            // 注入并多开
            String dllPath = System.IO.Directory.GetCurrentDirectory() + "\\WeChatHelper.dll";
            InjectWeChat("WeChatHelper.dll");
        }
        private void buttonSend_Click(object sender, EventArgs e)
        {
            // 构造json消息,可使用相关Json库
            String strMsg = "{\"type\": 11036, \"data\":{\"to_wxid\":\"" +
                textBoxWxid.Text + "\", \"content\":\"" + textBoxMsg.Text + "\"}}";
            SendWeChatData(WxClientId, strMsg);
        }
        private void FormMain_FormClosing(object sender, FormClosingEventArgs e)
        {
            // 释放Socket并卸载注入的dll
            DestroyWeChat();
        }
        private void FormMain_Load(object sender, EventArgs e)
        {
            Instance = this;
            m_AcceptCallbackFunc = WxAcceptCallback;
            m_RecvCallbackFunc = WxRecvCallback;
            m_CloseCallbackFunc = WxCloseCallback;
            // 初始化Callback
            InitWeChatSocket(m_AcceptCallbackFunc, m_RecvCallbackFunc, m_CloseCallbackFunc);
        }
        private void button1_Click(object sender, EventArgs e)
        {
            // 构造json消息,可使用相关Json库
            String strMsg = "{\"type\": 11030}";
            SendWeChatData(WxClientId, strMsg);
        }
    }
}

https://www.showdoc.cc/505015445242065?page_id=2980813708300422

Guess you like

Origin www.cnblogs.com/wechat-hook/p/11563986.html
Recommended