⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 win32.cs

📁 a simple source code on Remote desktop using blue tooth. Mouse control and desktop screen shot captu
💻 CS
📖 第 1 页 / 共 3 页
字号:
using System;
using System.Text;
using System.Windows.Forms;
using System.Drawing;
using System.Runtime.InteropServices;
namespace WindowsApplication1
{
        public class Win32
        {
            public const uint MAX_PATH = 260;

            #region Hooks - user32.dll

            /// <summary>
            /// Defines the layout of the MouseHookStruct
            /// </summary>
            [StructLayout(LayoutKind.Sequential)]
            public struct MSLLHOOKSTRUCT
            {
                public Point Point;
                public int MouseData;
                public int Flags;
                public int Time;
                public int ExtraInfo;
            }

            /// <summary>
            ///  EventArgs class for use as parameters by HookEventHandler delegates
            /// </summary>
            public class HookEventArgs : EventArgs
            {
                private int _code;
                private IntPtr _wParam;
                private IntPtr _lParam;

                /// <summary>
                /// Initializes a new instance of the HookEventArgs class
                /// </summary>
                /// <param name="code">the hook code</param>
                /// <param name="wParam">hook specific information</param>
                /// <param name="lParam">hook specific information</param>
                public HookEventArgs(int code, IntPtr wParam, IntPtr lParam)
                {
                    _code = code;
                    _wParam = wParam;
                    _lParam = lParam;
                }

                /// <summary>
                /// The hook code
                /// </summary>
                public int Code
                {
                    get
                    {
                        return _code;
                    }
                }

                /// <summary>
                /// A pointer to data
                /// </summary>
                public IntPtr wParam
                {
                    get
                    {
                        return _wParam;
                    }
                }

                /// <summary>
                /// A pointer to data
                /// </summary>
                public IntPtr lParam
                {
                    get
                    {
                        return _lParam;
                    }
                }
            }

            /// <summary>
            /// Event delegate for use with the HookEventArgs class
            /// </summary>
            public delegate void HookEventHandler(object sender, HookEventArgs e);

            /// <summary>
            /// Defines the various types of hooks that are available in Windows
            /// </summary>
            public enum HookTypes : int
            {
                WH_JOURNALRECORD = 0,
                WH_JOURNALPLAYBACK = 1,
                WH_KEYBOARD = 2,
                WH_GETMESSAGE = 3,
                WH_CALLWNDPROC = 4,
                WH_CBT = 5,
                WH_SYSMSGFILTER = 6,
                WH_MOUSE = 7,
                WH_HARDWARE = 8,
                WH_DEBUG = 9,
                WH_SHELL = 10,
                WH_FOREGROUNDIDLE = 11,
                WH_CALLWNDPROCRET = 12,
                WH_KEYBOARD_LL = 13,
                WH_MOUSE_LL = 14
            }

            public enum ShellHookMessages
            {
                HSHELL_WINDOWCREATED = 1,
                HSHELL_WINDOWDESTROYED = 2,
                HSHELL_ACTIVATESHELLWINDOW = 3,
                HSHELL_WINDOWACTIVATED = 4,
                HSHELL_GETMINRECT = 5,
                HSHELL_REDRAW = 6,
                HSHELL_TASKMAN = 7,
                HSHELL_LANGUAGE = 8,
                HSHELL_ACCESSIBILITYSTATE = 11
            }

            public delegate int HookProc(int nCode, IntPtr wParam, IntPtr lParam);

            [DllImport("user32.dll")]
            public static extern IntPtr SetWindowsHookEx(HookTypes hookType, HookProc hookProc, IntPtr hInstance, int nThreadId);

            [DllImport("user32.dll")]
            public static extern int UnhookWindowsHookEx(IntPtr hookHandle);

            [DllImport("user32.dll")]
            public static extern int CallNextHookEx(IntPtr hookHandle, int nCode, IntPtr wParam, IntPtr lParam);

            [DllImport("user32.dll")]
            public static extern int RegisterShellHookWindow(IntPtr hWnd);

            [DllImport("user32.dll")]
            public static extern int DeregisterShellHookWindow(IntPtr hWnd);

            #endregion Hooks

            #region System - Kernel32.dll

            [DllImport("kernel32.dll", EntryPoint = "GetLastError", SetLastError = true, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)]
            public static extern Int32 GetLastError();

            #endregion

            #region Windows - user32.dll

            public const int GWL_HWNDPARENT = (-8);
            public const int GWL_EXSTYLE = (-20);
            public const int GWL_STYLE = (-16);
            public const int GCL_HICON = (-14);
            public const int GCL_HICONSM = (-34);
            public const int WM_QUERYDRAGICON = 0x37;
            public const int WM_GETICON = 0x7F;
            public const int WM_SETICON = 0x80;
            public const int ICON_SMALL = 0;
            public const int ICON_BIG = 1;
            public const int SMTO_ABORTIFHUNG = 0x2;
            public const int TRUE = 1;
            public const int FALSE = 0;

            public const int WHITE_BRUSH = 0;
            public const int LTGRAY_BRUSH = 1;
            public const int GRAY_BRUSH = 2;
            public const int DKGRAY_BRUSH = 3;
            public const int BLACK_BRUSH = 4;
            public const int NULL_BRUSH = 5;
            public const int HOLLOW_BRUSH = NULL_BRUSH;
            public const int WHITE_PEN = 6;
            public const int BLACK_PEN = 7;
            public const int NULL_PEN = 8;
            public const int OEM_FIXED_FONT = 10;
            public const int ANSI_FIXED_FONT = 11;
            public const int ANSI_VAR_FONT = 12;
            public const int SYSTEM_FONT = 13;
            public const int DEVICE_DEFAULT_FONT = 14;
            public const int DEFAULT_PALETTE = 15;
            public const int SYSTEM_FIXED_FONT = 16;


            public const int RDW_INVALIDATE = 0x0001;
            public const int RDW_INTERNALPAINT = 0x0002;
            public const int RDW_ERASE = 0x0004;

            public const int RDW_VALIDATE = 0x0008;
            public const int RDW_NOINTERNALPAINT = 0x0010;
            public const int RDW_NOERASE = 0x0020;

            public const int RDW_NOCHILDREN = 0x0040;
            public const int RDW_ALLCHILDREN = 0x0080;

            public const int RDW_UPDATENOW = 0x0100;
            public const int RDW_ERASENOW = 0x0200;

            public const int RDW_FRAME = 0x0400;
            public const int RDW_NOFRAME = 0x0800;



            public enum ShowWindowCmds
            {
                SW_HIDE = 0,
                SW_SHOWNORMAL = 1,
                SW_NORMAL = 1,
                SW_SHOWMINIMIZED = 2,
                SW_SHOWMAXIMIZED = 3,
                SW_MAXIMIZE = 3,
                SW_SHOWNOACTIVATE = 4,
                SW_SHOW = 5,
                SW_MINIMIZE = 6,
                SW_SHOWMINNOACTIVE = 7,
                SW_SHOWNA = 8,
                SW_RESTORE = 9,
                SW_SHOWDEFAULT = 10,
                SW_FORCEMINIMIZE = 11,
                SW_MAX = 11
            }

            public const int HIDE_WINDOW = 0;
            public const int SHOW_OPENWINDOW = 1;
            public const int SHOW_ICONWINDOW = 2;
            public const int SHOW_FULLSCREEN = 3;
            public const int SHOW_OPENNOACTIVATE = 4;
            public const int SW_PARENTCLOSING = 1;
            public const int SW_OTHERZOOM = 2;
            public const int SW_PARENTOPENING = 3;
            public const int SW_OTHERUNZOOM = 4;

            public const int SWP_NOSIZE = 0x0001;
            public const int SWP_NOMOVE = 0x0002;
            public const int SWP_NOZORDER = 0x0004;
            public const int SWP_NOREDRAW = 0x0008;
            public const int SWP_NOACTIVATE = 0x0010;
            public const int SWP_FRAMECHANGED = 0x0020; /* The frame changed: send WM_NCCALCSIZE */
            public const int SWP_SHOWWINDOW = 0x0040;
            public const int SWP_HIDEWINDOW = 0x0080;
            public const int SWP_NOCOPYBITS = 0x0100;
            public const int SWP_NOOWNERZORDER = 0x0200; /* Don't do owner Z ordering */
            public const int SWP_NOSENDCHANGING = 0x0400;  /* Don't send WM_WINDOWPOSCHANGING */
            public const int SWP_DRAWFRAME = SWP_FRAMECHANGED;
            public const int SWP_NOREPOSITION = SWP_NOOWNERZORDER;
            public const int SWP_DEFERERASE = 0x2000;
            public const int SWP_ASYNCWINDOWPOS = 0x4000;

            public const int HWND_TOP = 0;
            public const int HWND_BOTTOM = 1;
            public const int HWND_TOPMOST = -1;
            public const int HWND_NOTOPMOST = -2;

            public enum PeekMessageFlags
            {
                PM_NOREMOVE = 0,
                PM_REMOVE = 1,
                PM_NOYIELD = 2
            }

            public enum WindowMessages
            {
                WM_NULL = 0x0000,
                WM_CREATE = 0x0001,
                WM_DESTROY = 0x0002,
                WM_MOVE = 0x0003,
                WM_SIZE = 0x0005,
                WM_ACTIVATE = 0x0006,
                WM_SETFOCUS = 0x0007,
                WM_KILLFOCUS = 0x0008,
                WM_ENABLE = 0x000A,
                WM_SETREDRAW = 0x000B,
                WM_SETTEXT = 0x000C,
                WM_GETTEXT = 0x000D,
                WM_GETTEXTLENGTH = 0x000E,
                WM_PAINT = 0x000F,
                WM_CLOSE = 0x0010,

⌨️ 快捷键说明

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