UnmanagedMethods.cs 83 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235
  1. using System;
  2. using System.ComponentModel;
  3. using System.Diagnostics.CodeAnalysis;
  4. using System.Runtime.CompilerServices;
  5. using System.Runtime.InteropServices;
  6. using System.Runtime.InteropServices.ComTypes;
  7. using System.Text;
  8. // ReSharper disable InconsistentNaming
  9. #pragma warning disable 169, 649
  10. namespace Avalonia.Win32.Interop
  11. {
  12. [SuppressMessage("Microsoft.StyleCop.CSharp.NamingRules", "SA1305:FieldNamesMustNotUseHungarianNotation", Justification = "Using Win32 naming for consistency.")]
  13. [SuppressMessage("Microsoft.StyleCop.CSharp.NamingRules", "SA1307:AccessibleFieldsMustBeginWithUpperCaseLetter", Justification = "Using Win32 naming for consistency.")]
  14. [SuppressMessage("Microsoft.StyleCop.CSharp.NamingRules", "SA1310:FieldNamesMustNotContainUnderscore", Justification = "Using Win32 naming for consistency.")]
  15. [SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1600:Elements must be documented", Justification = "Look in Win32 docs.")]
  16. [SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1602:Enumeration items must be documented", Justification = "Look in Win32 docs.")]
  17. internal unsafe static class UnmanagedMethods
  18. {
  19. public const int CW_USEDEFAULT = unchecked((int)0x80000000);
  20. public delegate void TimerProc(IntPtr hWnd, uint uMsg, IntPtr nIDEvent, uint dwTime);
  21. public delegate void TimeCallback(uint uTimerID, uint uMsg, UIntPtr dwUser, UIntPtr dw1, UIntPtr dw2);
  22. [UnmanagedFunctionPointer(CallingConvention.StdCall)]
  23. public delegate void WaitOrTimerCallback(IntPtr lpParameter, bool timerOrWaitFired);
  24. public delegate IntPtr WndProc(IntPtr hWnd, uint msg, IntPtr wParam, IntPtr lParam);
  25. public static readonly IntPtr DPI_AWARENESS_CONTEXT_UNAWARE = new IntPtr(-1);
  26. public static readonly IntPtr DPI_AWARENESS_CONTEXT_SYSTEM_AWARE = new IntPtr(-2);
  27. public static readonly IntPtr DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE = new IntPtr(-3);
  28. public static readonly IntPtr DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2 = new IntPtr(-4);
  29. public enum Cursor
  30. {
  31. IDC_ARROW = 32512,
  32. IDC_IBEAM = 32513,
  33. IDC_WAIT = 32514,
  34. IDC_CROSS = 32515,
  35. IDC_UPARROW = 32516,
  36. IDC_SIZE = 32640,
  37. IDC_ICON = 32641,
  38. IDC_SIZENWSE = 32642,
  39. IDC_SIZENESW = 32643,
  40. IDC_SIZEWE = 32644,
  41. IDC_SIZENS = 32645,
  42. IDC_SIZEALL = 32646,
  43. IDC_NO = 32648,
  44. IDC_HAND = 32649,
  45. IDC_APPSTARTING = 32650,
  46. IDC_HELP = 32651
  47. }
  48. public enum MouseActivate : int
  49. {
  50. MA_ACTIVATE = 1,
  51. MA_ACTIVATEANDEAT = 2,
  52. MA_NOACTIVATE = 3,
  53. MA_NOACTIVATEANDEAT = 4
  54. }
  55. [Flags]
  56. public enum SetWindowPosFlags : uint
  57. {
  58. SWP_ASYNCWINDOWPOS = 0x4000,
  59. SWP_DEFERERASE = 0x2000,
  60. SWP_DRAWFRAME = 0x0020,
  61. SWP_FRAMECHANGED = 0x0020,
  62. SWP_HIDEWINDOW = 0x0080,
  63. SWP_NOACTIVATE = 0x0010,
  64. SWP_NOCOPYBITS = 0x0100,
  65. SWP_NOMOVE = 0x0002,
  66. SWP_NOOWNERZORDER = 0x0200,
  67. SWP_NOREDRAW = 0x0008,
  68. SWP_NOREPOSITION = 0x0200,
  69. SWP_NOSENDCHANGING = 0x0400,
  70. SWP_NOSIZE = 0x0001,
  71. SWP_NOZORDER = 0x0004,
  72. SWP_SHOWWINDOW = 0x0040,
  73. SWP_RESIZE = SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER
  74. }
  75. public static class WindowPosZOrder
  76. {
  77. public static readonly IntPtr HWND_BOTTOM = new IntPtr(1);
  78. public static readonly IntPtr HWND_TOP = new IntPtr(0);
  79. public static readonly IntPtr HWND_TOPMOST = new IntPtr(-1);
  80. public static readonly IntPtr HWND_NOTOPMOST = new IntPtr(-2);
  81. }
  82. public enum SizeCommand
  83. {
  84. Restored,
  85. Minimized,
  86. Maximized,
  87. MaxShow,
  88. MaxHide,
  89. }
  90. public enum ShowWindowCommand
  91. {
  92. Hide = 0,
  93. Normal = 1,
  94. ShowMinimized = 2,
  95. Maximize = 3,
  96. ShowMaximized = 3,
  97. ShowNoActivate = 4,
  98. Show = 5,
  99. Minimize = 6,
  100. ShowMinNoActive = 7,
  101. ShowNA = 8,
  102. Restore = 9,
  103. ShowDefault = 10,
  104. ForceMinimize = 11
  105. }
  106. public enum SystemMetric
  107. {
  108. SM_CXSCREEN = 0, // 0x00
  109. SM_CYSCREEN = 1, // 0x01
  110. SM_CXVSCROLL = 2, // 0x02
  111. SM_CYHSCROLL = 3, // 0x03
  112. SM_CYCAPTION = 4, // 0x04
  113. SM_CXBORDER = 5, // 0x05
  114. SM_CYBORDER = 6, // 0x06
  115. SM_CXDLGFRAME = 7, // 0x07
  116. SM_CXFIXEDFRAME = 7, // 0x07
  117. SM_CYDLGFRAME = 8, // 0x08
  118. SM_CYFIXEDFRAME = 8, // 0x08
  119. SM_CYVTHUMB = 9, // 0x09
  120. SM_CXHTHUMB = 10, // 0x0A
  121. SM_CXICON = 11, // 0x0B
  122. SM_CYICON = 12, // 0x0C
  123. SM_CXCURSOR = 13, // 0x0D
  124. SM_CYCURSOR = 14, // 0x0E
  125. SM_CYMENU = 15, // 0x0F
  126. SM_CXFULLSCREEN = 16, // 0x10
  127. SM_CYFULLSCREEN = 17, // 0x11
  128. SM_CYKANJIWINDOW = 18, // 0x12
  129. SM_MOUSEPRESENT = 19, // 0x13
  130. SM_CYVSCROLL = 20, // 0x14
  131. SM_CXHSCROLL = 21, // 0x15
  132. SM_DEBUG = 22, // 0x16
  133. SM_SWAPBUTTON = 23, // 0x17
  134. SM_CXMIN = 28, // 0x1C
  135. SM_CYMIN = 29, // 0x1D
  136. SM_CXSIZE = 30, // 0x1E
  137. SM_CYSIZE = 31, // 0x1F
  138. SM_CXSIZEFRAME = 32, // 0x20
  139. SM_CXFRAME = 32, // 0x20
  140. SM_CYSIZEFRAME = 33, // 0x21
  141. SM_CYFRAME = 33, // 0x21
  142. SM_CXMINTRACK = 34, // 0x22
  143. SM_CYMINTRACK = 35, // 0x23
  144. SM_CXDOUBLECLK = 36, // 0x24
  145. SM_CYDOUBLECLK = 37, // 0x25
  146. SM_CXICONSPACING = 38, // 0x26
  147. SM_CYICONSPACING = 39, // 0x27
  148. SM_MENUDROPALIGNMENT = 40, // 0x28
  149. SM_PENWINDOWS = 41, // 0x29
  150. SM_DBCSENABLED = 42, // 0x2A
  151. SM_CMOUSEBUTTONS = 43, // 0x2B
  152. SM_SECURE = 44, // 0x2C
  153. SM_CXEDGE = 45, // 0x2D
  154. SM_CYEDGE = 46, // 0x2E
  155. SM_CXMINSPACING = 47, // 0x2F
  156. SM_CYMINSPACING = 48, // 0x30
  157. SM_CXSMICON = 49, // 0x31
  158. SM_CYSMICON = 50, // 0x32
  159. SM_CYSMCAPTION = 51, // 0x33
  160. SM_CXSMSIZE = 52, // 0x34
  161. SM_CYSMSIZE = 53, // 0x35
  162. SM_CXMENUSIZE = 54, // 0x36
  163. SM_CYMENUSIZE = 55, // 0x37
  164. SM_ARRANGE = 56, // 0x38
  165. SM_CXMINIMIZED = 57, // 0x39
  166. SM_CYMINIMIZED = 58, // 0x3A
  167. SM_CXMAXTRACK = 59, // 0x3B
  168. SM_CYMAXTRACK = 60, // 0x3C
  169. SM_CXMAXIMIZED = 61, // 0x3D
  170. SM_CYMAXIMIZED = 62, // 0x3E
  171. SM_NETWORK = 63, // 0x3F
  172. SM_CLEANBOOT = 67, // 0x43
  173. SM_CXDRAG = 68, // 0x44
  174. SM_CYDRAG = 69, // 0x45
  175. SM_SHOWSOUNDS = 70, // 0x46
  176. SM_CXMENUCHECK = 71, // 0x47
  177. SM_CYMENUCHECK = 72, // 0x48
  178. SM_SLOWMACHINE = 73, // 0x49
  179. SM_MIDEASTENABLED = 74, // 0x4A
  180. SM_MOUSEWHEELPRESENT = 75, // 0x4B
  181. SM_XVIRTUALSCREEN = 76, // 0x4C
  182. SM_YVIRTUALSCREEN = 77, // 0x4D
  183. SM_CXVIRTUALSCREEN = 78, // 0x4E
  184. SM_CYVIRTUALSCREEN = 79, // 0x4F
  185. SM_CMONITORS = 80, // 0x50
  186. SM_SAMEDISPLAYFORMAT = 81, // 0x51
  187. SM_IMMENABLED = 82, // 0x52
  188. SM_CXFOCUSBORDER = 83, // 0x53
  189. SM_CYFOCUSBORDER = 84, // 0x54
  190. SM_TABLETPC = 86, // 0x56
  191. SM_MEDIACENTER = 87, // 0x57
  192. SM_STARTER = 88, // 0x58
  193. SM_SERVERR2 = 89, // 0x59
  194. SM_MOUSEHORIZONTALWHEELPRESENT = 91, // 0x5B
  195. SM_CXPADDEDBORDER = 92, // 0x5C
  196. SM_DIGITIZER = 94, // 0x5E
  197. SM_MAXIMUMTOUCHES = 95, // 0x5F
  198. SM_REMOTESESSION = 0x1000, // 0x1000
  199. SM_SHUTTINGDOWN = 0x2000, // 0x2000
  200. SM_REMOTECONTROL = 0x2001, // 0x2001
  201. SM_CONVERTABLESLATEMODE = 0x2003,
  202. SM_SYSTEMDOCKED = 0x2004,
  203. }
  204. [Flags]
  205. public enum ModifierKeys
  206. {
  207. MK_CONTROL = 0x0008,
  208. MK_LBUTTON = 0x0001,
  209. MK_MBUTTON = 0x0010,
  210. MK_RBUTTON = 0x0002,
  211. MK_SHIFT = 0x0004,
  212. MK_ALT = 0x0020,
  213. MK_XBUTTON1 = 0x0020,
  214. MK_XBUTTON2 = 0x0040
  215. }
  216. public enum VirtualKeyStates : int
  217. {
  218. VK_LBUTTON = 0x01,
  219. VK_RBUTTON = 0x02,
  220. VK_CANCEL = 0x03,
  221. VK_MBUTTON = 0x04,
  222. VK_XBUTTON1 = 0x05,
  223. VK_XBUTTON2 = 0x06,
  224. VK_BACK = 0x08,
  225. VK_TAB = 0x09,
  226. VK_CLEAR = 0x0C,
  227. VK_RETURN = 0x0D,
  228. VK_SHIFT = 0x10,
  229. VK_CONTROL = 0x11,
  230. VK_MENU = 0x12,
  231. VK_PAUSE = 0x13,
  232. VK_CAPITAL = 0x14,
  233. VK_KANA = 0x15,
  234. VK_HANGEUL = 0x15,
  235. VK_HANGUL = 0x15,
  236. VK_JUNJA = 0x17,
  237. VK_FINAL = 0x18,
  238. VK_HANJA = 0x19,
  239. VK_KANJI = 0x19,
  240. VK_ESCAPE = 0x1B,
  241. VK_CONVERT = 0x1C,
  242. VK_NONCONVERT = 0x1D,
  243. VK_ACCEPT = 0x1E,
  244. VK_MODECHANGE = 0x1F,
  245. VK_SPACE = 0x20,
  246. VK_PRIOR = 0x21,
  247. VK_NEXT = 0x22,
  248. VK_END = 0x23,
  249. VK_HOME = 0x24,
  250. VK_LEFT = 0x25,
  251. VK_UP = 0x26,
  252. VK_RIGHT = 0x27,
  253. VK_DOWN = 0x28,
  254. VK_SELECT = 0x29,
  255. VK_PRINT = 0x2A,
  256. VK_EXECUTE = 0x2B,
  257. VK_SNAPSHOT = 0x2C,
  258. VK_INSERT = 0x2D,
  259. VK_DELETE = 0x2E,
  260. VK_HELP = 0x2F,
  261. VK_LWIN = 0x5B,
  262. VK_RWIN = 0x5C,
  263. VK_APPS = 0x5D,
  264. VK_SLEEP = 0x5F,
  265. VK_NUMPAD0 = 0x60,
  266. VK_NUMPAD1 = 0x61,
  267. VK_NUMPAD2 = 0x62,
  268. VK_NUMPAD3 = 0x63,
  269. VK_NUMPAD4 = 0x64,
  270. VK_NUMPAD5 = 0x65,
  271. VK_NUMPAD6 = 0x66,
  272. VK_NUMPAD7 = 0x67,
  273. VK_NUMPAD8 = 0x68,
  274. VK_NUMPAD9 = 0x69,
  275. VK_MULTIPLY = 0x6A,
  276. VK_ADD = 0x6B,
  277. VK_SEPARATOR = 0x6C,
  278. VK_SUBTRACT = 0x6D,
  279. VK_DECIMAL = 0x6E,
  280. VK_DIVIDE = 0x6F,
  281. VK_F1 = 0x70,
  282. VK_F2 = 0x71,
  283. VK_F3 = 0x72,
  284. VK_F4 = 0x73,
  285. VK_F5 = 0x74,
  286. VK_F6 = 0x75,
  287. VK_F7 = 0x76,
  288. VK_F8 = 0x77,
  289. VK_F9 = 0x78,
  290. VK_F10 = 0x79,
  291. VK_F11 = 0x7A,
  292. VK_F12 = 0x7B,
  293. VK_F13 = 0x7C,
  294. VK_F14 = 0x7D,
  295. VK_F15 = 0x7E,
  296. VK_F16 = 0x7F,
  297. VK_F17 = 0x80,
  298. VK_F18 = 0x81,
  299. VK_F19 = 0x82,
  300. VK_F20 = 0x83,
  301. VK_F21 = 0x84,
  302. VK_F22 = 0x85,
  303. VK_F23 = 0x86,
  304. VK_F24 = 0x87,
  305. VK_NUMLOCK = 0x90,
  306. VK_SCROLL = 0x91,
  307. VK_OEM_NEC_EQUAL = 0x92,
  308. VK_OEM_FJ_JISHO = 0x92,
  309. VK_OEM_FJ_MASSHOU = 0x93,
  310. VK_OEM_FJ_TOUROKU = 0x94,
  311. VK_OEM_FJ_LOYA = 0x95,
  312. VK_OEM_FJ_ROYA = 0x96,
  313. VK_LSHIFT = 0xA0,
  314. VK_RSHIFT = 0xA1,
  315. VK_LCONTROL = 0xA2,
  316. VK_RCONTROL = 0xA3,
  317. VK_LMENU = 0xA4,
  318. VK_RMENU = 0xA5,
  319. VK_BROWSER_BACK = 0xA6,
  320. VK_BROWSER_FORWARD = 0xA7,
  321. VK_BROWSER_REFRESH = 0xA8,
  322. VK_BROWSER_STOP = 0xA9,
  323. VK_BROWSER_SEARCH = 0xAA,
  324. VK_BROWSER_FAVORITES = 0xAB,
  325. VK_BROWSER_HOME = 0xAC,
  326. VK_VOLUME_MUTE = 0xAD,
  327. VK_VOLUME_DOWN = 0xAE,
  328. VK_VOLUME_UP = 0xAF,
  329. VK_MEDIA_NEXT_TRACK = 0xB0,
  330. VK_MEDIA_PREV_TRACK = 0xB1,
  331. VK_MEDIA_STOP = 0xB2,
  332. VK_MEDIA_PLAY_PAUSE = 0xB3,
  333. VK_LAUNCH_MAIL = 0xB4,
  334. VK_LAUNCH_MEDIA_SELECT = 0xB5,
  335. VK_LAUNCH_APP1 = 0xB6,
  336. VK_LAUNCH_APP2 = 0xB7,
  337. VK_OEM_1 = 0xBA,
  338. VK_OEM_PLUS = 0xBB,
  339. VK_OEM_COMMA = 0xBC,
  340. VK_OEM_MINUS = 0xBD,
  341. VK_OEM_PERIOD = 0xBE,
  342. VK_OEM_2 = 0xBF,
  343. VK_OEM_3 = 0xC0,
  344. VK_OEM_4 = 0xDB,
  345. VK_OEM_5 = 0xDC,
  346. VK_OEM_6 = 0xDD,
  347. VK_OEM_7 = 0xDE,
  348. VK_OEM_8 = 0xDF,
  349. VK_OEM_AX = 0xE1,
  350. VK_OEM_102 = 0xE2,
  351. VK_ICO_HELP = 0xE3,
  352. VK_ICO_00 = 0xE4,
  353. VK_PROCESSKEY = 0xE5,
  354. VK_ICO_CLEAR = 0xE6,
  355. VK_PACKET = 0xE7,
  356. VK_OEM_RESET = 0xE9,
  357. VK_OEM_JUMP = 0xEA,
  358. VK_OEM_PA1 = 0xEB,
  359. VK_OEM_PA2 = 0xEC,
  360. VK_OEM_PA3 = 0xED,
  361. VK_OEM_WSCTRL = 0xEE,
  362. VK_OEM_CUSEL = 0xEF,
  363. VK_OEM_ATTN = 0xF0,
  364. VK_OEM_FINISH = 0xF1,
  365. VK_OEM_COPY = 0xF2,
  366. VK_OEM_AUTO = 0xF3,
  367. VK_OEM_ENLW = 0xF4,
  368. VK_OEM_BACKTAB = 0xF5,
  369. VK_ATTN = 0xF6,
  370. VK_CRSEL = 0xF7,
  371. VK_EXSEL = 0xF8,
  372. VK_EREOF = 0xF9,
  373. VK_PLAY = 0xFA,
  374. VK_ZOOM = 0xFB,
  375. VK_NONAME = 0xFC,
  376. VK_PA1 = 0xFD,
  377. VK_OEM_CLEAR = 0xFE
  378. }
  379. public enum WindowActivate
  380. {
  381. WA_INACTIVE,
  382. WA_ACTIVE,
  383. WA_CLICKACTIVE,
  384. }
  385. public enum HitTestValues
  386. {
  387. HTERROR = -2,
  388. HTTRANSPARENT = -1,
  389. HTNOWHERE = 0,
  390. HTCLIENT = 1,
  391. HTCAPTION = 2,
  392. HTSYSMENU = 3,
  393. HTGROWBOX = 4,
  394. HTMENU = 5,
  395. HTHSCROLL = 6,
  396. HTVSCROLL = 7,
  397. HTMINBUTTON = 8,
  398. HTMAXBUTTON = 9,
  399. HTLEFT = 10,
  400. HTRIGHT = 11,
  401. HTTOP = 12,
  402. HTTOPLEFT = 13,
  403. HTTOPRIGHT = 14,
  404. HTBOTTOM = 15,
  405. HTBOTTOMLEFT = 16,
  406. HTBOTTOMRIGHT = 17,
  407. HTBORDER = 18,
  408. HTOBJECT = 19,
  409. HTCLOSE = 20,
  410. HTHELP = 21
  411. }
  412. [Flags]
  413. public enum WindowStyles : uint
  414. {
  415. WS_BORDER = 0x800000,
  416. WS_CAPTION = 0xc00000,
  417. WS_CHILD = 0x40000000,
  418. WS_CLIPCHILDREN = 0x2000000,
  419. WS_CLIPSIBLINGS = 0x4000000,
  420. WS_DISABLED = 0x8000000,
  421. WS_DLGFRAME = 0x400000,
  422. WS_GROUP = 0x20000,
  423. WS_HSCROLL = 0x100000,
  424. WS_MAXIMIZE = 0x1000000,
  425. WS_MAXIMIZEBOX = 0x10000,
  426. WS_MINIMIZE = 0x20000000,
  427. WS_MINIMIZEBOX = 0x20000,
  428. WS_OVERLAPPED = 0x0,
  429. WS_OVERLAPPEDWINDOW = WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_SIZEFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX,
  430. WS_POPUP = 0x80000000u,
  431. WS_POPUPWINDOW = WS_POPUP | WS_BORDER | WS_SYSMENU,
  432. WS_SIZEFRAME = 0x40000,
  433. WS_SYSMENU = 0x80000,
  434. WS_TABSTOP = 0x10000,
  435. WS_THICKFRAME = 0x40000,
  436. WS_VISIBLE = 0x10000000,
  437. WS_VSCROLL = 0x200000,
  438. WS_EX_DLGMODALFRAME = 0x00000001,
  439. WS_EX_NOPARENTNOTIFY = 0x00000004,
  440. WS_EX_NOREDIRECTIONBITMAP = 0x00200000,
  441. WS_EX_TOPMOST = 0x00000008,
  442. WS_EX_ACCEPTFILES = 0x00000010,
  443. WS_EX_TRANSPARENT = 0x00000020,
  444. WS_EX_MDICHILD = 0x00000040,
  445. WS_EX_TOOLWINDOW = 0x00000080,
  446. WS_EX_WINDOWEDGE = 0x00000100,
  447. WS_EX_CLIENTEDGE = 0x00000200,
  448. WS_EX_CONTEXTHELP = 0x00000400,
  449. WS_EX_RIGHT = 0x00001000,
  450. WS_EX_LEFT = 0x00000000,
  451. WS_EX_RTLREADING = 0x00002000,
  452. WS_EX_LTRREADING = 0x00000000,
  453. WS_EX_LEFTSCROLLBAR = 0x00004000,
  454. WS_EX_RIGHTSCROLLBAR = 0x00000000,
  455. WS_EX_CONTROLPARENT = 0x00010000,
  456. WS_EX_STATICEDGE = 0x00020000,
  457. WS_EX_APPWINDOW = 0x00040000,
  458. WS_EX_OVERLAPPEDWINDOW = WS_EX_WINDOWEDGE | WS_EX_CLIENTEDGE,
  459. WS_EX_PALETTEWINDOW = WS_EX_WINDOWEDGE | WS_EX_TOOLWINDOW | WS_EX_TOPMOST,
  460. WS_EX_LAYERED = 0x00080000,
  461. WS_EX_NOINHERITLAYOUT = 0x00100000,
  462. WS_EX_LAYOUTRTL = 0x00400000,
  463. WS_EX_COMPOSITED = 0x02000000,
  464. WS_EX_NOACTIVATE = 0x08000000
  465. }
  466. [Flags]
  467. public enum ClassStyles : uint
  468. {
  469. CS_VREDRAW = 0x0001,
  470. CS_HREDRAW = 0x0002,
  471. CS_DBLCLKS = 0x0008,
  472. CS_OWNDC = 0x0020,
  473. CS_CLASSDC = 0x0040,
  474. CS_PARENTDC = 0x0080,
  475. CS_NOCLOSE = 0x0200,
  476. CS_SAVEBITS = 0x0800,
  477. CS_BYTEALIGNCLIENT = 0x1000,
  478. CS_BYTEALIGNWINDOW = 0x2000,
  479. CS_GLOBALCLASS = 0x4000,
  480. CS_IME = 0x00010000,
  481. CS_DROPSHADOW = 0x00020000
  482. }
  483. public enum WindowsMessage : uint
  484. {
  485. WM_NULL = 0x0000,
  486. WM_CREATE = 0x0001,
  487. WM_DESTROY = 0x0002,
  488. WM_MOVE = 0x0003,
  489. WM_SIZE = 0x0005,
  490. WM_ACTIVATE = 0x0006,
  491. WM_SETFOCUS = 0x0007,
  492. WM_KILLFOCUS = 0x0008,
  493. WM_ENABLE = 0x000A,
  494. WM_SETREDRAW = 0x000B,
  495. WM_SETTEXT = 0x000C,
  496. WM_GETTEXT = 0x000D,
  497. WM_GETTEXTLENGTH = 0x000E,
  498. WM_PAINT = 0x000F,
  499. WM_CLOSE = 0x0010,
  500. WM_QUERYENDSESSION = 0x0011,
  501. WM_QUERYOPEN = 0x0013,
  502. WM_ENDSESSION = 0x0016,
  503. WM_QUIT = 0x0012,
  504. WM_ERASEBKGND = 0x0014,
  505. WM_SYSCOLORCHANGE = 0x0015,
  506. WM_SHOWWINDOW = 0x0018,
  507. WM_WININICHANGE = 0x001A,
  508. WM_SETTINGCHANGE = WM_WININICHANGE,
  509. WM_DEVMODECHANGE = 0x001B,
  510. WM_ACTIVATEAPP = 0x001C,
  511. WM_FONTCHANGE = 0x001D,
  512. WM_TIMECHANGE = 0x001E,
  513. WM_CANCELMODE = 0x001F,
  514. WM_SETCURSOR = 0x0020,
  515. WM_MOUSEACTIVATE = 0x0021,
  516. WM_CHILDACTIVATE = 0x0022,
  517. WM_QUEUESYNC = 0x0023,
  518. WM_GETMINMAXINFO = 0x0024,
  519. WM_PAINTICON = 0x0026,
  520. WM_ICONERASEBKGND = 0x0027,
  521. WM_NEXTDLGCTL = 0x0028,
  522. WM_SPOOLERSTATUS = 0x002A,
  523. WM_DRAWITEM = 0x002B,
  524. WM_MEASUREITEM = 0x002C,
  525. WM_DELETEITEM = 0x002D,
  526. WM_VKEYTOITEM = 0x002E,
  527. WM_CHARTOITEM = 0x002F,
  528. WM_SETFONT = 0x0030,
  529. WM_GETFONT = 0x0031,
  530. WM_SETHOTKEY = 0x0032,
  531. WM_GETHOTKEY = 0x0033,
  532. WM_QUERYDRAGICON = 0x0037,
  533. WM_COMPAREITEM = 0x0039,
  534. WM_GETOBJECT = 0x003D,
  535. WM_COMPACTING = 0x0041,
  536. WM_WINDOWPOSCHANGING = 0x0046,
  537. WM_WINDOWPOSCHANGED = 0x0047,
  538. WM_COPYDATA = 0x004A,
  539. WM_CANCELJOURNAL = 0x004B,
  540. WM_NOTIFY = 0x004E,
  541. WM_INPUTLANGCHANGEREQUEST = 0x0050,
  542. WM_INPUTLANGCHANGE = 0x0051,
  543. WM_TCARD = 0x0052,
  544. WM_HELP = 0x0053,
  545. WM_USERCHANGED = 0x0054,
  546. WM_NOTIFYFORMAT = 0x0055,
  547. WM_CONTEXTMENU = 0x007B,
  548. WM_STYLECHANGING = 0x007C,
  549. WM_STYLECHANGED = 0x007D,
  550. WM_DISPLAYCHANGE = 0x007E,
  551. WM_GETICON = 0x007F,
  552. WM_SETICON = 0x0080,
  553. WM_NCCREATE = 0x0081,
  554. WM_NCDESTROY = 0x0082,
  555. WM_NCCALCSIZE = 0x0083,
  556. WM_NCHITTEST = 0x0084,
  557. WM_NCPAINT = 0x0085,
  558. WM_NCACTIVATE = 0x0086,
  559. WM_GETDLGCODE = 0x0087,
  560. WM_SYNCPAINT = 0x0088,
  561. WM_NCMOUSEMOVE = 0x00A0,
  562. WM_NCLBUTTONDOWN = 0x00A1,
  563. WM_NCLBUTTONUP = 0x00A2,
  564. WM_NCLBUTTONDBLCLK = 0x00A3,
  565. WM_NCRBUTTONDOWN = 0x00A4,
  566. WM_NCRBUTTONUP = 0x00A5,
  567. WM_NCRBUTTONDBLCLK = 0x00A6,
  568. WM_NCMBUTTONDOWN = 0x00A7,
  569. WM_NCMBUTTONUP = 0x00A8,
  570. WM_NCMBUTTONDBLCLK = 0x00A9,
  571. WM_NCXBUTTONDOWN = 0x00AB,
  572. WM_NCXBUTTONUP = 0x00AC,
  573. WM_NCXBUTTONDBLCLK = 0x00AD,
  574. WM_INPUT_DEVICE_CHANGE = 0x00FE,
  575. WM_INPUT = 0x00FF,
  576. WM_KEYFIRST = 0x0100,
  577. WM_KEYDOWN = 0x0100,
  578. WM_KEYUP = 0x0101,
  579. WM_CHAR = 0x0102,
  580. WM_DEADCHAR = 0x0103,
  581. WM_SYSKEYDOWN = 0x0104,
  582. WM_SYSKEYUP = 0x0105,
  583. WM_SYSCHAR = 0x0106,
  584. WM_SYSDEADCHAR = 0x0107,
  585. WM_UNICHAR = 0x0109,
  586. WM_KEYLAST = 0x0109,
  587. WM_IME_STARTCOMPOSITION = 0x010D,
  588. WM_IME_ENDCOMPOSITION = 0x010E,
  589. WM_IME_COMPOSITION = 0x010F,
  590. WM_IME_KEYLAST = 0x010F,
  591. WM_INITDIALOG = 0x0110,
  592. WM_COMMAND = 0x0111,
  593. WM_SYSCOMMAND = 0x0112,
  594. WM_TIMER = 0x0113,
  595. WM_HSCROLL = 0x0114,
  596. WM_VSCROLL = 0x0115,
  597. WM_INITMENU = 0x0116,
  598. WM_INITMENUPOPUP = 0x0117,
  599. WM_MENUSELECT = 0x011F,
  600. WM_MENUCHAR = 0x0120,
  601. WM_ENTERIDLE = 0x0121,
  602. WM_MENURBUTTONUP = 0x0122,
  603. WM_MENUDRAG = 0x0123,
  604. WM_MENUGETOBJECT = 0x0124,
  605. WM_UNINITMENUPOPUP = 0x0125,
  606. WM_MENUCOMMAND = 0x0126,
  607. WM_CHANGEUISTATE = 0x0127,
  608. WM_UPDATEUISTATE = 0x0128,
  609. WM_QUERYUISTATE = 0x0129,
  610. WM_CTLCOLORMSGBOX = 0x0132,
  611. WM_CTLCOLOREDIT = 0x0133,
  612. WM_CTLCOLORLISTBOX = 0x0134,
  613. WM_CTLCOLORBTN = 0x0135,
  614. WM_CTLCOLORDLG = 0x0136,
  615. WM_CTLCOLORSCROLLBAR = 0x0137,
  616. WM_CTLCOLORSTATIC = 0x0138,
  617. WM_MOUSEFIRST = 0x0200,
  618. WM_MOUSEMOVE = 0x0200,
  619. WM_LBUTTONDOWN = 0x0201,
  620. WM_LBUTTONUP = 0x0202,
  621. WM_LBUTTONDBLCLK = 0x0203,
  622. WM_RBUTTONDOWN = 0x0204,
  623. WM_RBUTTONUP = 0x0205,
  624. WM_RBUTTONDBLCLK = 0x0206,
  625. WM_MBUTTONDOWN = 0x0207,
  626. WM_MBUTTONUP = 0x0208,
  627. WM_MBUTTONDBLCLK = 0x0209,
  628. WM_MOUSEWHEEL = 0x020A,
  629. WM_XBUTTONDOWN = 0x020B,
  630. WM_XBUTTONUP = 0x020C,
  631. WM_XBUTTONDBLCLK = 0x020D,
  632. WM_MOUSEHWHEEL = 0x020E,
  633. WM_MOUSELAST = 0x020E,
  634. WM_PARENTNOTIFY = 0x0210,
  635. WM_ENTERMENULOOP = 0x0211,
  636. WM_EXITMENULOOP = 0x0212,
  637. WM_NEXTMENU = 0x0213,
  638. WM_SIZING = 0x0214,
  639. WM_CAPTURECHANGED = 0x0215,
  640. WM_MOVING = 0x0216,
  641. WM_POWERBROADCAST = 0x0218,
  642. WM_DEVICECHANGE = 0x0219,
  643. WM_MDICREATE = 0x0220,
  644. WM_MDIDESTROY = 0x0221,
  645. WM_MDIACTIVATE = 0x0222,
  646. WM_MDIRESTORE = 0x0223,
  647. WM_MDINEXT = 0x0224,
  648. WM_MDIMAXIMIZE = 0x0225,
  649. WM_MDITILE = 0x0226,
  650. WM_MDICASCADE = 0x0227,
  651. WM_MDIICONARRANGE = 0x0228,
  652. WM_MDIGETACTIVE = 0x0229,
  653. WM_MDISETMENU = 0x0230,
  654. WM_ENTERSIZEMOVE = 0x0231,
  655. WM_EXITSIZEMOVE = 0x0232,
  656. WM_DROPFILES = 0x0233,
  657. WM_MDIREFRESHMENU = 0x0234,
  658. WM_IME_SETCONTEXT = 0x0281,
  659. WM_IME_NOTIFY = 0x0282,
  660. WM_IME_CONTROL = 0x0283,
  661. WM_IME_COMPOSITIONFULL = 0x0284,
  662. WM_IME_SELECT = 0x0285,
  663. WM_IME_CHAR = 0x0286,
  664. WM_IME_REQUEST = 0x0288,
  665. WM_IME_KEYDOWN = 0x0290,
  666. WM_IME_KEYUP = 0x0291,
  667. WM_MOUSEHOVER = 0x02A1,
  668. WM_MOUSELEAVE = 0x02A3,
  669. WM_NCMOUSEHOVER = 0x02A0,
  670. WM_NCMOUSELEAVE = 0x02A2,
  671. WM_WTSSESSION_CHANGE = 0x02B1,
  672. WM_TABLET_FIRST = 0x02c0,
  673. WM_TABLET_LAST = 0x02df,
  674. WM_DPICHANGED = 0x02E0,
  675. WM_CUT = 0x0300,
  676. WM_COPY = 0x0301,
  677. WM_PASTE = 0x0302,
  678. WM_CLEAR = 0x0303,
  679. WM_UNDO = 0x0304,
  680. WM_RENDERFORMAT = 0x0305,
  681. WM_RENDERALLFORMATS = 0x0306,
  682. WM_DESTROYCLIPBOARD = 0x0307,
  683. WM_DRAWCLIPBOARD = 0x0308,
  684. WM_PAINTCLIPBOARD = 0x0309,
  685. WM_VSCROLLCLIPBOARD = 0x030A,
  686. WM_SIZECLIPBOARD = 0x030B,
  687. WM_ASKCBFORMATNAME = 0x030C,
  688. WM_CHANGECBCHAIN = 0x030D,
  689. WM_HSCROLLCLIPBOARD = 0x030E,
  690. WM_QUERYNEWPALETTE = 0x030F,
  691. WM_PALETTEISCHANGING = 0x0310,
  692. WM_PALETTECHANGED = 0x0311,
  693. WM_HOTKEY = 0x0312,
  694. WM_PRINT = 0x0317,
  695. WM_PRINTCLIENT = 0x0318,
  696. WM_APPCOMMAND = 0x0319,
  697. WM_THEMECHANGED = 0x031A,
  698. WM_CLIPBOARDUPDATE = 0x031D,
  699. WM_DWMCOMPOSITIONCHANGED = 0x031E,
  700. WM_DWMNCRENDERINGCHANGED = 0x031F,
  701. WM_DWMCOLORIZATIONCOLORCHANGED = 0x0320,
  702. WM_DWMWINDOWMAXIMIZEDCHANGE = 0x0321,
  703. WM_GETTITLEBARINFOEX = 0x033F,
  704. WM_HANDHELDFIRST = 0x0358,
  705. WM_HANDHELDLAST = 0x035F,
  706. WM_AFXFIRST = 0x0360,
  707. WM_AFXLAST = 0x037F,
  708. WM_PENWINFIRST = 0x0380,
  709. WM_PENWINLAST = 0x038F,
  710. WM_TOUCH = 0x0240,
  711. WM_APP = 0x8000,
  712. WM_USER = 0x0400,
  713. WM_DISPATCH_WORK_ITEM = WM_USER,
  714. }
  715. public enum MapVirtualKeyMapTypes : uint
  716. {
  717. MAPVK_VK_TO_VSC = 0x00,
  718. MAPVK_VSC_TO_VK = 0x01,
  719. MAPVK_VK_TO_CHAR = 0x02,
  720. MAPVK_VSC_TO_VK_EX = 0x03,
  721. }
  722. public enum BitmapCompressionMode : uint
  723. {
  724. BI_RGB = 0,
  725. BI_RLE8 = 1,
  726. BI_RLE4 = 2,
  727. BI_BITFIELDS = 3,
  728. BI_JPEG = 4,
  729. BI_PNG = 5
  730. }
  731. public enum DIBColorTable
  732. {
  733. DIB_RGB_COLORS = 0, /* color table in RGBs */
  734. DIB_PAL_COLORS /* color table in palette indices */
  735. }
  736. public enum WindowLongParam
  737. {
  738. GWL_WNDPROC = -4,
  739. GWL_HINSTANCE = -6,
  740. GWL_HWNDPARENT = -8,
  741. GWL_ID = -12,
  742. GWL_STYLE = -16,
  743. GWL_EXSTYLE = -20,
  744. GWL_USERDATA = -21
  745. }
  746. public enum MenuCharParam
  747. {
  748. MNC_IGNORE = 0,
  749. MNC_CLOSE = 1,
  750. MNC_EXECUTE = 2,
  751. MNC_SELECT = 3
  752. }
  753. [StructLayout(LayoutKind.Sequential)]
  754. public struct RGBQUAD
  755. {
  756. public byte rgbBlue;
  757. public byte rgbGreen;
  758. public byte rgbRed;
  759. public byte rgbReserved;
  760. }
  761. [StructLayout(LayoutKind.Sequential)]
  762. public struct BITMAPINFOHEADER
  763. {
  764. public uint biSize;
  765. public int biWidth;
  766. public int biHeight;
  767. public ushort biPlanes;
  768. public ushort biBitCount;
  769. public uint biCompression;
  770. public uint biSizeImage;
  771. public int biXPelsPerMeter;
  772. public int biYPelsPerMeter;
  773. public uint biClrUsed;
  774. public uint biClrImportant;
  775. public void Init()
  776. {
  777. biSize = (uint)Marshal.SizeOf(this);
  778. }
  779. }
  780. [StructLayout(LayoutKind.Sequential)]
  781. public struct BITMAPINFO
  782. {
  783. // C# cannot inlay structs in structs so must expand directly here
  784. //
  785. //[StructLayout(LayoutKind.Sequential)]
  786. //public struct BITMAPINFOHEADER
  787. //{
  788. public uint biSize;
  789. public int biWidth;
  790. public int biHeight;
  791. public ushort biPlanes;
  792. public ushort biBitCount;
  793. public BitmapCompressionMode biCompression;
  794. public uint biSizeImage;
  795. public int biXPelsPerMeter;
  796. public int biYPelsPerMeter;
  797. public uint biClrUsed;
  798. public uint biClrImportant;
  799. //}
  800. [MarshalAs(UnmanagedType.ByValArray, SizeConst = 256)]
  801. public uint[] cols;
  802. }
  803. [StructLayout(LayoutKind.Sequential)]
  804. public struct MINMAXINFO
  805. {
  806. public POINT ptReserved;
  807. public POINT ptMaxSize;
  808. public POINT ptMaxPosition;
  809. public POINT ptMinTrackSize;
  810. public POINT ptMaxTrackSize;
  811. }
  812. public const int SizeOf_BITMAPINFOHEADER = 40;
  813. [DllImport("user32.dll")]
  814. public static extern bool EnumDisplayMonitors(IntPtr hdc, IntPtr lprcClip,
  815. MonitorEnumDelegate lpfnEnum, IntPtr dwData);
  816. public delegate bool MonitorEnumDelegate(IntPtr hMonitor, IntPtr hdcMonitor, ref Rect lprcMonitor, IntPtr dwData);
  817. [DllImport("user32.dll", SetLastError = true)]
  818. public static extern IntPtr GetDC(IntPtr hWnd);
  819. [DllImport("gdi32.dll")]
  820. public static extern int SetDIBitsToDevice(IntPtr hdc, int XDest, int YDest,
  821. uint dwWidth, uint dwHeight,
  822. int XSrc, int YSrc,
  823. uint uStartScan, uint cScanLines,
  824. IntPtr lpvBits, [In] ref BITMAPINFO lpbmi, uint fuColorUse);
  825. [DllImport("user32.dll")]
  826. public static extern bool ReleaseDC(IntPtr hWnd, IntPtr hDC);
  827. [DllImport("user32.dll", SetLastError = true)]
  828. public static extern bool AdjustWindowRectEx(ref RECT lpRect, uint dwStyle, bool bMenu, uint dwExStyle);
  829. [DllImport("user32.dll")]
  830. public static extern IntPtr BeginPaint(IntPtr hwnd, out PAINTSTRUCT lpPaint);
  831. [DllImport("user32.dll")]
  832. public static extern bool ClientToScreen(IntPtr hWnd, ref POINT lpPoint);
  833. [DllImport("user32.dll", SetLastError = true)]
  834. public static extern IntPtr CreateWindowEx(
  835. int dwExStyle,
  836. uint lpClassName,
  837. string lpWindowName,
  838. uint dwStyle,
  839. int x,
  840. int y,
  841. int nWidth,
  842. int nHeight,
  843. IntPtr hWndParent,
  844. IntPtr hMenu,
  845. IntPtr hInstance,
  846. IntPtr lpParam);
  847. [DllImport("user32.dll", EntryPoint = "DefWindowProcW")]
  848. public static extern IntPtr DefWindowProc(IntPtr hWnd, uint msg, IntPtr wParam, IntPtr lParam);
  849. [DllImport("user32.dll", EntryPoint = "DispatchMessageW")]
  850. public static extern IntPtr DispatchMessage(ref MSG lpmsg);
  851. [DllImport("user32.dll", SetLastError = true)]
  852. public static extern bool DestroyWindow(IntPtr hwnd);
  853. [DllImport("user32.dll")]
  854. public static extern bool EnableWindow(IntPtr hWnd, bool bEnable);
  855. [DllImport("user32.dll")]
  856. public static extern bool EndPaint(IntPtr hWnd, ref PAINTSTRUCT lpPaint);
  857. [DllImport("user32.dll")]
  858. public static extern uint GetCaretBlinkTime();
  859. [DllImport("user32.dll")]
  860. public static extern bool GetClientRect(IntPtr hwnd, out RECT lpRect);
  861. [DllImport("user32.dll")]
  862. public static extern bool GetCursorPos(out POINT lpPoint);
  863. [DllImport("user32.dll")]
  864. public static extern uint GetDoubleClickTime();
  865. [DllImport("user32.dll")]
  866. public static extern bool GetKeyboardState(byte[] lpKeyState);
  867. [DllImport("user32.dll", EntryPoint = "MapVirtualKeyW")]
  868. public static extern uint MapVirtualKey(uint uCode, uint uMapType);
  869. [DllImport("user32.dll", EntryPoint = "GetMessageW")]
  870. public static extern sbyte GetMessage(out MSG lpMsg, IntPtr hWnd, uint wMsgFilterMin, uint wMsgFilterMax);
  871. [DllImport("user32.dll")]
  872. public static extern int GetMessageTime();
  873. [DllImport("kernel32.dll")]
  874. public static extern IntPtr GetModuleHandle(string lpModuleName);
  875. [DllImport("user32.dll")]
  876. public static extern int GetSystemMetrics(SystemMetric smIndex);
  877. [DllImport("user32.dll", SetLastError = true)]
  878. public static extern uint GetWindowLongPtr(IntPtr hWnd, int nIndex);
  879. [DllImport("user32.dll", SetLastError = true, EntryPoint = "GetWindowLong")]
  880. public static extern uint GetWindowLong32b(IntPtr hWnd, int nIndex);
  881. public static uint GetWindowLong(IntPtr hWnd, int nIndex)
  882. {
  883. if(IntPtr.Size == 4)
  884. {
  885. return GetWindowLong32b(hWnd, nIndex);
  886. }
  887. else
  888. {
  889. return GetWindowLongPtr(hWnd, nIndex);
  890. }
  891. }
  892. [DllImport("user32.dll", SetLastError = true, EntryPoint = "SetWindowLong")]
  893. private static extern uint SetWindowLong32b(IntPtr hWnd, int nIndex, uint value);
  894. [DllImport("user32.dll", SetLastError = true, EntryPoint = "SetWindowLongPtr")]
  895. private static extern IntPtr SetWindowLong64b(IntPtr hWnd, int nIndex, IntPtr value);
  896. public static uint SetWindowLong(IntPtr hWnd, int nIndex, uint value)
  897. {
  898. if (IntPtr.Size == 4)
  899. {
  900. return SetWindowLong32b(hWnd, nIndex, value);
  901. }
  902. else
  903. {
  904. return (uint)SetWindowLong64b(hWnd, nIndex, new IntPtr((uint)value)).ToInt32();
  905. }
  906. }
  907. public static IntPtr SetWindowLongPtr(IntPtr hWnd, int nIndex, IntPtr handle)
  908. {
  909. if (IntPtr.Size == 4)
  910. {
  911. return new IntPtr(SetWindowLong32b(hWnd, nIndex, (uint)handle.ToInt32()));
  912. }
  913. else
  914. {
  915. return SetWindowLong64b(hWnd, nIndex, handle);
  916. }
  917. }
  918. [DllImport("user32.dll")]
  919. public static extern IntPtr GetSystemMenu(IntPtr hWnd, bool bRevert);
  920. [DllImport("user32.dll")]
  921. public static extern bool EnableMenuItem(IntPtr hMenu, uint uIDEnableItem, uint uEnable);
  922. [DllImport("user32.dll", SetLastError = true)]
  923. public static extern bool GetWindowPlacement(IntPtr hWnd, ref WINDOWPLACEMENT lpwndpl);
  924. [DllImport("user32.dll")]
  925. public static extern bool GetWindowRect(IntPtr hwnd, out RECT lpRect);
  926. [DllImport("user32.dll")]
  927. public static extern bool GetUpdateRect(IntPtr hwnd, out RECT lpRect, bool bErase);
  928. [DllImport("user32.dll")]
  929. public static extern bool InvalidateRect(IntPtr hWnd, ref RECT lpRect, bool bErase);
  930. [DllImport("user32.dll")]
  931. public static extern bool InvalidateRect(IntPtr hWnd, RECT* lpRect, bool bErase);
  932. [DllImport("user32.dll")]
  933. public static extern bool ValidateRect(IntPtr hWnd, IntPtr lpRect);
  934. [DllImport("user32.dll")]
  935. public static extern bool IsWindow(IntPtr hWnd);
  936. [DllImport("user32.dll")]
  937. public static extern bool IsWindowEnabled(IntPtr hWnd);
  938. [DllImport("user32.dll")]
  939. public static extern bool IsWindowUnicode(IntPtr hWnd);
  940. [DllImport("user32.dll")]
  941. public static extern bool IsWindowVisible(IntPtr hWnd);
  942. [DllImport("user32.dll")]
  943. public static extern bool KillTimer(IntPtr hWnd, IntPtr uIDEvent);
  944. [DllImport("user32.dll")]
  945. public static extern IntPtr LoadCursor(IntPtr hInstance, IntPtr lpCursorName);
  946. [DllImport("user32.dll")]
  947. public static extern bool PeekMessage(out MSG lpMsg, IntPtr hWnd, uint wMsgFilterMin, uint wMsgFilterMax, uint wRemoveMsg);
  948. [DllImport("user32")]
  949. public static extern IntPtr GetMessageExtraInfo();
  950. [DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Unicode, EntryPoint = "RegisterClassExW")]
  951. public static extern ushort RegisterClassEx(ref WNDCLASSEX lpwcx);
  952. [DllImport("user32.dll")]
  953. public static extern void RegisterTouchWindow(IntPtr hWnd, int flags);
  954. [DllImport("user32.dll")]
  955. public static extern bool ReleaseCapture();
  956. [DllImport("user32.dll")]
  957. public static extern bool ScreenToClient(IntPtr hWnd, ref POINT lpPoint);
  958. [DllImport("user32.dll", SetLastError = true)]
  959. public static extern IntPtr GetActiveWindow();
  960. [DllImport("user32.dll", SetLastError = true)]
  961. public static extern IntPtr SetActiveWindow(IntPtr hWnd);
  962. [DllImport("user32.dll")]
  963. public static extern IntPtr SetCapture(IntPtr hWnd);
  964. [DllImport("user32.dll")]
  965. public static extern IntPtr SetTimer(IntPtr hWnd, IntPtr nIDEvent, uint uElapse, TimerProc lpTimerFunc);
  966. [DllImport("user32.dll", SetLastError = true)]
  967. public static extern bool MoveWindow(IntPtr hWnd, int X, int Y, int nWidth, int nHeight, bool bRepaint);
  968. [DllImport("user32.dll")]
  969. public static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int x, int y, int cx, int cy, SetWindowPosFlags uFlags);
  970. [DllImport("user32.dll")]
  971. public static extern bool SetFocus(IntPtr hWnd);
  972. [DllImport("user32.dll")]
  973. public static extern IntPtr GetFocus();
  974. [DllImport("user32.dll")]
  975. public static extern bool SetParent(IntPtr hWnd, IntPtr hWndNewParent);
  976. [DllImport("user32.dll")]
  977. public static extern IntPtr GetParent(IntPtr hWnd);
  978. public enum GetAncestorFlags
  979. {
  980. GA_PARENT = 1,
  981. GA_ROOT = 2,
  982. GA_ROOTOWNER = 3
  983. }
  984. [DllImport("user32.dll")]
  985. public static extern IntPtr GetAncestor(IntPtr hwnd, GetAncestorFlags gaFlags);
  986. [DllImport("user32.dll")]
  987. public static extern bool ShowWindow(IntPtr hWnd, ShowWindowCommand nCmdShow);
  988. [DllImport("kernel32.dll", SetLastError = true)]
  989. public static extern IntPtr CreateTimerQueue();
  990. [DllImport("kernel32.dll", SetLastError = true)]
  991. public static extern bool DeleteTimerQueueEx(IntPtr TimerQueue, IntPtr CompletionEvent);
  992. [DllImport("kernel32.dll", SetLastError = true)]
  993. [return: MarshalAs(UnmanagedType.Bool)]
  994. public static extern bool CreateTimerQueueTimer(
  995. out IntPtr phNewTimer,
  996. IntPtr TimerQueue,
  997. WaitOrTimerCallback Callback,
  998. IntPtr Parameter,
  999. uint DueTime,
  1000. uint Period,
  1001. uint Flags);
  1002. [DllImport("kernel32.dll", SetLastError = true)]
  1003. public static extern bool DeleteTimerQueueTimer(IntPtr TimerQueue, IntPtr Timer, IntPtr CompletionEvent);
  1004. [DllImport("user32.dll")]
  1005. public static extern int ToUnicode(
  1006. uint virtualKeyCode,
  1007. uint scanCode,
  1008. byte[] keyboardState,
  1009. [Out, MarshalAs(UnmanagedType.LPWStr, SizeConst = 64)]
  1010. StringBuilder receivingBuffer,
  1011. int bufferSize,
  1012. uint flags);
  1013. [DllImport("user32.dll", SetLastError = true)]
  1014. public static extern bool TrackMouseEvent(ref TRACKMOUSEEVENT lpEventTrack);
  1015. [DllImport("user32.dll")]
  1016. public static extern bool TranslateMessage(ref MSG lpMsg);
  1017. [DllImport("user32.dll")]
  1018. public static extern bool UnregisterClass(string lpClassName, IntPtr hInstance);
  1019. [DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Unicode, EntryPoint = "SetWindowTextW")]
  1020. public static extern bool SetWindowText(IntPtr hwnd, string lpString);
  1021. public enum ClassLongIndex : int
  1022. {
  1023. GCLP_MENUNAME = -8,
  1024. GCLP_HBRBACKGROUND = -10,
  1025. GCLP_HCURSOR = -12,
  1026. GCLP_HICON = -14,
  1027. GCLP_HMODULE = -16,
  1028. GCL_CBWNDEXTRA = -18,
  1029. GCL_CBCLSEXTRA = -20,
  1030. GCLP_WNDPROC = -24,
  1031. GCL_STYLE = -26,
  1032. GCLP_HICONSM = -34,
  1033. GCW_ATOM = -32
  1034. }
  1035. [DllImport("user32.dll", EntryPoint = "SetClassLongPtr")]
  1036. private static extern IntPtr SetClassLong64(IntPtr hWnd, ClassLongIndex nIndex, IntPtr dwNewLong);
  1037. [DllImport("user32.dll", EntryPoint = "SetClassLong")]
  1038. private static extern IntPtr SetClassLong32(IntPtr hWnd, ClassLongIndex nIndex, IntPtr dwNewLong);
  1039. public static IntPtr SetClassLong(IntPtr hWnd, ClassLongIndex nIndex, IntPtr dwNewLong)
  1040. {
  1041. if (IntPtr.Size == 4)
  1042. {
  1043. return SetClassLong32(hWnd, nIndex, dwNewLong);
  1044. }
  1045. return SetClassLong64(hWnd, nIndex, dwNewLong);
  1046. }
  1047. public static IntPtr GetClassLongPtr(IntPtr hWnd, int nIndex)
  1048. {
  1049. if (IntPtr.Size > 4)
  1050. return GetClassLongPtr64(hWnd, nIndex);
  1051. else
  1052. return new IntPtr(GetClassLongPtr32(hWnd, nIndex));
  1053. }
  1054. [DllImport("user32.dll", EntryPoint = "GetClassLong")]
  1055. public static extern uint GetClassLongPtr32(IntPtr hWnd, int nIndex);
  1056. [DllImport("user32.dll", EntryPoint = "GetClassLongPtr")]
  1057. public static extern IntPtr GetClassLongPtr64(IntPtr hWnd, int nIndex);
  1058. [DllImport("user32.dll", EntryPoint = "SetCursor")]
  1059. internal static extern IntPtr SetCursor(IntPtr hCursor);
  1060. [DllImport("ole32.dll", PreserveSig = true)]
  1061. internal static extern int CoCreateInstance(ref Guid clsid,
  1062. IntPtr ignore1, int ignore2, ref Guid iid, [MarshalAs(UnmanagedType.IUnknown), Out] out object pUnkOuter);
  1063. [DllImport("ole32.dll", PreserveSig = true)]
  1064. internal static extern int CoCreateInstance(ref Guid clsid,
  1065. IntPtr ignore1, int ignore2, ref Guid iid, [Out] out IntPtr pUnkOuter);
  1066. [DllImport("shell32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
  1067. internal static extern int SHCreateItemFromParsingName([MarshalAs(UnmanagedType.LPWStr)] string pszPath, IntPtr pbc, ref Guid riid, [MarshalAs(UnmanagedType.Interface)] out IShellItem ppv);
  1068. [DllImport("user32.dll", SetLastError = true)]
  1069. public static extern bool OpenClipboard(IntPtr hWndOwner);
  1070. [DllImport("user32.dll", SetLastError = true)]
  1071. public static extern bool CloseClipboard();
  1072. [DllImport("user32.dll")]
  1073. public static extern bool EmptyClipboard();
  1074. [DllImport("user32.dll")]
  1075. public static extern IntPtr GetClipboardData(ClipboardFormat uFormat);
  1076. [DllImport("user32.dll")]
  1077. public static extern IntPtr SetClipboardData(ClipboardFormat uFormat, IntPtr hMem);
  1078. [DllImport("ole32.dll", PreserveSig = false)]
  1079. public static extern int OleGetClipboard(out IOleDataObject dataObject);
  1080. [DllImport("ole32.dll", PreserveSig = true)]
  1081. public static extern int OleSetClipboard(IOleDataObject dataObject);
  1082. [DllImport("kernel32.dll", ExactSpelling = true)]
  1083. public static extern IntPtr GlobalLock(IntPtr handle);
  1084. [DllImport("kernel32.dll", ExactSpelling = true)]
  1085. public static extern bool GlobalUnlock(IntPtr handle);
  1086. [DllImport("kernel32.dll", ExactSpelling = true)]
  1087. public static extern IntPtr GlobalAlloc(int uFlags, int dwBytes);
  1088. [DllImport("kernel32.dll", ExactSpelling = true)]
  1089. public static extern IntPtr GlobalFree(IntPtr hMem);
  1090. [DllImport("kernel32.dll", SetLastError = true)]
  1091. public static extern IntPtr LoadLibrary(string fileName);
  1092. [DllImport("kernel32.dll", SetLastError = true)]
  1093. public static extern IntPtr LoadLibraryEx(string fileName, IntPtr hFile, int flags);
  1094. [DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Ansi)]
  1095. public static extern IntPtr GetProcAddress(IntPtr hModule, string lpProcName);
  1096. [DllImport("comdlg32.dll", CharSet = CharSet.Unicode, EntryPoint = "GetSaveFileNameW")]
  1097. public static extern bool GetSaveFileName(IntPtr lpofn);
  1098. [DllImport("comdlg32.dll", CharSet = CharSet.Unicode, EntryPoint = "GetOpenFileNameW")]
  1099. public static extern bool GetOpenFileName(IntPtr lpofn);
  1100. [DllImport("comdlg32.dll")]
  1101. public static extern int CommDlgExtendedError();
  1102. public static bool ShCoreAvailable => LoadLibrary("shcore.dll") != IntPtr.Zero;
  1103. [DllImport("shcore.dll")]
  1104. public static extern void SetProcessDpiAwareness(PROCESS_DPI_AWARENESS value);
  1105. [DllImport("user32.dll", SetLastError = true)]
  1106. public static extern bool SetProcessDpiAwarenessContext(IntPtr dpiAWarenessContext);
  1107. [DllImport("shcore.dll")]
  1108. public static extern long GetDpiForMonitor(IntPtr hmonitor, MONITOR_DPI_TYPE dpiType, out uint dpiX, out uint dpiY);
  1109. [DllImport("gdi32.dll")]
  1110. public static extern int GetDeviceCaps(IntPtr hdc, DEVICECAP nIndex);
  1111. [DllImport("shcore.dll")]
  1112. public static extern void GetScaleFactorForMonitor(IntPtr hMon, out uint pScale);
  1113. [DllImport("user32.dll", SetLastError = true)]
  1114. public static extern bool SetProcessDPIAware();
  1115. [DllImport("user32.dll")]
  1116. public static extern IntPtr MonitorFromPoint(POINT pt, MONITOR dwFlags);
  1117. [DllImport("user32.dll")]
  1118. public static extern IntPtr MonitorFromRect(RECT rect, MONITOR dwFlags);
  1119. [DllImport("user32.dll")]
  1120. public static extern IntPtr MonitorFromWindow(IntPtr hwnd, MONITOR dwFlags);
  1121. [DllImport("user32", EntryPoint = "GetMonitorInfoW", ExactSpelling = true, CharSet = CharSet.Unicode)]
  1122. [return: MarshalAs(UnmanagedType.Bool)]
  1123. public static extern bool GetMonitorInfo([In] IntPtr hMonitor, ref MONITORINFO lpmi);
  1124. [DllImport("user32")]
  1125. public static extern unsafe bool GetTouchInputInfo(
  1126. IntPtr hTouchInput,
  1127. uint cInputs,
  1128. TOUCHINPUT* pInputs,
  1129. int cbSize
  1130. );
  1131. [DllImport("user32")]
  1132. public static extern bool CloseTouchInputHandle(IntPtr hTouchInput);
  1133. [return: MarshalAs(UnmanagedType.Bool)]
  1134. [DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Unicode, EntryPoint = "PostMessageW")]
  1135. public static extern bool PostMessage(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam);
  1136. [DllImport("gdi32.dll")]
  1137. public static extern int SetDIBitsToDevice(IntPtr hdc, int XDest, int YDest, uint
  1138. dwWidth, uint dwHeight, int XSrc, int YSrc, uint uStartScan, uint cScanLines,
  1139. IntPtr lpvBits, [In] ref BITMAPINFOHEADER lpbmi, uint fuColorUse);
  1140. [DllImport("kernel32.dll", SetLastError = true)]
  1141. [return: MarshalAs(UnmanagedType.Bool)]
  1142. public static extern bool CloseHandle(IntPtr hObject);
  1143. [DllImport("gdi32.dll", SetLastError = true)]
  1144. public static extern IntPtr CreateDIBSection(IntPtr hDC, ref BITMAPINFOHEADER pBitmapInfo, int un, out IntPtr lplpVoid, IntPtr handle, int dw);
  1145. [DllImport("gdi32.dll")]
  1146. public static extern int DeleteObject(IntPtr hObject);
  1147. [DllImport("gdi32.dll", SetLastError = true)]
  1148. public static extern IntPtr CreateCompatibleDC(IntPtr hdc);
  1149. [DllImport("gdi32.dll")]
  1150. public static extern IntPtr SelectObject(IntPtr hdc, IntPtr hObject);
  1151. [DllImport("gdi32.dll")]
  1152. public static extern int ChoosePixelFormat(IntPtr hdc, ref PixelFormatDescriptor pfd);
  1153. [DllImport("gdi32.dll")]
  1154. public static extern int DescribePixelFormat(IntPtr hdc, ref PixelFormatDescriptor pfd);
  1155. [DllImport("gdi32.dll")]
  1156. public static extern int SetPixelFormat(IntPtr hdc, int iPixelFormat, ref PixelFormatDescriptor pfd);
  1157. [DllImport("gdi32.dll")]
  1158. public static extern int DescribePixelFormat(IntPtr hdc, int iPixelFormat, int bytes, ref PixelFormatDescriptor pfd);
  1159. [DllImport("gdi32.dll")]
  1160. public static extern bool SwapBuffers(IntPtr hdc);
  1161. [DllImport("opengl32.dll")]
  1162. public static extern IntPtr wglCreateContext(IntPtr hdc);
  1163. [DllImport("opengl32.dll")]
  1164. public static extern bool wglDeleteContext(IntPtr context);
  1165. [DllImport("opengl32.dll")]
  1166. public static extern bool wglMakeCurrent(IntPtr hdc, IntPtr context);
  1167. [DllImport("opengl32.dll")]
  1168. public static extern IntPtr wglGetCurrentContext();
  1169. [DllImport("opengl32.dll")]
  1170. public static extern IntPtr wglGetCurrentDC();
  1171. [DllImport("opengl32.dll", CharSet = CharSet.Ansi)]
  1172. public static extern IntPtr wglGetProcAddress(string name);
  1173. [DllImport("kernel32.dll", SetLastError = true)]
  1174. public static extern IntPtr CreateFileMapping(IntPtr hFile,
  1175. IntPtr lpFileMappingAttributes,
  1176. uint flProtect,
  1177. uint dwMaximumSizeHigh,
  1178. uint dwMaximumSizeLow,
  1179. string lpName);
  1180. [DllImport("msvcrt.dll", EntryPoint="memcpy", SetLastError = false, CallingConvention=CallingConvention.Cdecl)]
  1181. public static extern IntPtr CopyMemory(IntPtr dest, IntPtr src, UIntPtr count);
  1182. [DllImport("ole32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
  1183. public static extern HRESULT RegisterDragDrop(IntPtr hwnd, IDropTarget target);
  1184. [DllImport("ole32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
  1185. public static extern HRESULT RevokeDragDrop(IntPtr hwnd);
  1186. [DllImport("ole32.dll", EntryPoint = "OleInitialize")]
  1187. public static extern HRESULT OleInitialize(IntPtr val);
  1188. [DllImport("ole32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
  1189. internal static extern void ReleaseStgMedium(ref STGMEDIUM medium);
  1190. [DllImport("user32.dll", BestFitMapping = false, CharSet = CharSet.Auto, SetLastError = true)]
  1191. public static extern int GetClipboardFormatName(int format, StringBuilder lpString, int cchMax);
  1192. [DllImport("user32.dll", BestFitMapping = false, CharSet = CharSet.Auto, SetLastError = true)]
  1193. public static extern int RegisterClipboardFormat(string format);
  1194. [DllImport("kernel32.dll", CharSet = CharSet.Auto, ExactSpelling = true, SetLastError = true)]
  1195. public static extern IntPtr GlobalSize(IntPtr hGlobal);
  1196. [DllImport("shell32.dll", BestFitMapping = false, CharSet = CharSet.Auto)]
  1197. public static extern int DragQueryFile(IntPtr hDrop, int iFile, StringBuilder lpszFile, int cch);
  1198. [DllImport("ole32.dll", CharSet = CharSet.Auto, ExactSpelling = true, PreserveSig = false)]
  1199. internal static extern void DoDragDrop(IOleDataObject dataObject, IDropSource dropSource, int allowedEffects, out int finalEffect);
  1200. [DllImport("dwmapi.dll")]
  1201. public static extern int DwmExtendFrameIntoClientArea(IntPtr hwnd, ref MARGINS margins);
  1202. [DllImport("dwmapi.dll")]
  1203. public static extern int DwmIsCompositionEnabled(out bool enabled);
  1204. [DllImport("dwmapi.dll")]
  1205. public static extern void DwmFlush();
  1206. [DllImport("dwmapi.dll")]
  1207. public static extern bool DwmDefWindowProc(IntPtr hWnd, uint msg, IntPtr wParam, IntPtr lParam, ref IntPtr plResult);
  1208. [DllImport("dwmapi.dll")]
  1209. public static extern void DwmEnableBlurBehindWindow(IntPtr hwnd, ref DWM_BLURBEHIND blurBehind);
  1210. [Flags]
  1211. public enum DWM_BB
  1212. {
  1213. Enable = 1,
  1214. BlurRegion = 2,
  1215. TransitionMaximized = 4
  1216. }
  1217. [StructLayout(LayoutKind.Sequential)]
  1218. public struct DWM_BLURBEHIND
  1219. {
  1220. public DWM_BB dwFlags;
  1221. public bool fEnable;
  1222. public IntPtr hRgnBlur;
  1223. public bool fTransitionOnMaximized;
  1224. public DWM_BLURBEHIND(bool enabled)
  1225. {
  1226. fEnable = enabled ? true : false;
  1227. hRgnBlur = IntPtr.Zero;
  1228. fTransitionOnMaximized = false;
  1229. dwFlags = DWM_BB.Enable;
  1230. }
  1231. }
  1232. [StructLayout(LayoutKind.Sequential)]
  1233. internal struct RTL_OSVERSIONINFOEX
  1234. {
  1235. internal uint dwOSVersionInfoSize;
  1236. internal uint dwMajorVersion;
  1237. internal uint dwMinorVersion;
  1238. internal uint dwBuildNumber;
  1239. internal uint dwPlatformId;
  1240. [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)]
  1241. internal string szCSDVersion;
  1242. }
  1243. [DllImport("ntdll")]
  1244. private static extern int RtlGetVersion(out RTL_OSVERSIONINFOEX lpVersionInformation);
  1245. internal static Version RtlGetVersion()
  1246. {
  1247. RTL_OSVERSIONINFOEX v = new RTL_OSVERSIONINFOEX();
  1248. v.dwOSVersionInfoSize = (uint)Marshal.SizeOf(v);
  1249. if (RtlGetVersion(out v) == 0)
  1250. {
  1251. return new Version((int)v.dwMajorVersion, (int)v.dwMinorVersion, (int)v.dwBuildNumber, (int)v.dwPlatformId);
  1252. }
  1253. else
  1254. {
  1255. throw new Exception("RtlGetVersion failed!");
  1256. }
  1257. }
  1258. [DllImport("kernel32", EntryPoint="WaitForMultipleObjectsEx", SetLastError = true, CharSet = CharSet.Auto)]
  1259. private static extern int IntWaitForMultipleObjectsEx(int nCount, IntPtr[] pHandles, bool bWaitAll, int dwMilliseconds, bool bAlertable);
  1260. public const int WAIT_FAILED = unchecked((int)0xFFFFFFFF);
  1261. internal static int WaitForMultipleObjectsEx(int nCount, IntPtr[] pHandles, bool bWaitAll, int dwMilliseconds, bool bAlertable)
  1262. {
  1263. int result = IntWaitForMultipleObjectsEx(nCount, pHandles, bWaitAll, dwMilliseconds, bAlertable);
  1264. if(result == WAIT_FAILED)
  1265. {
  1266. throw new Win32Exception();
  1267. }
  1268. return result;
  1269. }
  1270. [DllImport("user32.dll")]
  1271. internal static extern int SetWindowCompositionAttribute(IntPtr hwnd, ref WindowCompositionAttributeData data);
  1272. [StructLayout(LayoutKind.Sequential)]
  1273. internal struct WindowCompositionAttributeData
  1274. {
  1275. public WindowCompositionAttribute Attribute;
  1276. public IntPtr Data;
  1277. public int SizeOfData;
  1278. }
  1279. internal enum WindowCompositionAttribute
  1280. {
  1281. // ...
  1282. WCA_ACCENT_POLICY = 19
  1283. // ...
  1284. }
  1285. internal enum AccentState
  1286. {
  1287. ACCENT_DISABLED = 0,
  1288. ACCENT_ENABLE_GRADIENT = 1,
  1289. ACCENT_ENABLE_TRANSPARENTGRADIENT = 2,
  1290. ACCENT_ENABLE_BLURBEHIND = 3,
  1291. ACCENT_ENABLE_ACRYLIC = 4, //1703 and above
  1292. ACCENT_ENABLE_HOSTBACKDROP = 5, // RS5 1809
  1293. ACCENT_INVALID_STATE = 6
  1294. }
  1295. internal enum AccentFlags
  1296. {
  1297. DrawLeftBorder = 0x20,
  1298. DrawTopBorder = 0x40,
  1299. DrawRightBorder = 0x80,
  1300. DrawBottomBorder = 0x100,
  1301. }
  1302. [StructLayout(LayoutKind.Sequential)]
  1303. internal struct AccentPolicy
  1304. {
  1305. public AccentState AccentState;
  1306. public int AccentFlags;
  1307. public int GradientColor;
  1308. public int AnimationId;
  1309. }
  1310. [StructLayout(LayoutKind.Sequential)]
  1311. internal struct MARGINS
  1312. {
  1313. public int cxLeftWidth;
  1314. public int cxRightWidth;
  1315. public int cyTopHeight;
  1316. public int cyBottomHeight;
  1317. }
  1318. public enum MONITOR
  1319. {
  1320. MONITOR_DEFAULTTONULL = 0x00000000,
  1321. MONITOR_DEFAULTTOPRIMARY = 0x00000001,
  1322. MONITOR_DEFAULTTONEAREST = 0x00000002,
  1323. }
  1324. [StructLayout(LayoutKind.Sequential)]
  1325. internal struct MONITORINFO
  1326. {
  1327. public int cbSize;
  1328. public RECT rcMonitor;
  1329. public RECT rcWork;
  1330. public int dwFlags;
  1331. public static MONITORINFO Create()
  1332. {
  1333. return new MONITORINFO() { cbSize = Marshal.SizeOf<MONITORINFO>() };
  1334. }
  1335. public enum MonitorOptions : uint
  1336. {
  1337. MONITOR_DEFAULTTONULL = 0x00000000,
  1338. MONITOR_DEFAULTTOPRIMARY = 0x00000001,
  1339. MONITOR_DEFAULTTONEAREST = 0x00000002
  1340. }
  1341. }
  1342. public enum DEVICECAP
  1343. {
  1344. HORZRES = 8,
  1345. DESKTOPHORZRES = 118
  1346. }
  1347. public enum PROCESS_DPI_AWARENESS
  1348. {
  1349. PROCESS_DPI_UNAWARE = 0,
  1350. PROCESS_SYSTEM_DPI_AWARE = 1,
  1351. PROCESS_PER_MONITOR_DPI_AWARE = 2
  1352. }
  1353. public enum MONITOR_DPI_TYPE
  1354. {
  1355. MDT_EFFECTIVE_DPI = 0,
  1356. MDT_ANGULAR_DPI = 1,
  1357. MDT_RAW_DPI = 2,
  1358. MDT_DEFAULT = MDT_EFFECTIVE_DPI
  1359. }
  1360. public enum ClipboardFormat
  1361. {
  1362. /// <summary>
  1363. /// Text format. Each line ends with a carriage return/linefeed (CR-LF) combination. A null character signals the end of the data. Use this format for ANSI text.
  1364. /// </summary>
  1365. CF_TEXT = 1,
  1366. /// <summary>
  1367. /// A handle to a bitmap
  1368. /// </summary>
  1369. CF_BITMAP = 2,
  1370. /// <summary>
  1371. /// A memory object containing a BITMAPINFO structure followed by the bitmap bits.
  1372. /// </summary>
  1373. CF_DIB = 3,
  1374. /// <summary>
  1375. /// Unicode text format. Each line ends with a carriage return/linefeed (CR-LF) combination. A null character signals the end of the data.
  1376. /// </summary>
  1377. CF_UNICODETEXT = 13,
  1378. /// <summary>
  1379. /// A handle to type HDROP that identifies a list of files.
  1380. /// </summary>
  1381. CF_HDROP = 15,
  1382. }
  1383. public struct MSG
  1384. {
  1385. public IntPtr hwnd;
  1386. public uint message;
  1387. public IntPtr wParam;
  1388. public IntPtr lParam;
  1389. public uint time;
  1390. public POINT pt;
  1391. }
  1392. [StructLayout(LayoutKind.Sequential)]
  1393. public struct PAINTSTRUCT
  1394. {
  1395. public IntPtr hdc;
  1396. public bool fErase;
  1397. public RECT rcPaint;
  1398. public bool fRestore;
  1399. public bool fIncUpdate;
  1400. [MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)]
  1401. public byte[] rgbReserved;
  1402. }
  1403. public struct POINT
  1404. {
  1405. public int X;
  1406. public int Y;
  1407. }
  1408. public struct SIZE
  1409. {
  1410. public int X;
  1411. public int Y;
  1412. }
  1413. public struct RECT
  1414. {
  1415. public int left;
  1416. public int top;
  1417. public int right;
  1418. public int bottom;
  1419. public int Width => right - left;
  1420. public int Height => bottom - top;
  1421. public RECT(Rect rect)
  1422. {
  1423. left = (int)rect.X;
  1424. top = (int)rect.Y;
  1425. right = (int)(rect.X + rect.Width);
  1426. bottom = (int)(rect.Y + rect.Height);
  1427. }
  1428. public void Offset(POINT pt)
  1429. {
  1430. left += pt.X;
  1431. right += pt.X;
  1432. top += pt.Y;
  1433. bottom += pt.Y;
  1434. }
  1435. }
  1436. [StructLayout(LayoutKind.Sequential)]
  1437. public struct WINDOWPOS
  1438. {
  1439. public IntPtr hwnd;
  1440. public IntPtr hwndInsertAfter;
  1441. public int x;
  1442. public int y;
  1443. public int cx;
  1444. public int cy;
  1445. public uint flags;
  1446. }
  1447. [StructLayout(LayoutKind.Sequential)]
  1448. public struct NCCALCSIZE_PARAMS
  1449. {
  1450. [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)]
  1451. public RECT[] rgrc;
  1452. public WINDOWPOS lppos;
  1453. }
  1454. public struct TRACKMOUSEEVENT
  1455. {
  1456. public int cbSize;
  1457. public uint dwFlags;
  1458. public IntPtr hwndTrack;
  1459. public int dwHoverTime;
  1460. }
  1461. [StructLayout(LayoutKind.Sequential)]
  1462. public struct WINDOWPLACEMENT
  1463. {
  1464. /// <summary>
  1465. /// The length of the structure, in bytes. Before calling the GetWindowPlacement or SetWindowPlacement functions, set this member to sizeof(WINDOWPLACEMENT).
  1466. /// <para>
  1467. /// GetWindowPlacement and SetWindowPlacement fail if this member is not set correctly.
  1468. /// </para>
  1469. /// </summary>
  1470. public int Length;
  1471. /// <summary>
  1472. /// Specifies flags that control the position of the minimized window and the method by which the window is restored.
  1473. /// </summary>
  1474. public int Flags;
  1475. /// <summary>
  1476. /// The current show state of the window.
  1477. /// </summary>
  1478. public ShowWindowCommand ShowCmd;
  1479. /// <summary>
  1480. /// The coordinates of the window's upper-left corner when the window is minimized.
  1481. /// </summary>
  1482. public POINT MinPosition;
  1483. /// <summary>
  1484. /// The coordinates of the window's upper-left corner when the window is maximized.
  1485. /// </summary>
  1486. public POINT MaxPosition;
  1487. /// <summary>
  1488. /// The window's coordinates when the window is in the restored position.
  1489. /// </summary>
  1490. public RECT NormalPosition;
  1491. /// <summary>
  1492. /// Gets the default (empty) value.
  1493. /// </summary>
  1494. public static WINDOWPLACEMENT Default
  1495. {
  1496. get
  1497. {
  1498. WINDOWPLACEMENT result = new WINDOWPLACEMENT();
  1499. result.Length = Marshal.SizeOf(result);
  1500. return result;
  1501. }
  1502. }
  1503. }
  1504. [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
  1505. public struct WNDCLASSEX
  1506. {
  1507. public int cbSize;
  1508. public int style;
  1509. public WndProc lpfnWndProc;
  1510. public int cbClsExtra;
  1511. public int cbWndExtra;
  1512. public IntPtr hInstance;
  1513. public IntPtr hIcon;
  1514. public IntPtr hCursor;
  1515. public IntPtr hbrBackground;
  1516. public string lpszMenuName;
  1517. public string lpszClassName;
  1518. public IntPtr hIconSm;
  1519. }
  1520. [StructLayout(LayoutKind.Sequential)]
  1521. public struct TOUCHINPUT
  1522. {
  1523. public int X;
  1524. public int Y;
  1525. public IntPtr Source;
  1526. public uint Id;
  1527. public TouchInputFlags Flags;
  1528. public int Mask;
  1529. public uint Time;
  1530. public IntPtr ExtraInfo;
  1531. public int CxContact;
  1532. public int CyContact;
  1533. }
  1534. [Flags]
  1535. public enum TouchInputFlags
  1536. {
  1537. /// <summary>
  1538. /// Movement has occurred. Cannot be combined with TOUCHEVENTF_DOWN.
  1539. /// </summary>
  1540. TOUCHEVENTF_MOVE = 0x0001,
  1541. /// <summary>
  1542. /// The corresponding touch point was established through a new contact. Cannot be combined with TOUCHEVENTF_MOVE or TOUCHEVENTF_UP.
  1543. /// </summary>
  1544. TOUCHEVENTF_DOWN = 0x0002,
  1545. /// <summary>
  1546. /// A touch point was removed.
  1547. /// </summary>
  1548. TOUCHEVENTF_UP = 0x0004,
  1549. /// <summary>
  1550. /// A touch point is in range. This flag is used to enable touch hover support on compatible hardware. Applications that do not want support for hover can ignore this flag.
  1551. /// </summary>
  1552. TOUCHEVENTF_INRANGE = 0x0008,
  1553. /// <summary>
  1554. /// Indicates that this TOUCHINPUT structure corresponds to a primary contact point. See the following text for more information on primary touch points.
  1555. /// </summary>
  1556. TOUCHEVENTF_PRIMARY = 0x0010,
  1557. /// <summary>
  1558. /// When received using GetTouchInputInfo, this input was not coalesced.
  1559. /// </summary>
  1560. TOUCHEVENTF_NOCOALESCE = 0x0020,
  1561. /// <summary>
  1562. /// The touch event came from the user's palm.
  1563. /// </summary>
  1564. TOUCHEVENTF_PALM = 0x0080
  1565. }
  1566. [Flags]
  1567. public enum OpenFileNameFlags
  1568. {
  1569. OFN_ALLOWMULTISELECT = 0x00000200,
  1570. OFN_EXPLORER = 0x00080000,
  1571. OFN_HIDEREADONLY = 0x00000004,
  1572. OFN_NOREADONLYRETURN = 0x00008000,
  1573. OFN_OVERWRITEPROMPT = 0x00000002
  1574. }
  1575. public enum HRESULT : uint
  1576. {
  1577. S_FALSE = 0x0001,
  1578. S_OK = 0x0000,
  1579. E_INVALIDARG = 0x80070057,
  1580. E_OUTOFMEMORY = 0x8007000E,
  1581. E_NOTIMPL = 0x80004001,
  1582. E_UNEXPECTED = 0x8000FFFF
  1583. }
  1584. public enum Icons
  1585. {
  1586. ICON_SMALL = 0,
  1587. ICON_BIG = 1
  1588. }
  1589. public const uint SIGDN_FILESYSPATH = 0x80058000;
  1590. [Flags]
  1591. public enum FOS : uint
  1592. {
  1593. FOS_OVERWRITEPROMPT = 0x00000002,
  1594. FOS_STRICTFILETYPES = 0x00000004,
  1595. FOS_NOCHANGEDIR = 0x00000008,
  1596. FOS_PICKFOLDERS = 0x00000020,
  1597. FOS_FORCEFILESYSTEM = 0x00000040, // Ensure that items returned are filesystem items.
  1598. FOS_ALLNONSTORAGEITEMS = 0x00000080, // Allow choosing items that have no storage.
  1599. FOS_NOVALIDATE = 0x00000100,
  1600. FOS_ALLOWMULTISELECT = 0x00000200,
  1601. FOS_PATHMUSTEXIST = 0x00000800,
  1602. FOS_FILEMUSTEXIST = 0x00001000,
  1603. FOS_CREATEPROMPT = 0x00002000,
  1604. FOS_SHAREAWARE = 0x00004000,
  1605. FOS_NOREADONLYRETURN = 0x00008000,
  1606. FOS_NOTESTFILECREATE = 0x00010000,
  1607. FOS_HIDEMRUPLACES = 0x00020000,
  1608. FOS_HIDEPINNEDPLACES = 0x00040000,
  1609. FOS_NODEREFERENCELINKS = 0x00100000,
  1610. FOS_DONTADDTORECENT = 0x02000000,
  1611. FOS_FORCESHOWHIDDEN = 0x10000000,
  1612. FOS_DEFAULTNOMINIMODE = 0x20000000
  1613. }
  1614. public static class ShellIds
  1615. {
  1616. public static readonly Guid OpenFileDialog = Guid.Parse("DC1C5A9C-E88A-4DDE-A5A1-60F82A20AEF7");
  1617. public static readonly Guid SaveFileDialog = Guid.Parse("C0B4E2F3-BA21-4773-8DBA-335EC946EB8B");
  1618. public static readonly Guid IFileDialog = Guid.Parse("42F85136-DB7E-439C-85F1-E4075D135FC8");
  1619. public static readonly Guid IShellItem = Guid.Parse("43826D1E-E718-42EE-BC55-A1E261C37BFE");
  1620. public static readonly Guid TaskBarList = Guid.Parse("56FDF344-FD6D-11D0-958A-006097C9A090");
  1621. public static readonly Guid ITaskBarList2 = Guid.Parse("ea1afb91-9e28-4b86-90e9-9e9f8a5eefaf");
  1622. }
  1623. [ComImport(), Guid("42F85136-DB7E-439C-85F1-E4075D135FC8"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
  1624. public interface IFileDialog
  1625. {
  1626. [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
  1627. [PreserveSig()]
  1628. uint Show([In, Optional] IntPtr hwndOwner); //IModalWindow
  1629. [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
  1630. uint SetFileTypes(uint cFileTypes, [In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 0)] COMDLG_FILTERSPEC[] rgFilterSpec);
  1631. [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
  1632. uint SetFileTypeIndex([In] uint iFileType);
  1633. [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
  1634. uint GetFileTypeIndex(out uint piFileType);
  1635. [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
  1636. uint Advise([In, MarshalAs(UnmanagedType.Interface)] IntPtr pfde, out uint pdwCookie);
  1637. [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
  1638. uint Unadvise([In] uint dwCookie);
  1639. [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
  1640. uint SetOptions([In] uint fos);
  1641. [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
  1642. uint GetOptions(out uint fos);
  1643. [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
  1644. void SetDefaultFolder([In, MarshalAs(UnmanagedType.Interface)] IShellItem psi);
  1645. [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
  1646. uint SetFolder([In, MarshalAs(UnmanagedType.Interface)] IShellItem psi);
  1647. [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
  1648. uint GetFolder([MarshalAs(UnmanagedType.Interface)] out IShellItem ppsi);
  1649. [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
  1650. uint GetCurrentSelection([MarshalAs(UnmanagedType.Interface)] out IShellItem ppsi);
  1651. [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
  1652. uint SetFileName([In, MarshalAs(UnmanagedType.LPWStr)] string pszName);
  1653. [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
  1654. uint GetFileName([MarshalAs(UnmanagedType.LPWStr)] out string pszName);
  1655. [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
  1656. uint SetTitle([In, MarshalAs(UnmanagedType.LPWStr)] string pszTitle);
  1657. [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
  1658. uint SetOkButtonLabel([In, MarshalAs(UnmanagedType.LPWStr)] string pszText);
  1659. [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
  1660. uint SetFileNameLabel([In, MarshalAs(UnmanagedType.LPWStr)] string pszLabel);
  1661. [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
  1662. uint GetResult([MarshalAs(UnmanagedType.Interface)] out IShellItem ppsi);
  1663. [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
  1664. uint AddPlace([In, MarshalAs(UnmanagedType.Interface)] IShellItem psi, uint fdap);
  1665. [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
  1666. uint SetDefaultExtension([In, MarshalAs(UnmanagedType.LPWStr)] string pszDefaultExtension);
  1667. [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
  1668. uint Close([MarshalAs(UnmanagedType.Error)] uint hr);
  1669. [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
  1670. uint SetClientGuid([In] ref Guid guid);
  1671. [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
  1672. uint ClearClientData();
  1673. [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
  1674. uint SetFilter([MarshalAs(UnmanagedType.Interface)] IntPtr pFilter);
  1675. }
  1676. [ComImport, Guid("d57c7288-d4ad-4768-be02-9d969532d960"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
  1677. public interface IFileOpenDialog
  1678. {
  1679. [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
  1680. [PreserveSig()]
  1681. uint Show([In, Optional] IntPtr hwndOwner); //IModalWindow
  1682. [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
  1683. uint SetFileTypes([In] uint cFileTypes, [In, MarshalAs(UnmanagedType.LPArray)] IntPtr rgFilterSpec);
  1684. [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
  1685. void SetFileTypeIndex([In] uint iFileType);
  1686. [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
  1687. void GetFileTypeIndex(out uint piFileType);
  1688. [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
  1689. uint Advise([In, MarshalAs(UnmanagedType.Interface)] IntPtr pfde, out uint pdwCookie);
  1690. [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
  1691. void Unadvise([In] uint dwCookie);
  1692. [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
  1693. uint SetOptions([In] uint fos);
  1694. [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
  1695. uint GetOptions(out uint fos);
  1696. [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
  1697. void SetDefaultFolder([In, MarshalAs(UnmanagedType.Interface)] IShellItem psi);
  1698. [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
  1699. void SetFolder([In, MarshalAs(UnmanagedType.Interface)] IShellItem psi);
  1700. [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
  1701. void GetFolder([MarshalAs(UnmanagedType.Interface)] out IShellItem ppsi);
  1702. [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
  1703. void GetCurrentSelection([MarshalAs(UnmanagedType.Interface)] out IShellItem ppsi);
  1704. [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
  1705. void SetFileName([In, MarshalAs(UnmanagedType.LPWStr)] string pszName);
  1706. [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
  1707. void GetFileName([MarshalAs(UnmanagedType.LPWStr)] out string pszName);
  1708. [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
  1709. void SetTitle([In, MarshalAs(UnmanagedType.LPWStr)] string pszTitle);
  1710. [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
  1711. void SetOkButtonLabel([In, MarshalAs(UnmanagedType.LPWStr)] string pszText);
  1712. [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
  1713. void SetFileNameLabel([In, MarshalAs(UnmanagedType.LPWStr)] string pszLabel);
  1714. [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
  1715. void GetResult([MarshalAs(UnmanagedType.Interface)] out IShellItem ppsi);
  1716. [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
  1717. uint AddPlace([In, MarshalAs(UnmanagedType.Interface)] IShellItem psi, uint fdap);
  1718. [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
  1719. void SetDefaultExtension([In, MarshalAs(UnmanagedType.LPWStr)] string pszDefaultExtension);
  1720. [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
  1721. void Close([MarshalAs(UnmanagedType.Error)] int hr);
  1722. [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
  1723. void SetClientGuid([In] ref Guid guid);
  1724. [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
  1725. void ClearClientData();
  1726. [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
  1727. void SetFilter([MarshalAs(UnmanagedType.Interface)] IntPtr pFilter);
  1728. [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
  1729. void GetResults([MarshalAs(UnmanagedType.Interface)] out IShellItemArray ppenum);
  1730. [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
  1731. void GetSelectedItems([MarshalAs(UnmanagedType.Interface)] out IShellItemArray ppsai);
  1732. }
  1733. [ComImport, Guid("B63EA76D-1F85-456F-A19C-48159EFA858B"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
  1734. public interface IShellItemArray
  1735. {
  1736. [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
  1737. void BindToHandler([In, MarshalAs(UnmanagedType.Interface)] IntPtr pbc, [In] ref Guid rbhid,
  1738. [In] ref Guid riid, out IntPtr ppvOut);
  1739. [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
  1740. void GetPropertyStore([In] int Flags, [In] ref Guid riid, out IntPtr ppv);
  1741. [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
  1742. void GetPropertyDescriptionList([In] ref PROPERTYKEY keyType, [In] ref Guid riid, out IntPtr ppv);
  1743. [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
  1744. void GetAttributes([In] SIATTRIBFLAGS dwAttribFlags, [In] uint sfgaoMask, out uint psfgaoAttribs);
  1745. [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
  1746. void GetCount(out uint pdwNumItems);
  1747. [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
  1748. void GetItemAt([In] uint dwIndex, [MarshalAs(UnmanagedType.Interface)] out IShellItem ppsi);
  1749. [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
  1750. void EnumItems([MarshalAs(UnmanagedType.Interface)] out IntPtr ppenumShellItems);
  1751. }
  1752. [StructLayout(LayoutKind.Sequential, Pack = 4)]
  1753. public struct PROPERTYKEY
  1754. {
  1755. public Guid fmtid;
  1756. public uint pid;
  1757. }
  1758. public enum SIATTRIBFLAGS
  1759. {
  1760. SIATTRIBFLAGS_AND = 1,
  1761. SIATTRIBFLAGS_APPCOMPAT = 3,
  1762. SIATTRIBFLAGS_OR = 2
  1763. }
  1764. [ComImport, Guid("43826D1E-E718-42EE-BC55-A1E261C37BFE"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
  1765. public interface IShellItem
  1766. {
  1767. [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
  1768. uint BindToHandler([In] IntPtr pbc, [In] ref Guid rbhid, [In] ref Guid riid, [Out, MarshalAs(UnmanagedType.Interface)] out IntPtr ppvOut);
  1769. [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
  1770. uint GetParent([MarshalAs(UnmanagedType.Interface)] out IShellItem ppsi);
  1771. [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
  1772. uint GetDisplayName([In] uint sigdnName, out IntPtr ppszName);
  1773. [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
  1774. uint GetAttributes([In] uint sfgaoMask, out uint psfgaoAttribs);
  1775. [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
  1776. uint Compare([In, MarshalAs(UnmanagedType.Interface)] IShellItem psi, [In] uint hint, out int piOrder);
  1777. }
  1778. [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
  1779. public struct COMDLG_FILTERSPEC
  1780. {
  1781. [MarshalAs(UnmanagedType.LPWStr)]
  1782. public string pszName;
  1783. [MarshalAs(UnmanagedType.LPWStr)]
  1784. public string pszSpec;
  1785. }
  1786. public delegate void MarkFullscreenWindow(IntPtr This, IntPtr hwnd, [MarshalAs(UnmanagedType.Bool)] bool fullscreen);
  1787. public delegate HRESULT HrInit(IntPtr This);
  1788. public struct ITaskBarList2VTable
  1789. {
  1790. public IntPtr IUnknown1;
  1791. public IntPtr IUnknown2;
  1792. public IntPtr IUnknown3;
  1793. public IntPtr HrInit;
  1794. public IntPtr AddTab;
  1795. public IntPtr DeleteTab;
  1796. public IntPtr ActivateTab;
  1797. public IntPtr SetActiveAlt;
  1798. public IntPtr MarkFullscreenWindow;
  1799. }
  1800. }
  1801. [Flags]
  1802. internal enum DropEffect : int
  1803. {
  1804. None = 0,
  1805. Copy = 1,
  1806. Move = 2,
  1807. Link = 4,
  1808. Scroll = -2147483648,
  1809. }
  1810. [ComImport]
  1811. [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
  1812. [Guid("00000122-0000-0000-C000-000000000046")]
  1813. internal interface IDropTarget
  1814. {
  1815. [PreserveSig]
  1816. UnmanagedMethods.HRESULT DragEnter([MarshalAs(UnmanagedType.Interface)] [In] IOleDataObject pDataObj, [MarshalAs(UnmanagedType.U4)] [In] int grfKeyState, [MarshalAs(UnmanagedType.U8)] [In] long pt, [In] [Out] ref DropEffect pdwEffect);
  1817. [PreserveSig]
  1818. UnmanagedMethods.HRESULT DragOver([MarshalAs(UnmanagedType.U4)] [In] int grfKeyState, [MarshalAs(UnmanagedType.U8)] [In] long pt, [In] [Out] ref DropEffect pdwEffect);
  1819. [PreserveSig]
  1820. UnmanagedMethods.HRESULT DragLeave();
  1821. [PreserveSig]
  1822. UnmanagedMethods.HRESULT Drop([MarshalAs(UnmanagedType.Interface)] [In] IOleDataObject pDataObj, [MarshalAs(UnmanagedType.U4)] [In] int grfKeyState, [MarshalAs(UnmanagedType.U8)] [In] long pt, [In] [Out] ref DropEffect pdwEffect);
  1823. }
  1824. [ComImport]
  1825. [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
  1826. [Guid("00000121-0000-0000-C000-000000000046")]
  1827. internal interface IDropSource
  1828. {
  1829. [PreserveSig]
  1830. int QueryContinueDrag(int fEscapePressed, [MarshalAs(UnmanagedType.U4)] [In] int grfKeyState);
  1831. [PreserveSig]
  1832. int GiveFeedback([MarshalAs(UnmanagedType.U4)] [In] int dwEffect);
  1833. }
  1834. [ComImport]
  1835. [Guid("0000010E-0000-0000-C000-000000000046")]
  1836. [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
  1837. internal interface IOleDataObject
  1838. {
  1839. void GetData([In] ref FORMATETC format, out STGMEDIUM medium);
  1840. void GetDataHere([In] ref FORMATETC format, ref STGMEDIUM medium);
  1841. [PreserveSig]
  1842. int QueryGetData([In] ref FORMATETC format);
  1843. [PreserveSig]
  1844. int GetCanonicalFormatEtc([In] ref FORMATETC formatIn, out FORMATETC formatOut);
  1845. void SetData([In] ref FORMATETC formatIn, [In] ref STGMEDIUM medium, [MarshalAs(UnmanagedType.Bool)] bool release);
  1846. IEnumFORMATETC EnumFormatEtc(DATADIR direction);
  1847. [PreserveSig]
  1848. int DAdvise([In] ref FORMATETC pFormatetc, ADVF advf, IAdviseSink adviseSink, out int connection);
  1849. void DUnadvise(int connection);
  1850. [PreserveSig]
  1851. int EnumDAdvise(out IEnumSTATDATA enumAdvise);
  1852. }
  1853. [StructLayoutAttribute(LayoutKind.Sequential)]
  1854. internal struct _DROPFILES
  1855. {
  1856. public Int32 pFiles;
  1857. public Int32 X;
  1858. public Int32 Y;
  1859. public bool fNC;
  1860. public bool fWide;
  1861. }
  1862. [Flags]
  1863. internal enum PixelFormatDescriptorFlags : uint
  1864. {
  1865. PFD_DOUBLEBUFFER = 0x00000001,
  1866. PFD_STEREO = 0x00000002,
  1867. PFD_DRAW_TO_WINDOW = 0x00000004,
  1868. PFD_DRAW_TO_BITMAP = 0x00000008,
  1869. PFD_SUPPORT_GDI = 0x00000010,
  1870. PFD_SUPPORT_OPENGL = 0x00000020,
  1871. PFD_GENERIC_FORMAT = 0x00000040,
  1872. PFD_NEED_PALETTE = 0x00000080,
  1873. PFD_NEED_SYSTEM_PALETTE = 0x00000100,
  1874. PFD_SWAP_EXCHANGE = 0x00000200,
  1875. PFD_SWAP_COPY = 0x00000400,
  1876. PFD_SWAP_LAYER_BUFFERS = 0x00000800,
  1877. PFD_GENERIC_ACCELERATED = 0x00001000,
  1878. PFD_SUPPORT_DIRECTDRAW = 0x00002000,
  1879. PFD_DEPTH_DONTCARE = 0x20000000,
  1880. PFD_DOUBLEBUFFER_DONTCARE = 0x40000000,
  1881. PFD_STEREO_DONTCARE = 0x80000000,
  1882. }
  1883. [StructLayout(LayoutKind.Sequential)]
  1884. internal struct PixelFormatDescriptor
  1885. {
  1886. public ushort Size;
  1887. public ushort Version;
  1888. public PixelFormatDescriptorFlags Flags;
  1889. public byte PixelType;
  1890. public byte ColorBits;
  1891. public byte RedBits;
  1892. public byte RedShift;
  1893. public byte GreenBits;
  1894. public byte GreenShift;
  1895. public byte BlueBits;
  1896. public byte BlueShift;
  1897. public byte AlphaBits;
  1898. public byte AlphaShift;
  1899. public byte AccumBits;
  1900. public byte AccumRedBits;
  1901. public byte AccumGreenBits;
  1902. public byte AccumBlueBits;
  1903. public byte AccumAlphaBits;
  1904. public byte DepthBits;
  1905. public byte StencilBits;
  1906. public byte AuxBuffers;
  1907. public byte LayerType;
  1908. private byte Reserved;
  1909. public uint LayerMask;
  1910. public uint VisibleMask;
  1911. public uint DamageMask;
  1912. }
  1913. }