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

📄 win32.cs

📁 a simple source code on Remote desktop using blue tooth. Mouse control and desktop screen shot captu
💻 CS
📖 第 1 页 / 共 3 页
字号:

            [DllImport("user32.dll")]
            public static extern int GetWindowModuleFileName(IntPtr hWnd, StringBuilder lpString, int nMaxCount);

            [DllImport("user32.dll")]
            public static extern int SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X, int Y, int cx, int cy, uint uFlags);

            [DllImport("user32.dll")]
            public static extern bool GetWindowPlacement(IntPtr window, ref WindowPlacement position);

            [DllImport("User32.dll")]
            public static extern int RegisterWindowMessage(string message);

            [DllImport("User32.dll")]
            public static extern void EnumWindows(EnumWindowEventHandler callback, Int32 lParam);

            //		[DllImport("User32.dll")]
            //		public static extern Int32 GetWindowText(IntPtr hWnd, StringBuilder lpString, Int32 nMaxCount);

            [DllImport("User32.dll")]
            public static extern bool IsWindowVisible(IntPtr hWnd);

            [DllImport("User32.dll")]
            public static extern Int32 GetWindow(IntPtr hWnd, Int32 wCmd);

            //		[DllImport("User32.dll")]
            //		public static extern WindowStyles GetWindowLong(IntPtr hWnd, Int32 index);

            [DllImport("User32.dll")]
            public static extern IntPtr GetParent(IntPtr hWnd);

            [DllImport("User32.dll")]
            public static extern int GetClassName(IntPtr hWnd, StringBuilder lpClassName, int nMaxCount);

            [DllImport("User32.dll")]
            public static extern int GetWindowText(IntPtr hWnd, StringBuilder lpString, int nMaxCount);

            [DllImport("User32.dll")]
            public static extern WindowStyles GetWindowLong(IntPtr hWnd, int index);

            [DllImport("User32.dll")]
            public static extern int SendMessageTimeout(IntPtr hWnd, int uMsg, int wParam, int lParam, int fuFlags, int uTimeout, out int lpdwResult);

            [DllImport("User32.dll")]
            public static extern int GetClassLong(IntPtr hWnd, int index);

            [DllImport("User32.dll")]
            public static extern int GetWindowThreadProcessId(IntPtr hWnd, out int processId);

            [DllImport("User32.dll")]
            public static extern int SendMessage(IntPtr hWnd, int uMsg, IntPtr wParam, IntPtr lParam);

            [DllImport("User32.dll")]
            public static extern int PostMessage(IntPtr hWnd, int uMsg, IntPtr wParam, IntPtr lParam);

            [DllImport("User32.dll")]
            public static extern void SwitchToThisWindow(IntPtr hWnd, int altTabActivated);

            [DllImport("User32.dll")]
            public static extern int ShowWindowAsync(IntPtr hWnd, int command);

            [DllImport("user32.dll")]
            public static extern IntPtr GetDesktopWindow();

            [DllImport("user32.dll")]
            public static extern IntPtr GetForegroundWindow();

            [DllImport("user32.dll")]
            public static extern bool BringWindowToTop(IntPtr window);

            [DllImport("user32.dll")]
            public static extern bool GetWindowInfo(IntPtr hwnd, ref WindowInfo info);

            [DllImport("user32.dll")]
            public static extern IntPtr GetWindowDC(IntPtr hwnd);

            [DllImport("user32.dll")]
            public static extern IntPtr GetDC(IntPtr hwnd);

            [DllImport("user32.dll")]
            public static extern Int32 ReleaseDC(IntPtr hwnd, IntPtr hdc);

            [DllImport("user32.dll")]
            public static extern bool GetWindowRect(IntPtr hwnd, ref Rect rectangle);

            [DllImport("user32.dll")]
            public static extern bool GetClientRect(IntPtr hwnd, ref Rect rectangle);

            [DllImport("user32.dll")]
            public static extern IntPtr WindowFromPoint(Point pt);

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

            [DllImport("user32.dll")]
            public static extern int ReleaseCapture();

            [DllImport("user32.dll")]
            public static extern IntPtr SelectObject(IntPtr hDc, IntPtr hObject);

            [DllImport("user32.dll")]
            public static extern IntPtr GetStockObject(int nObject);

            [DllImport("user32.dll")]
            public static extern int InvalidateRect(IntPtr hWnd, IntPtr lpRect, int bErase);

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

            [DllImport("user32.dll")]
            public static extern int RedrawWindow(IntPtr hWnd, IntPtr lprcUpdate, IntPtr hrgnUpdate, uint flags);

            #endregion Windows

            #region GDI - gdi32.dll

            public enum BinaryRasterOperations
            {
                R2_BLACK = 1,   /*  0       */
                R2_NOTMERGEPEN = 2,   /* DPon     */
                R2_MASKNOTPEN = 3,   /* DPna     */
                R2_NOTCOPYPEN = 4,   /* PN       */
                R2_MASKPENNOT = 5,   /* PDna     */
                R2_NOT = 6,   /* Dn       */
                R2_XORPEN = 7,   /* DPx      */
                R2_NOTMASKPEN = 8,   /* DPan     */
                R2_MASKPEN = 9,   /* DPa      */
                R2_NOTXORPEN = 10,  /* DPxn     */
                R2_NOP = 11,  /* D        */
                R2_MERGENOTPEN = 12,  /* DPno     */
                R2_COPYPEN = 13,  /* P        */
                R2_MERGEPENNOT = 14,  /* PDno     */
                R2_MERGEPEN = 15,  /* DPo      */
                R2_WHITE = 16,  /*  1       */
                R2_LAST = 16
            }

            public enum TernaryRasterOperations
            {
                SRCCOPY = 0x00CC0020, /* dest = source                   */
                SRCPAINT = 0x00EE0086, /* dest = source OR dest           */
                SRCAND = 0x008800C6, /* dest = source AND dest          */
                SRCINVERT = 0x00660046, /* dest = source XOR dest          */
                SRCERASE = 0x00440328, /* dest = source AND (NOT dest )   */
                NOTSRCCOPY = 0x00330008, /* dest = (NOT source)             */
                NOTSRCERASE = 0x001100A6, /* dest = (NOT src) AND (NOT dest) */
                MERGECOPY = 0x00C000CA, /* dest = (source AND pattern)     */
                MERGEPAINT = 0x00BB0226, /* dest = (NOT source) OR dest     */
                PATCOPY = 0x00F00021, /* dest = pattern                  */
                PATPAINT = 0x00FB0A09, /* dest = DPSnoo                   */
                PATINVERT = 0x005A0049, /* dest = pattern XOR dest         */
                DSTINVERT = 0x00550009, /* dest = (NOT dest)               */
                BLACKNESS = 0x00000042, /* dest = BLACK                    */
                WHITENESS = 0x00FF0062 /* dest = WHITE                    */

            }

            [DllImport("gdi32.dll")]
            public static extern bool BitBlt(IntPtr hdcDst, int xDst, int yDst, int cx, int cy, IntPtr hdcSrc, int xSrc, int ySrc, uint ulRop);

            [DllImport("gdi32.dll")]
            public static extern bool StretchBlt(IntPtr hdcDst, int xDst, int yDst, int cx, int cy, IntPtr hdcSrc, int xSrc, int ySrc, int cxSrc, int cySrc, uint ulRop);

            [DllImport("gdi32.dll")]
            public static extern IntPtr CreateDC(IntPtr lpszDriver, string lpszDevice, IntPtr lpszOutput, IntPtr lpInitData);

            [DllImport("gdi32.dll")]
            public static extern IntPtr DeleteDC(IntPtr hdc);

            #endregion

            #region Shlwapi.dll

            [DllImport("Shlwapi.dll")]
            public static extern string PathGetArgs(string path);

            public static string SafePathGetArgs(string path)
            {
                try
                {
                    return Win32.PathGetArgs(path);
                }
                catch (System.Exception) { }
                return string.Empty;
            }

            [DllImport("Shlwapi.dll")]
            public static extern int PathCompactPathEx(
                System.Text.StringBuilder pszOut, /* Address of the string that has been altered */
                System.Text.StringBuilder pszSrc, /* Pointer to a null-terminated string of max length (MAX_PATH) that contains the path to be altered */
                uint cchMax,					  /* Maximum number of chars to be contained in the new string, including the null character. Example: cchMax = 8, then 7 chars will be returned, the last for the null character. */
                uint dwFlags);					  /* Reserved */

            public static string PathCompactPathEx(string source, uint maxChars)
            {
                StringBuilder pszOut = new StringBuilder((int)Win32.MAX_PATH);
                StringBuilder pszSrc = new StringBuilder(source);

                int result = Win32.PathCompactPathEx(pszOut, pszSrc, maxChars, (uint)0);
                if (result == 1)
                    return pszOut.ToString();
                else
                {
                    System.Diagnostics.Debug.WriteLine("Win32.PathCompactPathEx failed to compact the path '" + source + "' down to '" + maxChars + "' characters.");
                    return string.Empty;
                }
            }

            #endregion

            #region Hotkeys

            [Flags()]
            public enum HotkeyModifiers
            {
                MOD_ALT = 0x0001,
                MOD_CONTROL = 0x0002,
                MOD_SHIFT = 0x0004,
                MOD_WIN = 0x0008
            }

            [DllImport("User32")]
            public static extern int RegisterHotKey(IntPtr hWnd, int id, uint modifiers, uint virtualkeyCode);

            [DllImport("User32")]
            public static extern int UnregisterHotKey(IntPtr hWnd, int id);

            [DllImport("Kernel32")]
            public static extern short GlobalAddAtom(string atomName);

            [DllImport("Kernel32")]
            public static extern short GlobalDeleteAtom(short atom);

            #endregion

            [DllImport("User32")]
            public static extern int LockWindowUpdate(IntPtr windowHandle);

            public static short MAKEWORD(byte a, byte b)
            {
                return ((short)(((byte)(a & 0xff)) | ((short)((byte)(b & 0xff))) << 8));
            }

            public static byte LOBYTE(short a)
            {
                return ((byte)(a & 0xff));
            }

            public static byte HIBYTE(short a)
            {
                return ((byte)(a >> 8));
            }

            public static int MAKELONG(short a, short b)
            {
                return (((int)(a & 0xffff)) | (((int)(b & 0xffff)) << 16));
            }

            public static short HIWORD(int a)
            {
                return ((short)(a >> 16));
            }

            public static short LOWORD(int a)
            {
                return ((short)(a & 0xffff));
            }

            [DllImport("Kernel32")]
            public static extern int CopyFile(string source, string destination, int failIfExists);
        }
    
}

⌨️ 快捷键说明

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