zoukankan      html  css  js  c++  java
  • WinAPI

    using System;
    using System.Collections.Generic;
    using System.Text;
    using System.Runtime.InteropServices;

    namespace MineMan
    {
        public class WinAPI
        {
            //
            //  內存讀取部分
            //
            [DllImport("kernel32.dll")] // 打開內存讀取
            public static extern IntPtr OpenProcess(int dwDesiredAccess, int bInheritHandle, int dwProcessId);

            [DllImport("kernel32.dll")] // 關閉內存讀取
            public static extern Int32 CloseHandle(IntPtr hObject);

            [DllImport("kernel32.dll")] // 讀取內存
            public static extern int ReadProcessMemory(IntPtr hProcess, int lpBaseAddress, ref int lpBuffer, int nSize, int lpNumberOfBytesWritten);


            //
            //  鼠標控制部分
            //
            [DllImport("User32")]   // 設置鼠標位置
            public extern static int SetCursorPos(int x, int y);

            [DllImport("User32")]   // 隱藏或顯示鼠標
            public extern static int ShowCursor(bool bShow);

            [DllImport("user32")]   // 模擬鼠標事件
            public extern static void mouse_event(int dwFlags, int dx, int dy, int dwData, IntPtr dwExtraInfo);


            //
            //  窗體相關部分
            //
            [DllImport("USER32.DLL")]   // 查找窗體句柄
            public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);

            [DllImport("USER32.DLL")]   // 設置窗體置頂
            public static extern bool SetForegroundWindow(IntPtr hWnd);

            [DllImport("user32")]       // 獲得窗體位置
            public static extern bool GetWindowRect(IntPtr hwnd, ref RECT lpRect);

            public struct RECT          // 用於接受窗體位置的RECT結構,順序不可更改
            {
                public int left;    // 窗體最左邊,距離屏幕左邊的值
                public int top;     // 窗體最上邊,距離屏幕上邊的值
                public int right;   // 窗體最右邊,距離屏幕左邊的值
                public int bottom;  // 窗體最右邊,距離屏幕上邊的值
            }


            //
            //  系統熱鍵部分
            //
            [DllImport("USER32.DLL")]   // 註冊熱鍵
            public static extern bool RegisterHotKey(IntPtr hWnd, int id, uint control, System.Windows.Forms.Keys vk);

            [DllImport("USER32.DLL")]   // 卸載熱鍵
            public static extern bool UnregisterHotKey(IntPtr hWnd, int id);
        }
    }

  • 相关阅读:
    富文本ZSSRichTextEditor之趟坑集锦
    iOS11及Xcode9适配问题汇总
    XIB中拖UIScrollView的困难
    Glide加载图片问题记录
    微信关注事件bug记录
    kswapd0 进程 设置 swap
    AJAX请求返回HTTP 400 错误
    通过jQuery Ajax提交表单数据时同时上传附件
    JS---DOM---事件冒泡和阻止事件冒泡,总结事件
    JS---DOM---为元素绑定事件和解绑事件的兼容代码
  • 原文地址:https://www.cnblogs.com/yellowapplemylove/p/2021590.html
Copyright © 2011-2022 走看看