nativemethods.cs

来自「QQ自动消息发送器 适用于适度的骚扰您的好友们。」· CS 代码 · 共 78 行

CS
78
字号
/*
 *--------------------------------------------------------
 *	Class Name(类名):	NativMethods
 *	Author(创建者):		三角猫
 *	Email(电子邮件):	alex_zzg@163.com
 *	Create Time(创建时间):	2008/01/15 21:27:18 
 *	CLR Version(CLR版本):	2.0.50727.312
 *	Copyright (c) 		三角猫 www.zu14.cn
 *	All Rights Reserved.
 *	File Memo(备注):
 *--------------------------------------------------------
*/
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;

namespace QQAutoMsg
{
    /// <summary>
    /// API声明类
    /// </summary>
    internal static class NativeMethods
    {
        #region Callback Delegate Section
        internal delegate bool EnumDesktopWindowsDelegate(IntPtr hWnd, uint lParam);
        #endregion

        #region Windows API Import Section

        //[DllImport("user32.dll", EntryPoint = "FindWindow", SetLastError = true, CharSet = CharSet.Unicode)]
        //internal static extern IntPtr FindWindow(string lpClassName, string lpWindowName);

        [DllImport("user32.dll", EntryPoint = "FindWindowEx", SetLastError = true, CharSet = CharSet.Unicode)]
        internal static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, string lpszClass, 
            string lpszWindow);

        [DllImport("user32.dll", EntryPoint = "GetWindowTextLength", SetLastError = true, 
            CharSet = CharSet.Unicode)]
        internal static extern int GetWindowTextLength(IntPtr hWnd);

        [DllImport("user32.dll", EntryPoint = "GetWindowText", CharSet = CharSet.Unicode, SetLastError = true)]
        internal static extern int GetWindowText(IntPtr hWnd, StringBuilder lpString, int nMaxCount);

        [DllImport("user32.dll", EntryPoint = "GetClassName", CharSet = CharSet.Unicode, SetLastError = true)]
        internal static extern int GetClassName(IntPtr hWnd, StringBuilder buf, int nMaxCount);

        [DllImport("user32.dll", EntryPoint = "EnumDesktopWindows", ExactSpelling = false, 
            CharSet = CharSet.Auto, SetLastError = true)]
        [return: MarshalAs(UnmanagedType.Bool)]
        internal static extern bool EnumDesktopWindows(IntPtr hDesktop, 
            EnumDesktopWindowsDelegate lpEnumCallbackFunction, IntPtr lParam);

        [DllImport("user32.dll", EntryPoint = "SendMessage", SetLastError = true, CharSet = CharSet.Unicode)]
        internal static extern IntPtr SendMessage(IntPtr hWnd, uint wMsg, IntPtr wParam, string lParam);

        [DllImport("user32.dll", EntryPoint = "SendMessage", SetLastError = true, CharSet = CharSet.Auto)]
        internal static extern IntPtr SendMessage(IntPtr hWnd, uint wMsg, IntPtr wParam, IntPtr lParam);

        [DllImport("user32.dll", EntryPoint = "GetWindow", SetLastError = true)]
        internal static extern IntPtr GetWindow(IntPtr hWnd, uint wCmd);

        [DllImport("user32.dll", EntryPoint = "IsWindow", SetLastError = true)]
        [return: MarshalAs(UnmanagedType.Bool)]
        internal static extern bool IsWindow(IntPtr hWnd);

        #endregion

        #region Windows Message Declaration Section

        internal const uint BM_CLICK = 0xF5;
        internal const uint GW_HWNDNEXT = 0x02;
        internal const uint EM_REPLACESEL = 0xC2;

        #endregion
    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?