![]() |
Sylloge
A C# helper library
|
00001 using System; 00002 using System.Collections.Generic; 00003 using System.Linq; 00004 using System.Text; 00005 00006 namespace Sylloge 00007 { 00008 public static partial class WinAPI 00009 { 00010 #region Constants and Globals 00011 00015 public static class Constants 00016 { 00017 public const int DIGCF_DEFAULT = 0x00000001; 00018 public const int DIGCF_PRESENT = 0x00000002; 00019 public const int DIGCF_ALLCLASSES = 0x00000004; 00020 public const int DIGCF_PROFILE = 0x00000008; 00021 public const int DIGCF_DEVICEINTERFACE = 0x00000010; 00022 public const int DIGCF_INTERFACEDEVICE = DIGCF_DEVICEINTERFACE; 00023 public static readonly IntPtr INVALID_HANDLE_VALUE = new IntPtr(-1); 00024 public const int SPDRP_DEVICEDESC = 0x00000000; 00025 public const int SPDRP_HARDWAREID = 0x00000001; 00026 public const int SPDRP_COMPATIBLEIDS = 0x00000002; 00027 public const int SPDRP_UNUSED0 = 0x00000003; 00028 public const int SPDRP_SERVICE = 0x00000004; 00029 public const int SPDRP_UNUSED1 = 0x00000005; 00030 public const int SPDRP_UNUSED2 = 0x00000006; 00031 public const int SPDRP_CLASS = 0x00000007; 00032 public const int SPDRP_CLASSGUID = 0x00000008; 00033 public const int SPDRP_DRIVER = 0x00000009; 00034 public const int SPDRP_CONFIGFLAGS = 0x0000000A; 00035 public const int SPDRP_MFG = 0x0000000B; 00036 public const int SPDRP_FRIENDLYNAME = 0x0000000C; 00037 public const int SPDRP_LOCATION_INFORMATION = 0x0000000D; 00038 public const int SPDRP_PHYSICAL_DEVICE_OBJECT_NAME = 0x0000000E; 00039 public const int SPDRP_CAPABILITIES = 0x0000000F; 00040 public const int SPDRP_UI_NUMBER = 0x00000010; 00041 public const int SPDRP_UPPERFILTERS = 0x00000011; 00042 public const int SPDRP_LOWERFILTERS = 0x00000012; 00043 public const int SPDRP_BUSTYPEGUID = 0x00000013; 00044 public const int SPDRP_LEGACYBUSTYPE = 0x00000014; 00045 public const int SPDRP_BUSNUMBER = 0x00000015; 00046 public const int SPDRP_ENUMERATOR_NAME = 0x00000016; 00047 public const int SPDRP_SECURITY = 0x00000017; 00048 public const int SPDRP_SECURITY_SDS = 0x00000018; 00049 public const int SPDRP_DEVTYPE = 0x00000019; 00050 public const int SPDRP_EXCLUSIVE = 0x0000001A; 00051 public const int SPDRP_CHARACTERISTICS = 0x0000001B; 00052 public const int SPDRP_ADDRESS = 0x0000001C; 00053 public const int SPDRP_UI_NUMBER_DESC_FORMAT = 0x0000001D; 00054 public const int SPDRP_DEVICE_POWER_DATA = 0x0000001E; 00055 public const int SPDRP_REMOVAL_POLICY = 0x0000001F; 00056 public const int SPDRP_REMOVAL_POLICY_HW_DEFAULT = 0x00000020; 00057 public const int SPDRP_REMOVAL_POLICY_OVERRIDE = 0x00000021; 00058 public const int SPDRP_INSTALL_STATE = 0x00000022; 00059 public const int SPDRP_LOCATION_PATHS = 0x00000023; 00060 public const int SPDRP_BASE_CONTAINERID = 0x00000024; 00061 public const int SPDRP_MAXIMUM_PROPERTY = 0x00000025; 00062 00063 public const int MAX_DEV_LEN = 1000; 00064 public const int DEVICE_NOTIFY_WINDOW_HANDLE = 0x0; 00065 public const int DEVICE_NOTIFY_SERVICE_HANDLE = 0x1; 00066 public const int DEVICE_NOTIFY_ALL_INTERFACE_CLASSES = 0x4; 00067 public const int DBT_DEVTYP_DEVICEINTERFACE = 0x5; 00068 public const int DBT_DEVNODES_CHANGED = 0x7; 00069 public const int WM_DEVICECHANGE = 0x219; 00070 public const int DIF_PROPERTYCHANGE = 0x12; 00071 public const int DICS_FLAG_GLOBAL = 0x1; 00072 public const int DICS_FLAG_CONFIGSPECIFIC = 0x2; 00073 public const int DICS_ENABLE = 0x1; 00074 public const int DICS_DISABLE = 0x2; 00075 // Keyboard Constants 00076 public const int HC_ACTION = 0; 00077 public const int WH_KEYBOARD_LL = 13; // Global hook 00078 public const int WH_KEYBOARD = 2; // Program hook (only registers key presses within the application) 00079 public const int WM_KEYDOWN = 0x100; 00080 public const int WM_KEYUP = 0x0101; 00081 public const int WM_SYSKEYDOWN = 0x104; 00082 public const int WM_SYSKEYUP = 0x105; 00083 // Mouse constants 00084 public const int WH_MOUSE_LL = 14; // Global mouse 00085 public const int WH_MOUSE = 7; // Program hook (only registers mouse events within the application) 00086 public const int WM_LBUTTONDOWN = 0x0201; 00087 public const int WM_LBUTTONUP = 0x0202; 00088 public const int WM_MOUSEMOVE = 0x0200; 00089 public const int WM_MOUSEWHEEL = 0x020A; 00090 public const int WM_RBUTTONDOWN = 0x0204; 00091 public const int WM_RBUTTONUP = 0x0205; 00092 // Named Pipe Constants 00093 public const uint DUPLEX = 0x00000003; 00094 public const uint FILE_FLAG_OVERLAPPED = 0X40000000; 00095 public const uint BUFFER_SIZE = 4096; 00096 // Window options 00097 private const Int32 MF_BYPOSITION = 0x400; 00098 private const Int32 MF_REMOVE = 0x1000; 00099 // Gdi Options 00100 public const byte AC_SRC_OVER = 0; 00101 public const Int32 ULW_ALPHA = 2; 00102 public const byte AC_SRC_ALPHA = 1; 00103 public const int SRCCOPY = 0xCC0020; //BitBlt dwRop parameter 00104 // RedrawWindow - command options 00105 public const int SWR_INVALIDATE = 0X1; 00106 public const int SWR_INTERNALPAINT = 0X2; 00107 public const int SWR_ERASE = 0X4; 00108 public const int SWR_VALIDATE = 0X8; 00109 public const int SWR_NOINTERNALPAINT = 0X10; 00110 public const int SWR_NOERASE = 0X20; 00111 public const int SWR_NOCHILDREN = 0X40; 00112 public const int SWR_ALLCHILDREN = 0X80; 00113 public const int SWR_UPDATENOW = 0X100; 00114 public const int SWR_ERASENOW = 0X200; 00115 public const int SWR_FRAME = 0X400; 00116 public const int SWR_NOFRAME = 0X800; 00117 // ShowWindow - command options 00118 public const int SW_FORCEMINIMIZE = 11; 00119 public const int SW_HIDE = 0; 00120 public const int SW_MAXIMIZE = 3; 00121 public const int SW_MINIMIZE = 6; 00122 public const int SW_RESTORE = 9; 00123 public const int SW_SHOW = 5; 00124 public const int SW_SHOWDEFAULT = 10; 00125 public const int SW_SHOWMAXIMIZED = 3; 00126 public const int SW_SHOWMINIMIZED = 2; 00127 public const int SW_SHOWMINNOACTIVE = 7; 00128 public const int SW_SHOWNA = 8; 00129 public const int SW_SHOWNOACTIVATE = 4; 00130 public const int SW_SHOWNORMAL = 1; 00131 // SendInput - key types 00132 public const int INPUT_MOUSE = 0; 00133 public const int INPUT_KEYBOARD = 1; 00134 public const int INPUT_HARDWARE = 2; 00135 public const uint KEYEVENTF_EXTENDEDKEY = 0x0001; 00136 public const uint KEYEVENTF_KEYUP = 0x0002; 00137 public const uint KEYEVENTF_UNICODE = 0x0004; 00138 public const uint KEYEVENTF_SCANCODE = 0x0008; 00139 public const uint XBUTTON1 = 0x0001; 00140 public const uint XBUTTON2 = 0x0002; 00141 public const uint MOUSEEVENTF_MOVE = 0x0001; 00142 public const uint MOUSEEVENTF_LEFTDOWN = 0x0002; 00143 public const uint MOUSEEVENTF_LEFTUP = 0x0004; 00144 public const uint MOUSEEVENTF_RIGHTDOWN = 0x0008; 00145 public const uint MOUSEEVENTF_RIGHTUP = 0x0010; 00146 public const uint MOUSEEVENTF_MIDDLEDOWN = 0x0020; 00147 public const uint MOUSEEVENTF_MIDDLEUP = 0x0040; 00148 public const uint MOUSEEVENTF_XDOWN = 0x0080; 00149 public const uint MOUSEEVENTF_XUP = 0x0100; 00150 public const uint MOUSEEVENTF_WHEEL = 0x0800; 00151 public const uint MOUSEEVENTF_VIRTUALDESK = 0x4000; 00152 public const uint MOUSEEVENTF_ABSOLUTE = 0x8000; 00153 // SetWindowPos - Window Selections 00154 public const int GWL_ID = (-12); 00155 public const int GWL_STYLE = (-16); 00156 public const int GWL_EXSTYLE = (-20); 00157 // SetWindowPos - Window Styles 00158 public const UInt32 WS_OVERLAPPED = 0; 00159 public const UInt32 WS_POPUP = 0x80000000; 00160 public const UInt32 WS_CHILD = 0x40000000; 00161 public const UInt32 WS_MINIMIZE = 0x20000000; 00162 public const UInt32 WS_VISIBLE = 0x10000000; 00163 public const UInt32 WS_DISABLED = 0x8000000; 00164 public const UInt32 WS_CLIPSIBLINGS = 0x4000000; 00165 public const UInt32 WS_CLIPCHILDREN = 0x2000000; 00166 public const UInt32 WS_MAXIMIZE = 0x1000000; 00167 public const UInt32 WS_CAPTION = 0xC00000; // WS_BORDER or WS_DLGFRAME 00168 public const UInt32 WS_BORDER = 0x800000; 00169 public const UInt32 WS_DLGFRAME = 0x400000; 00170 public const UInt32 WS_VSCROLL = 0x200000; 00171 public const UInt32 WS_HSCROLL = 0x100000; 00172 public const UInt32 WS_SYSMENU = 0x80000; 00173 public const UInt32 WS_THICKFRAME = 0x40000; 00174 public const UInt32 WS_GROUP = 0x20000; 00175 public const UInt32 WS_TABSTOP = 0x10000; 00176 public const UInt32 WS_MINIMIZEBOX = 0x20000; 00177 public const UInt32 WS_MAXIMIZEBOX = 0x10000; 00178 public const UInt32 WS_TILED = WS_OVERLAPPED; 00179 public const UInt32 WS_ICONIC = WS_MINIMIZE; 00180 public const UInt32 WS_SIZEBOX = WS_THICKFRAME; 00181 // GetWindowLong - Extended Window Styles 00182 public const UInt32 WS_EX_DLGMODALFRAME = 0x0001; 00183 public const UInt32 WS_EX_NOPARENTNOTIFY = 0x0004; 00184 public const UInt32 WS_EX_TOPMOST = 0x0008; 00185 public const UInt32 WS_EX_ACCEPTFILES = 0x0010; 00186 public const UInt32 WS_EX_TRANSPARENT = 0x0020; 00187 public const UInt32 WS_EX_MDICHILD = 0x0040; 00188 public const UInt32 WS_EX_TOOLWINDOW = 0x0080; 00189 public const UInt32 WS_EX_WINDOWEDGE = 0x0100; 00190 public const UInt32 WS_EX_CLIENTEDGE = 0x0200; 00191 public const UInt32 WS_EX_CONTEXTHELP = 0x0400; 00192 public const UInt32 WS_EX_RIGHT = 0x1000; 00193 public const UInt32 WS_EX_LEFT = 0x0000; 00194 public const UInt32 WS_EX_RTLREADING = 0x2000; 00195 public const UInt32 WS_EX_LTRREADING = 0x0000; 00196 public const UInt32 WS_EX_LEFTSCROLLBAR = 0x4000; 00197 public const UInt32 WS_EX_RIGHTSCROLLBAR = 0x0000; 00198 public const UInt32 WS_EX_CONTROLPARENT = 0x10000; 00199 public const UInt32 WS_EX_STATICEDGE = 0x20000; 00200 public const UInt32 WS_EX_APPWINDOW = 0x40000; 00201 public const UInt32 WS_EX_OVERLAPPEDWINDOW = (WS_EX_WINDOWEDGE | WS_EX_CLIENTEDGE); 00202 public const UInt32 WS_EX_PALETTEWINDOW = (WS_EX_WINDOWEDGE | WS_EX_TOOLWINDOW | WS_EX_TOPMOST); 00203 public const UInt32 WS_EX_LAYERED = 0x00080000; 00204 public const UInt32 WS_EX_NOINHERITLAYOUT = 0x00100000; // Disable inheritence of mirroring by children 00205 public const UInt32 WS_EX_LAYOUTRTL = 0x00400000; // Right to left mirroring 00206 public const UInt32 WS_EX_COMPOSITED = 0x02000000; 00207 public const UInt32 WS_EX_NOACTIVATE = 0x08000000; 00208 // SetWindowPos 00209 public static readonly IntPtr HWND_TOPMOST = new IntPtr(-1); 00210 public static readonly IntPtr HWND_NOTOPMOST = new IntPtr(-2); 00211 public static readonly IntPtr HWND_TOP = new IntPtr(0); 00212 public static readonly IntPtr HWND_BOTTOM = new IntPtr(1); 00213 // SetWindowPos - uFlags parameters - from winuser.h 00214 public const UInt32 SWP_NOSIZE = 0x0001; 00215 public const UInt32 SWP_NOMOVE = 0x0002; 00216 public const UInt32 SWP_NOZORDER = 0x0004; 00217 public const UInt32 SWP_NOREDRAW = 0x0008; 00218 public const UInt32 SWP_NOACTIVATE = 0x0010; 00219 public const UInt32 SWP_FRAMECHANGED = 0x0020; /* The frame changed: send WM_NCCALCSIZE */ 00220 public const UInt32 SWP_SHOWWINDOW = 0x0040; 00221 public const UInt32 SWP_HIDEWINDOW = 0x0080; 00222 public const UInt32 SWP_NOCOPYBITS = 0x0100; 00223 public const UInt32 SWP_NOOWNERZORDER = 0x0200; /* Don't do owner Z ordering */ 00224 public const UInt32 SWP_NOSENDCHANGING = 0x0400; /* Don't send WM_WINDOWPOSCHANGING */ 00225 // DeviceIO constants 00226 public const uint ERROR_INSUFFICIENT_BUFFER = 122; 00227 public const uint FILE_BEGIN = 0; 00228 public const uint FILE_CURRENT = 1; 00229 public const uint FILE_END = 2; 00230 public const uint FILE_SHARE_READ = 0x00000001; 00231 public const uint FILE_SHARE_WRITE = 0x00000002; 00232 public const uint FILE_SHARE_DELETE = 0x00000004; 00233 public const uint FILE_FLAG_NO_BUFFERING = 0x20000000; 00234 public const uint FILE_FLAG_WRITE_THROUGH = 0x80000000; 00235 public const uint FILE_ATTRIBUTE_NORMAL = 0x00000080; 00236 public const uint FILE_DEVICE_FILE_SYSTEM = 9; 00237 public const uint FILE_DEVICE_MASS_STORAGE = 0x2D; 00238 public const uint FSCTL_LOCK_VOLUME = 6; 00239 public const uint FSCTL_DISMOUNT_VOLUME = 8; 00240 public const uint GENERIC_READ = 0x80000000; 00241 public const uint GENERIC_WRITE = 0x40000000; 00242 public const int IOCTL_DISK_GET_DRIVE_GEOMETRY = 0x70000; 00243 public const int IOCTL_DISK_DELETE_DRIVE_LAYOUT = 0x7C100; 00244 public const uint IOCTL_STORAGE_MEDIA_REMOVAL = 0x201; 00245 public const uint IOCTL_STORAGE_EJECT_MEDIA = 0x202; 00246 public const uint OPEN_EXISTING = 3; 00247 // Shell32 00248 public const int SHCNE_ASSOCCHANGED = 0x8000000; 00249 public const int SHCNF_IDLIST = 0; 00250 00251 public const int DEVCAP_VERTRES = 10; 00252 public const int DEVCAP_DESKTOPVERTRES = 117; 00253 00254 // Audio 00255 public static readonly IntPtr APPCOMMAND_VOLUME_MUTE = new IntPtr(0x80000); 00256 public static readonly IntPtr APPCOMMAND_VOLUME_UP = new IntPtr(0xA0000); 00257 public static readonly IntPtr APPCOMMAND_VOLUME_DOWN = new IntPtr(0x90000); 00258 public const int WM_APPCOMMAND = 0x319; 00259 } 00260 00261 #endregion 00262 } 00263 }