| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117 |
- /*******************************************************************************
- * Copyright(c) 2012 dongke All rights reserved. / Confidential
- * 类的信息:
- * 1.程序名称:Win32.cs
- * 2.功能描述:系统中Win32的控制类
- * 编辑履历:
- * 作者 日期 版本 修改内容
- * 欧阳涛 2012/06/07 1.00 新建
- *******************************************************************************/
- using System;
- using System.Runtime.InteropServices;
- namespace Dongke.IBOSS.PRD.Basics.Library
- {
- /// <summary>
- /// 系统中Win32的控制类
- /// </summary>
- public static class Win32
- {
- #region User32
- public const int SW_RESTORE = 9;
- public const int SC_CLOSE = 0xF060;
- public const int MF_ENABLED = 0x00000000;
- public const int MF_GRAYED = 0x00000001;
- public const int MF_DISABLED = 0x00000002;
- public const int WM_SYSCOMMAND = 0x112;
- public const int WM_QUERYENDSESSION = 0x11;
- public const int WM_CUSTOM_FW = 0x1024;
- [DllImport("gdi32.dll")]
- private static extern int GetDeviceCaps(IntPtr hdc, int Index);
- [DllImport("user32.dll", CharSet = CharSet.Auto)]
- public static extern IntPtr SendMessage(HandleRef hWnd, int msg, int wParam, int lParam);
- [DllImport("user32.dll", CharSet = CharSet.Auto)]
- public static extern IntPtr SendMessage(IntPtr hWnd, int msg, int wParam, int lParam);
- [DllImport("user32.dll")]
- public static extern bool SetForegroundWindow(IntPtr hWnd);
- [DllImport("user32.dll")]
- public static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow);
- [DllImport("user32.dll")]
- public static extern bool IsIconic(IntPtr hWnd);
- [DllImport("user32.dll")]
- public static extern bool IsWindowEnabled(IntPtr hWnd);
- [DllImport("user32.dll")]
- public static extern bool IsWindowVisible(IntPtr hWnd);
- [DllImport("user32.dll")]
- public static extern bool EnableWindow(IntPtr hwnd, bool bEnable);
- [DllImport("user32.dll")]
- public static extern bool PrintWindow(IntPtr hwnd, IntPtr hdcBlt, uint nFlags);
- [DllImport("user32.dll", EntryPoint = "GetSystemMenu")]
- public static extern IntPtr GetSystemMenu(IntPtr hWnd, int bRevert);
- [DllImport("User32.dll")]
- public static extern bool EnableMenuItem(IntPtr hMenu, int uIDEnableItem, int uEnable);
- #endregion
- #region Shell32
- public const uint SHGFI_ICON = 0x100;
- public const uint SHGFI_LARGEICON = 0x0;
- public const uint SHGFI_SMALLICON = 0x1;
- public struct SHFILEINFO
- {
- public IntPtr hIcon;
- public IntPtr iIcon;
- public uint dwAttributes;
- [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 260)]
- public string szDisplayName;
- [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 80)]
- public string szTypeName;
- };
- [DllImport("shell32.dll")]
- public static extern IntPtr SHGetFileInfo(string pszPath, uint dwFileAttributes,
- ref SHFILEINFO psfi, uint cbSizeFileInfo, uint uFlags);
- #endregion
- #region Kernel32
- public static readonly IntPtr InvalidHandleValue = new IntPtr(-1);
- public const uint FILE_MAP_WRITE = 0x02;
- public const uint FILE_MAP_READ = 0x04;
- public const uint PAGE_READWRITE = 0x04;
- [DllImport("Kernel32")]
- public static extern IntPtr CreateFileMapping(IntPtr hFile,
- IntPtr pAttributes, uint flProtect,
- uint dwMaximumSizeHigh, uint dwMaximumSizeLow, string pName);
- [DllImport("Kernel32")]
- public static extern IntPtr OpenFileMapping(uint dwDesiredAccess,
- bool bInheritHandle, string name);
- [DllImport("Kernel32")]
- public static extern bool CloseHandle(IntPtr handle);
- [DllImport("Kernel32")]
- public static extern IntPtr MapViewOfFile(IntPtr hFileMappingObject,
- uint dwDesiredAccess,
- uint dwFileOffsetHigh, uint dwFileOffsetLow,
- IntPtr dwNumberOfBytesToMap);
- [DllImport("Kernel32")]
- public static extern bool UnmapViewOfFile(IntPtr address);
- [DllImport("Kernel32")]
- public static extern bool DuplicateHandle(IntPtr hSourceProcessHandle,
- IntPtr hSourceHandle,
- IntPtr hTargetProcessHandle, ref IntPtr lpTargetHandle,
- uint dwDesiredAccess, bool bInheritHandle, uint dwOptions);
- public const uint DUPLICATE_CLOSE_SOURCE = 0x00000001;
- public const uint DUPLICATE_SAME_ACCESS = 0x00000002;
- [DllImport("Kernel32")]
- public static extern IntPtr GetCurrentProcess();
- #endregion
- }
- }
|