/trunk/xPlatform.x86.kernel32/kernel32.cs

# · C# · 4523 lines · 3276 code · 1245 blank · 2 comment · 0 complexity · aa90e90fe4541ff77d5ee0114ff89b7d MD5 · raw file

  1. using System;
  2. using System.Text;
  3. using xPlatform.Flags;
  4. using System.Runtime.InteropServices;
  5. namespace xPlatform.x86.kernel32
  6. {
  7. [Serializable]
  8. public partial class kernel32 : ModuleBase
  9. {
  10. [NonSerialized]
  11. public const string ModuleName = "kernel32.dll";
  12. }
  13. #region Atom functions
  14. partial class kernel32
  15. {
  16. [DllImport(ModuleName), CLSCompliant(false)]
  17. public static extern ATOM AddAtomA(IntPtr lpString);
  18. [DllImport(ModuleName, CharSet = CharSet.Ansi), CLSCompliant(false)]
  19. public static extern ATOM AddAtomA(string lpString);
  20. [DllImport(ModuleName), CLSCompliant(false)]
  21. public static extern ATOM AddAtomW(IntPtr lpString);
  22. [DllImport(ModuleName, CharSet = CharSet.Unicode), CLSCompliant(false)]
  23. public static extern ATOM AddAtomW(string lpString);
  24. [DllImport(ModuleName), CLSCompliant(false)]
  25. public static extern ATOM DeleteAtom(ATOM nAtom);
  26. [DllImport(ModuleName), CLSCompliant(false)]
  27. public static extern ATOM FindAtomA(IntPtr lpString);
  28. [DllImport(ModuleName, CharSet = CharSet.Ansi), CLSCompliant(false)]
  29. public static extern ATOM FindAtomA(string lpString);
  30. [DllImport(ModuleName), CLSCompliant(false)]
  31. public static extern ATOM FindAtomW(IntPtr lpString);
  32. [DllImport(ModuleName, CharSet = CharSet.Unicode), CLSCompliant(false)]
  33. public static extern ATOM FindAtomW(string lpString);
  34. [DllImport(ModuleName), CLSCompliant(false)]
  35. public static extern uint GetAtomNameA(ATOM nAtom, IntPtr lpBuffer, int nSize);
  36. [DllImport(ModuleName, CharSet = CharSet.Ansi), CLSCompliant(false)]
  37. public static extern uint GetAtomNameA(ATOM nAtom, StringBuilder lpBuffer, int nSize);
  38. [DllImport(ModuleName), CLSCompliant(false)]
  39. public static extern uint GetAtomNameW(ATOM nAtom, IntPtr lpBuffer, int nSize);
  40. [DllImport(ModuleName, CharSet = CharSet.Unicode), CLSCompliant(false)]
  41. public static extern uint GetAtomNameW(ATOM nAtom, StringBuilder lpBuffer, int nSize);
  42. [DllImport(ModuleName), CLSCompliant(false)]
  43. public static extern ATOM GlobalAddAtomA(IntPtr lpString);
  44. [DllImport(ModuleName, CharSet = CharSet.Ansi), CLSCompliant(false)]
  45. public static extern ATOM GlobalAddAtomA(string lpString);
  46. [DllImport(ModuleName), CLSCompliant(false)]
  47. public static extern ATOM GlobalAddAtomW(IntPtr lpString);
  48. [DllImport(ModuleName, CharSet = CharSet.Unicode), CLSCompliant(false)]
  49. public static extern ATOM GlobalAddAtomW(string lpString);
  50. [DllImport(ModuleName), CLSCompliant(false)]
  51. public static extern ATOM GlobalDeleteAtom(ATOM nAtom);
  52. [DllImport(ModuleName), CLSCompliant(false)]
  53. public static extern ATOM GlobalFindAtomA(IntPtr lpString);
  54. [DllImport(ModuleName, CharSet = CharSet.Ansi), CLSCompliant(false)]
  55. public static extern ATOM GlobalFindAtomA(string lpString);
  56. [DllImport(ModuleName), CLSCompliant(false)]
  57. public static extern ATOM GlobalFindAtomW(IntPtr lpString);
  58. [DllImport(ModuleName, CharSet = CharSet.Unicode), CLSCompliant(false)]
  59. public static extern ATOM GlobalFindAtomW(string lpString);
  60. [DllImport(ModuleName), CLSCompliant(false)]
  61. public static extern uint GlobalGetAtomNameA(ATOM nAtom, IntPtr lpBuffer, int nSize);
  62. [DllImport(ModuleName, CharSet = CharSet.Ansi), CLSCompliant(false)]
  63. public static extern uint GlobalGetAtomNameA(ATOM nAtom, StringBuilder lpBuffer, int nSize);
  64. [DllImport(ModuleName), CLSCompliant(false)]
  65. public static extern uint GlobalGetAtomNameW(ATOM nAtom, IntPtr lpBuffer, int nSize);
  66. [DllImport(ModuleName, CharSet = CharSet.Unicode), CLSCompliant(false)]
  67. public static extern uint GlobalGetAtomNameW(ATOM nAtom, StringBuilder lpBuffer, int nSize);
  68. [DllImport(ModuleName), CLSCompliant(false)]
  69. public static extern int InitAtomTable(uint nSize);
  70. public static IntPtr MAKEINTATOM(int i)
  71. {
  72. return new IntPtr((uint)((ushort)i));
  73. }
  74. }
  75. #endregion // Atom functions
  76. #region Debugging functions
  77. partial class kernel32
  78. {
  79. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  80. public static extern int ContinueDebugEvent(uint dwProcessId, uint dwThreadId, uint dwContinueStatus);
  81. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  82. public static extern int DebugActiveProcess(uint dwProcessId);
  83. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  84. public static extern int DebugActiveProcessStop(uint dwProcessId);
  85. [DllImport(ModuleName)]
  86. public static extern void DebugBreak();
  87. [DllImport(ModuleName, SetLastError = true)]
  88. public static extern int DebugBreakProcess(IntPtr Process);
  89. [DllImport(ModuleName, SetLastError = true)]
  90. public static extern int DebugSetProcessKillOnExit(int KillOnExit);
  91. [DllImport(ModuleName)]
  92. public static extern void FatalExit(int ExitCode);
  93. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  94. public static extern int FlushInstructionCache(IntPtr hProcess, IntPtr lpBaseAddress, uint dwSize);
  95. [DllImport(ModuleName, SetLastError = true)]
  96. public static extern int GetThreadContext(IntPtr hThread, IntPtr lpContext);
  97. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  98. public static extern int GetThreadContext(IntPtr hThread, ref CONTEXT lpContext);
  99. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  100. public static extern int GetThreadSelectorEntry(IntPtr hThread, uint dwSelector, IntPtr lpSelectorEntry);
  101. [Todo("Test Required")]
  102. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  103. public static extern int GetThreadSelectorEntry(IntPtr hThread, uint dwSelector, ref LDT_ENTRY lpSelectorEntry);
  104. [DllImport(ModuleName)]
  105. public static extern int IsDebuggerPresent();
  106. [DllImport(ModuleName)]
  107. public static extern void OutputDebugStringA(IntPtr lpOutputString);
  108. [DllImport(ModuleName, CharSet = CharSet.Ansi)]
  109. public static extern void OutputDebugStringA(string lpOutputString);
  110. [DllImport(ModuleName)]
  111. public static extern void OutputDebugStringW(IntPtr lpOutputString);
  112. [DllImport(ModuleName, CharSet = CharSet.Unicode)]
  113. public static extern void OutputDebugStringW(string lpOutputString);
  114. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  115. public static extern int ReadProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress, IntPtr lpBuffer, uint nSize, IntPtr lpNumberOfBytesRead);
  116. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  117. public static extern int ReadProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress, IntPtr lpBuffer, uint nSize, ref uint lpNumberOfBytesRead);
  118. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  119. public static extern void SetDebugErrorLevel(uint dwLevel);
  120. [DllImport(ModuleName, SetLastError = true)]
  121. public static extern int SetThreadContext(IntPtr hThread, IntPtr lpContext);
  122. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  123. public static extern int SetThreadContext(IntPtr hThread, ref CONTEXT lpContext);
  124. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  125. public static extern int WaitForDebugEvent(IntPtr lpDebugEvent, uint dwMilliseconds);
  126. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  127. public static extern int WaitForDebugEvent(ref DEBUG_EVENT lpDebugEvent, uint dwMilliseconds);
  128. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  129. public static extern int WriteProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress, IntPtr lpBuffer, uint nSize, IntPtr lpNumberOfBytesWritten);
  130. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  131. public static extern int WriteProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress, IntPtr lpBuffer, uint nSize, ref uint lpNumberOfBytesWritten);
  132. }
  133. #endregion // Debugging functions
  134. #region Error functions
  135. partial class kernel32
  136. {
  137. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  138. public static extern int Beep(uint dwFreq, uint dwDuration);
  139. [DllImport(ModuleName), CLSCompliant(false)]
  140. public static extern void FatalAppExitA(uint uAction, IntPtr lpMessageText);
  141. [DllImport(ModuleName, CharSet = CharSet.Ansi), CLSCompliant(false)]
  142. public static extern void FatalAppExitA(uint uAction, string lpMessageText);
  143. [DllImport(ModuleName), CLSCompliant(false)]
  144. public static extern void FatalAppExitW(uint uAction, IntPtr lpMessageText);
  145. [DllImport(ModuleName, CharSet = CharSet.Unicode), CLSCompliant(false)]
  146. public static extern void FatalAppExitW(uint uAction, string lpMessageText);
  147. [DllImport(ModuleName, CharSet = CharSet.Ansi, SetLastError = true), CLSCompliant(false)]
  148. public static extern uint FormatMessageA(uint dwFlags, IntPtr lpSource, uint dwMessageId, uint dwLanguageId, IntPtr lpBuffer, uint nSize, IntPtr Arguments);
  149. [DllImport(ModuleName, CharSet = CharSet.Ansi, SetLastError = true), CLSCompliant(false)]
  150. public static extern uint FormatMessageA(uint dwFlags, IntPtr lpSource, uint dwMessageId, uint dwLanguageId, StringBuilder lpBuffer, uint nSize, IntPtr Arguments);
  151. [DllImport(ModuleName, CharSet = CharSet.Unicode, SetLastError = true), CLSCompliant(false)]
  152. public static extern uint FormatMessageW(uint dwFlags, IntPtr lpSource, uint dwMessageId, uint dwLanguageId, IntPtr lpBuffer, uint nSize, IntPtr Arguments);
  153. [DllImport(ModuleName, CharSet = CharSet.Unicode, SetLastError = true), CLSCompliant(false)]
  154. public static extern uint FormatMessageW(uint dwFlags, IntPtr lpSource, uint dwMessageId, uint dwLanguageId, StringBuilder lpBuffer, uint nSize, IntPtr Arguments);
  155. public static int GetLastError()
  156. {
  157. return Marshal.GetLastWin32Error();
  158. }
  159. [DllImport(ModuleName), CLSCompliant(false)]
  160. public static extern uint SetErrorMode(uint uMode);
  161. [DllImport(ModuleName), CLSCompliant(false)]
  162. public static extern void SetLastError(uint dwErrCode);
  163. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  164. public static extern void SetLastErrorEx(uint dwErrCode, uint dwType);
  165. }
  166. #endregion // Error functions
  167. #region Console functions
  168. partial class kernel32
  169. {
  170. [DllImport(ModuleName, CallingConvention = CallingConvention.Winapi)]
  171. public static extern int AddConsoleAliasA(
  172. [In] IntPtr Source,
  173. [In] IntPtr Target,
  174. [In] IntPtr ExeName);
  175. [DllImport(ModuleName, CallingConvention = CallingConvention.Winapi, CharSet = CharSet.Ansi)]
  176. public static extern int AddConsoleAliasA(
  177. [In] string Source,
  178. [In] string Target,
  179. [In] string ExeName);
  180. [DllImport(ModuleName, CallingConvention = CallingConvention.Winapi)]
  181. public static extern int AddConsoleAliasW(
  182. [In] IntPtr Source,
  183. [In] IntPtr Target,
  184. [In] IntPtr ExeName);
  185. [DllImport(ModuleName, CallingConvention = CallingConvention.Winapi, CharSet = CharSet.Unicode)]
  186. public static extern int AddConsoleAliasW(
  187. [In] string Source,
  188. [In] string Target,
  189. [In] string ExeName);
  190. [DllImport(ModuleName, SetLastError = true)]
  191. public static extern int AllocConsole();
  192. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  193. public static extern int AttachConsole(
  194. [In] uint dwProcessId);
  195. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  196. public static extern IntPtr CreateConsoleScreenBuffer(
  197. [In] uint dwDesiredAccess,
  198. [In] uint dwShareMode,
  199. [In] IntPtr lpSecurityAttributes,
  200. [In] uint dwFlags,
  201. [In] IntPtr lpScreenBufferData);
  202. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  203. public static extern IntPtr CreateConsoleScreenBuffer(
  204. [In] uint dwDesiredAccess,
  205. [In] uint dwShareMode,
  206. [In] ref SECURITY_ATTRIBUTES lpSecurityAttributes,
  207. [In] uint dwFlags,
  208. [In] IntPtr lpScreenBufferData);
  209. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  210. public static extern int FillConsoleOutputAttribute(
  211. [In] IntPtr hConsoleOutput,
  212. [In] ushort wAttribute,
  213. [In] uint nLength,
  214. [In] COORD dwWriteCoord,
  215. [Out] IntPtr lpNumberOfAttrsWritten);
  216. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  217. public static extern int FillConsoleOutputAttribute(
  218. [In] IntPtr hConsoleOutput,
  219. [In] ushort wAttribute,
  220. [In] uint nLength,
  221. [In] COORD dwWriteCoord,
  222. [Out] out uint lpNumberOfAttrsWritten);
  223. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  224. public static extern int FillConsoleOutputCharacterA(
  225. [In] IntPtr hConsoleOutput,
  226. [In] sbyte cCharacter,
  227. [In] uint nLength,
  228. [In] COORD dwWriteCoord,
  229. [Out] IntPtr lpNumberOfCharsWritten);
  230. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  231. public static extern int FillConsoleOutputCharacterA(
  232. [In] IntPtr hConsoleOutput,
  233. [In] sbyte cCharacter,
  234. [In] uint nLength,
  235. [In] COORD dwWriteCoord,
  236. [Out] out uint lpNumberOfCharsWritten);
  237. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  238. public static extern int FillConsoleOutputCharacterW(
  239. [In] IntPtr hConsoleOutput,
  240. [In] ushort cCharacter,
  241. [In] uint nLength,
  242. [In] COORD dwWriteCoord,
  243. [Out] IntPtr lpNumberOfCharsWritten);
  244. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  245. public static extern int FillConsoleOutputCharacterW(
  246. [In] IntPtr hConsoleOutput,
  247. [In] ushort cCharacter,
  248. [In] uint nLength,
  249. [In] COORD dwWriteCoord,
  250. [Out] out uint lpNumberOfCharsWritten);
  251. [DllImport(ModuleName, SetLastError = true)]
  252. public static extern int FlushConsoleInputBuffer(
  253. [In] IntPtr hConsoleInput);
  254. [DllImport(ModuleName, SetLastError = true)]
  255. public static extern int FreeConsole();
  256. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  257. public static extern int GenerateConsoleCtrlEvent(
  258. [In] uint dwCtrlEvent,
  259. [In] uint dwProcessGroupId);
  260. [DllImport(ModuleName, SetLastError = true, CallingConvention = CallingConvention.Winapi), CLSCompliant(false)]
  261. public static extern uint GetConsoleAliasA(
  262. [In] IntPtr lpSource,
  263. [Out] IntPtr lpTargetBuffer,
  264. [In] uint TargetBufferLength,
  265. [In] IntPtr lpExeName);
  266. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Winapi), CLSCompliant(false)]
  267. public static extern uint GetConsoleAliasA(
  268. [In] string lpSource,
  269. [Out] StringBuilder lpTargetBuffer,
  270. [In] uint TargetBufferLength,
  271. [In] string lpExeName);
  272. [DllImport(ModuleName, SetLastError = true, CallingConvention = CallingConvention.Winapi), CLSCompliant(false)]
  273. public static extern uint GetConsoleAliasW(
  274. [In] IntPtr lpSource,
  275. [Out] IntPtr lpTargetBuffer,
  276. [In] uint TargetBufferLength,
  277. [In] IntPtr lpExeName);
  278. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Winapi), CLSCompliant(false)]
  279. public static extern uint GetConsoleAliasW(
  280. [In] string lpSource,
  281. [Out] StringBuilder lpTargetBuffer,
  282. [In] uint TargetBufferLength,
  283. [In] string lpExeName);
  284. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  285. public static extern uint GetConsoleAliasesA(
  286. [Out] IntPtr lpAliasBuffer,
  287. [In] uint AliasBufferLength,
  288. [In] IntPtr lpExeName);
  289. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Ansi), CLSCompliant(false)]
  290. public static extern uint GetConsoleAliasesA(
  291. [Out] IntPtr lpAliasBuffer,
  292. [In] uint AliasBufferLength,
  293. [In] string lpExeName);
  294. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  295. public static extern uint GetConsoleAliasesW(
  296. [Out] IntPtr lpAliasBuffer,
  297. [In] uint AliasBufferLength,
  298. [In] IntPtr lpExeName);
  299. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Unicode), CLSCompliant(false)]
  300. public static extern uint GetConsoleAliasesW(
  301. [Out] IntPtr lpAliasBuffer,
  302. [In] uint AliasBufferLength,
  303. [In] string lpExeName);
  304. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  305. public static extern uint GetConsoleAliasesLengthA(
  306. [In] IntPtr lpExeName);
  307. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Ansi), CLSCompliant(false)]
  308. public static extern uint GetConsoleAliasesLengthA(
  309. [In] string lpExeName);
  310. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  311. public static extern uint GetConsoleAliasesLengthW(
  312. [In] IntPtr lpExeName);
  313. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Unicode), CLSCompliant(false)]
  314. public static extern uint GetConsoleAliasesLengthW(
  315. [In] string lpExeName);
  316. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  317. public static extern uint GetConsoleAliasExesA(
  318. [Out] IntPtr lpExeNameBuffer,
  319. [In] uint ExeNameBufferLength);
  320. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Ansi), CLSCompliant(false)]
  321. public static extern uint GetConsoleAliasExesA(
  322. [Out] StringBuilder lpExeNameBuffer,
  323. [In] uint ExeNameBufferLength);
  324. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  325. public static extern uint GetConsoleAliasExesW(
  326. [Out] IntPtr lpExeNameBuffer,
  327. [In] uint ExeNameBufferLength);
  328. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Unicode), CLSCompliant(false)]
  329. public static extern uint GetConsoleAliasExesW(
  330. [Out] StringBuilder lpExeNameBuffer,
  331. [In] uint ExeNameBufferLength);
  332. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  333. public static extern uint GetConsoleAliasExesLength();
  334. [DllImport(ModuleName), CLSCompliant(false)]
  335. public static extern uint GetConsoleCP();
  336. [DllImport(ModuleName, SetLastError = true)]
  337. public static extern int GetConsoleCursorInfo(
  338. [In] IntPtr hConsoleOutput,
  339. [Out] IntPtr lpConsoleCursorInfo);
  340. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  341. public static extern int GetConsoleCursorInfo(
  342. [In] IntPtr hConsoleOutput,
  343. [Out] out CONSOLE_CURSOR_INFO lpConsoleCursorInfo);
  344. [DllImport(ModuleName, SetLastError = true)]
  345. public static extern int GetConsoleDisplayMode(
  346. [Out] IntPtr lpModeFlags);
  347. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  348. public static extern int GetConsoleDisplayMode(
  349. [Out] out uint lpModeFlags);
  350. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  351. public static extern COORD GetConsoleFontSize(
  352. [In] IntPtr hConsoleOutput,
  353. [In] uint nFont);
  354. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  355. public static extern int GetConsoleHistoryInfo(
  356. IntPtr lpConsoleHistoryInfo);
  357. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  358. public static extern int GetConsoleHistoryInfo(
  359. [Out] out CONSOLE_HISTORY_INFO lpConsoleHistoryInfo);
  360. [DllImport(ModuleName, SetLastError = true)]
  361. public static extern int GetConsoleMode(
  362. [In] IntPtr hConsoleOutput,
  363. [Out] IntPtr lpMode);
  364. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  365. public static extern int GetConsoleMode(
  366. [In] IntPtr hConsoleOutput,
  367. [Out] out uint lpMode);
  368. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  369. public static extern uint GetConsoleOriginalTitleA(
  370. [Out] IntPtr lpConsoleTitle,
  371. [In] uint nSize);
  372. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Ansi), CLSCompliant(false)]
  373. public static extern uint GetConsoleOriginalTitleA(
  374. [Out] StringBuilder lpConsoleTitle,
  375. [In] uint nSize);
  376. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  377. public static extern uint GetConsoleOriginalTitleW(
  378. [Out] IntPtr lpConsoleTitle,
  379. [In] uint nSize);
  380. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Unicode), CLSCompliant(false)]
  381. public static extern uint GetConsoleOriginalTitleW(
  382. [Out] StringBuilder lpConsoleTitle,
  383. [In] uint nSize);
  384. [DllImport(ModuleName), CLSCompliant(false)]
  385. public static extern uint GetConsoleOutputCP();
  386. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  387. public static extern uint GetConsoleProcessList(
  388. [Out] IntPtr lpdwProcessList,
  389. [In] uint dwProcessCount);
  390. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  391. public static extern uint GetConsoleProcessList(
  392. [Out] uint[] lpdwProcessList,
  393. [In] uint dwProcessCount);
  394. [DllImport(ModuleName, SetLastError = true)]
  395. public static extern int GetConsoleScreenBufferInfo(
  396. [In] IntPtr hConsoleOutput,
  397. [Out] IntPtr lpConsoleScreenBufferInfo);
  398. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  399. public static extern int GetConsoleScreenBufferInfo(
  400. [In] IntPtr hConsoleOutput,
  401. [Out] out CONSOLE_SCREEN_BUFFER_INFO lpConsoleScreenBufferInfo);
  402. [DllImport(ModuleName, SetLastError = true)]
  403. public static extern int GetConsoleScreenBufferInfoEx(
  404. [In] IntPtr hConsoleOutput,
  405. [Out] IntPtr lpConsoleScreenBufferInfoEx);
  406. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  407. public static extern int GetConsoleScreenBufferInfoEx(
  408. [In] IntPtr hConsoleOutput,
  409. [Out] out CONSOLE_SCREEN_BUFFER_INFOEX lpConsoleScreenBufferInfoEx);
  410. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  411. public static extern int GetConsoleSelectionInfo(
  412. [Out] IntPtr lpConsoleSelectionInfo);
  413. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  414. public static extern int GetConsoleSelectionInfo(
  415. [Out] out CONSOLE_SELECTION_INFO lpConsoleSelectionInfo);
  416. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  417. public static extern uint GetConsoleTitleA(
  418. [Out] IntPtr lpConsoleTitle,
  419. [In] uint nSize);
  420. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Ansi), CLSCompliant(false)]
  421. public static extern uint GetConsoleTitleA(
  422. [Out] StringBuilder lpConsoleTitle,
  423. [In] uint nSize);
  424. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  425. public static extern uint GetConsoleTitleW(
  426. [Out] IntPtr lpConsoleTitle,
  427. [In] uint nSize);
  428. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Unicode), CLSCompliant(false)]
  429. public static extern uint GetConsoleTitleW(
  430. [Out] StringBuilder lpConsoleTitle,
  431. [In] uint nSize);
  432. [DllImport(ModuleName, SetLastError = true)]
  433. public static extern IntPtr GetConsoleWindow();
  434. [DllImport(ModuleName, SetLastError = true)]
  435. public static extern int GetCurrentConsoleFont(
  436. [In] IntPtr hConsoleOutput,
  437. [In] int bMaximumWindow,
  438. [Out] IntPtr lpConsoleCurrentFont);
  439. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  440. public static extern int GetCurrentConsoleFont(
  441. [In] IntPtr hConsoleOutput,
  442. [In] int bMaximumWindow,
  443. [Out] out CONSOLE_FONT_INFO lpConsoleCurrentFont);
  444. [DllImport(ModuleName, SetLastError = true)]
  445. public static extern int GetCurrentConsoleFontEx(
  446. [In] IntPtr hConsoleOutput,
  447. [In] int bMaximumWindow,
  448. [Out] IntPtr lpConsoleCurrentFontEx);
  449. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Unicode), CLSCompliant(false)]
  450. public static extern int GetCurrentConsoleFontEx(
  451. [In] IntPtr hConsoleOutput,
  452. [In] int bMaximumWindow,
  453. [Out] out CONSOLE_FONT_INFOEX lpConsoleCurrentFontEx);
  454. [DllImport(ModuleName, SetLastError = true)]
  455. public static extern COORD GetLargestConsoleWindowSize(
  456. [In] IntPtr hConsoleOutput);
  457. [DllImport(ModuleName, SetLastError = true)]
  458. public static extern int GetNumberOfConsoleInputEvents(
  459. [In] IntPtr hConsoleInput,
  460. [Out] IntPtr lpcNumberOfEvents);
  461. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  462. public static extern int GetNumberOfConsoleInputEvents(
  463. [In] IntPtr hConsoleInput,
  464. [Out] out uint lpcNumberOfEvents);
  465. [DllImport(ModuleName, SetLastError = true)]
  466. public static extern int GetNumberOfConsoleMouseButtons(
  467. [In] IntPtr hNumberOfMouseButtons);
  468. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  469. public static extern int GetNumberOfConsoleMouseButtons(
  470. [Out] out uint lpNumberOfMouseButtons);
  471. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  472. public static extern IntPtr GetStdHandle(
  473. [In] uint nStdHandle);
  474. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Ansi), CLSCompliant(false)]
  475. public static extern int PeekConsoleInputA(
  476. [In] IntPtr hConsoleInput,
  477. [Out] IntPtr lpBuffer,
  478. [In] uint nLength,
  479. [Out] IntPtr lpNumberOfEventsRead);
  480. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Ansi), CLSCompliant(false)]
  481. public static extern int PeekConsoleInputA(
  482. [In] IntPtr hConsoleInput,
  483. [Out] out INPUT_RECORD lpBuffer,
  484. [In] uint nLength,
  485. [Out] out uint lpNumberOfEventsRead);
  486. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Unicode), CLSCompliant(false)]
  487. public static extern int PeekConsoleInputW(
  488. [In] IntPtr hConsoleInput,
  489. [Out] IntPtr lpBuffer,
  490. [In] uint nLength,
  491. [Out] IntPtr lpNumberOfEventsRead);
  492. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Unicode), CLSCompliant(false)]
  493. public static extern int PeekConsoleInputW(
  494. [In] IntPtr hConsoleInput,
  495. [Out] out INPUT_RECORD lpBuffer,
  496. [In] uint nLength,
  497. [Out] out uint lpNumberOfEventsRead);
  498. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Ansi), CLSCompliant(false)]
  499. public static extern int ReadConsoleA(
  500. [In] IntPtr hConsoleInput,
  501. [Out] IntPtr lpBuffer,
  502. [In] uint nNumberOfCharsToRead,
  503. [Out] IntPtr lpNumberOfCharsRead,
  504. [In] IntPtr lpReserved);
  505. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Ansi), CLSCompliant(false)]
  506. public static extern int ReadConsoleA(
  507. [In] IntPtr hConsoleInput,
  508. [Out] IntPtr lpBuffer,
  509. [In] uint nNumberOfCharsToRead,
  510. [Out] out uint lpNumberOfCharsRead,
  511. [In] IntPtr lpReserved);
  512. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Ansi), CLSCompliant(false)]
  513. public static extern int ReadConsoleA(
  514. [In] IntPtr hConsoleInput,
  515. [Out] IntPtr lpBuffer,
  516. [In] uint nNumberOfCharsToRead,
  517. [Out] IntPtr lpNumberOfCharsRead,
  518. [In] ref CONSOLE_READCONSOLE_CONTROL lpReserved);
  519. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Ansi), CLSCompliant(false)]
  520. public static extern int ReadConsoleA(
  521. [In] IntPtr hConsoleInput,
  522. [Out] IntPtr lpBuffer,
  523. [In] uint nNumberOfCharsToRead,
  524. [Out] out uint lpNumberOfCharsRead,
  525. [In] ref CONSOLE_READCONSOLE_CONTROL lpReserved);
  526. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Unicode), CLSCompliant(false)]
  527. public static extern int ReadConsoleW(
  528. [In] IntPtr hConsoleInput,
  529. [Out] IntPtr lpBuffer,
  530. [In] uint nNumberOfCharsToRead,
  531. [Out] IntPtr lpNumberOfCharsRead,
  532. [In] IntPtr lpReserved);
  533. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Unicode), CLSCompliant(false)]
  534. public static extern int ReadConsoleW(
  535. [In] IntPtr hConsoleInput,
  536. [Out] IntPtr lpBuffer,
  537. [In] uint nNumberOfCharsToRead,
  538. [Out] out uint lpNumberOfCharsRead,
  539. [In] IntPtr lpReserved);
  540. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Unicode), CLSCompliant(false)]
  541. public static extern int ReadConsoleW(
  542. [In] IntPtr hConsoleInput,
  543. [Out] IntPtr lpBuffer,
  544. [In] uint nNumberOfCharsToRead,
  545. [Out] IntPtr lpNumberOfCharsRead,
  546. [In] ref CONSOLE_READCONSOLE_CONTROL lpReserved);
  547. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Unicode), CLSCompliant(false)]
  548. public static extern int ReadConsoleW(
  549. [In] IntPtr hConsoleInput,
  550. [Out] IntPtr lpBuffer,
  551. [In] uint nNumberOfCharsToRead,
  552. [Out] out uint lpNumberOfCharsRead,
  553. [In] ref CONSOLE_READCONSOLE_CONTROL lpReserved);
  554. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Ansi), CLSCompliant(false)]
  555. public static extern int ReadConsoleInputA(
  556. [In] IntPtr hConsoleInput,
  557. [Out] IntPtr lpBuffer,
  558. [In] uint nLength,
  559. [Out] IntPtr lpNumberOfEventsRead);
  560. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Ansi), CLSCompliant(false)]
  561. public static extern int ReadConsoleInputA(
  562. [In] IntPtr hConsoleInput,
  563. [Out] out INPUT_RECORD lpBuffer,
  564. [In] uint nLength,
  565. [Out] out uint lpNumberOfEventsRead);
  566. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Unicode), CLSCompliant(false)]
  567. public static extern int ReadConsoleInputW(
  568. [In] IntPtr hConsoleInput,
  569. [Out] IntPtr lpBuffer,
  570. [In] uint nLength,
  571. [Out] IntPtr lpNumberOfEventsRead);
  572. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Unicode), CLSCompliant(false)]
  573. public static extern int ReadConsoleInputW(
  574. [In] IntPtr hConsoleInput,
  575. [Out] out INPUT_RECORD lpBuffer,
  576. [In] uint nLength,
  577. [Out] out uint lpNumberOfEventsRead);
  578. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Ansi)]
  579. public static extern int ReadConsoleOutputA(
  580. [In] IntPtr hConsoleOutput,
  581. [Out] IntPtr lpBuffer,
  582. [In] COORD dwBufferSize,
  583. [In] COORD dwBufferCoord,
  584. [In, Out] IntPtr lpReadRegion);
  585. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Ansi), CLSCompliant(false)]
  586. public static extern int ReadConsoleOutputA(
  587. [In] IntPtr hConsoleOutput,
  588. [Out] out CHAR_INFO lpBuffer,
  589. [In] COORD dwBufferSize,
  590. [In] COORD dwBufferCoord,
  591. [In, Out] ref SMALL_RECT lpReadRegion);
  592. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Unicode)]
  593. public static extern int ReadConsoleOutputW(
  594. [In] IntPtr hConsoleOutput,
  595. [Out] IntPtr lpBuffer,
  596. [In] COORD dwBufferSize,
  597. [In] COORD dwBufferCoord,
  598. [In, Out] IntPtr lpReadRegion);
  599. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Unicode), CLSCompliant(false)]
  600. public static extern int ReadConsoleOutputW(
  601. [In] IntPtr hConsoleOutput,
  602. [Out] out CHAR_INFO lpBuffer,
  603. [In] COORD dwBufferSize,
  604. [In] COORD dwBufferCoord,
  605. [In, Out] ref SMALL_RECT lpReadRegion);
  606. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  607. public static extern int ReadConsoleOutputAttribute(
  608. [In] IntPtr hConsoleOutput,
  609. [Out] IntPtr lpAttribute,
  610. [In] uint nLength,
  611. [In] COORD dwReadCoord,
  612. [Out] IntPtr lpNumberOfAttrsRead);
  613. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  614. public static extern int ReadConsoleOutputAttribute(
  615. [In] IntPtr hConsoleOutput,
  616. [Out] out uint lpAttribute,
  617. [In] uint nLength,
  618. [In] COORD dwReadCoord,
  619. [Out] out uint lpNumberOfAttrsRead);
  620. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Ansi), CLSCompliant(false)]
  621. public static extern int ReadConsoleOutputCharacterA(
  622. [In] IntPtr hConsoleOutput,
  623. [Out] IntPtr lpCharacter,
  624. [In] uint nLength,
  625. [In] COORD dwReadCoord,
  626. [Out] IntPtr lpNumberOfCharsRead);
  627. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Ansi), CLSCompliant(false)]
  628. public static extern int ReadConsoleOutputCharacterA(
  629. [In] IntPtr hConsoleOutput,
  630. [Out] StringBuilder lpCharacter,
  631. [In] uint nLength,
  632. [In] COORD dwReadCoord,
  633. [Out] out uint lpNumberOfCharsRead);
  634. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Unicode), CLSCompliant(false)]
  635. public static extern int ReadConsoleOutputCharacterW(
  636. [In] IntPtr hConsoleOutput,
  637. [Out] IntPtr lpCharacter,
  638. [In] uint nLength,
  639. [In] COORD dwReadCoord,
  640. [Out] IntPtr lpNumberOfCharsRead);
  641. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Unicode), CLSCompliant(false)]
  642. public static extern int ReadConsoleOutputCharacterW(
  643. [In] IntPtr hConsoleOutput,
  644. [Out] StringBuilder lpCharacter,
  645. [In] uint nLength,
  646. [In] COORD dwReadCoord,
  647. [Out] out uint lpNumberOfCharsRead);
  648. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Ansi)]
  649. public static extern int ScrollConsoleScreenBufferA(
  650. [In] IntPtr hConsoleOutput,
  651. [In] IntPtr lpScrollRectangle,
  652. [In] IntPtr lpClipRectangle,
  653. [In] COORD dwDestinationOrigin,
  654. [In] IntPtr lpFill);
  655. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Ansi), CLSCompliant(false)]
  656. public static extern int ScrollConsoleScreenBufferA(
  657. [In] IntPtr hConsoleOutput,
  658. [In] ref SMALL_RECT lpScrollRectangle,
  659. [In] ref SMALL_RECT lpClipRectangle,
  660. [In] COORD dwDestinationOrigin,
  661. [In] ref CHAR_INFO lpFill);
  662. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Unicode)]
  663. public static extern int ScrollConsoleScreenBufferW(
  664. [In] IntPtr hConsoleOutput,
  665. [In] IntPtr lpScrollRectangle,
  666. [In] IntPtr lpClipRectangle,
  667. [In] COORD dwDestinationOrigin,
  668. [In] IntPtr lpFill);
  669. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Unicode), CLSCompliant(false)]
  670. public static extern int ScrollConsoleScreenBufferW(
  671. [In] IntPtr hConsoleOutput,
  672. [In] ref SMALL_RECT lpScrollRectangle,
  673. [In] ref SMALL_RECT lpClipRectangle,
  674. [In] COORD dwDestinationOrigin,
  675. [In] ref CHAR_INFO lpFill);
  676. [DllImport(ModuleName, SetLastError = true)]
  677. public static extern int SetConsoleActiveScreenBuffer(
  678. [In] IntPtr hConsoleOutput);
  679. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  680. public static extern int SetConsoleCP(
  681. [In] uint wCodePageID);
  682. [DllImport(ModuleName, SetLastError = true)]
  683. public static extern int SetConsoleCtrlHandler(
  684. [In] IntPtr HandlerRoutine,
  685. [In] int Add);
  686. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  687. public static extern int SetConsoleCtrlHandler(
  688. [In] HandlerRoutine HandlerRoutine,
  689. [In] int Add);
  690. [DllImport(ModuleName, SetLastError = true)]
  691. public static extern int SetConsoleCursorInfo(
  692. [In] IntPtr hConsoleOutput,
  693. [In] IntPtr lpConsoleCursorInfo);
  694. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  695. public static extern int SetConsoleCursorInfo(
  696. [In] IntPtr hConsoleOutput,
  697. [In] ref CONSOLE_CURSOR_INFO lpConsoleCursorInfo);
  698. [DllImport(ModuleName, SetLastError = true)]
  699. public static extern int SetConsoleCursorPosition(
  700. [In] IntPtr hConsoleOutput,
  701. [In] COORD dwCursorPosition);
  702. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  703. public static extern int SetConsoleDisplayMode(
  704. [In] IntPtr hConsoleOutput,
  705. [In] uint dwFlags,
  706. [In] IntPtr lpNewScreenBufferDimensions);
  707. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  708. public static extern int SetConsoleDisplayMode(
  709. [In] IntPtr hConsoleOutput,
  710. [In] uint dwFlags,
  711. [In] ref COORD lpNewScreenBufferDimensions);
  712. [DllImport(ModuleName, SetLastError = true)]
  713. public static extern int SetConsoleHistoryInfo(
  714. [In] IntPtr lpConsoleHistoryInfo);
  715. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  716. public static extern int SetConsoleHistoryInfo(
  717. [In] ref CONSOLE_HISTORY_INFO lpConsoleHistoryInfo);
  718. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  719. public static extern int SetConsoleMode(
  720. [In] IntPtr hConsoleHandle,
  721. [In] uint dwMode);
  722. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  723. public static extern int SetConsoleOutputCP(
  724. [In] uint wCodePageId);
  725. [DllImport(ModuleName, SetLastError = true)]
  726. public static extern int SetConsoleScreenBufferInfoEx(
  727. [In] IntPtr hConsoleOutput,
  728. [In] IntPtr lpConsoleScreenBufferInfoEx);
  729. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  730. public static extern int SetConsoleScreenBufferInfoEx(
  731. [In] IntPtr hConsoleOutput,
  732. [In] ref CONSOLE_SCREEN_BUFFER_INFOEX lpConsoleScreenBufferInfoEx);
  733. [DllImport(ModuleName, SetLastError = true)]
  734. public static extern int SetConsoleScreenBufferSize(
  735. [In] IntPtr hConsoleOutput,
  736. [In] COORD dwSize);
  737. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  738. public static extern int SetConsoleTextAttributes(
  739. [In] IntPtr hConsoleOutput,
  740. [In] ushort wAttributes);
  741. [DllImport(ModuleName, SetLastError = true)]
  742. public static extern int SetConsoleTitleA(
  743. [In] IntPtr lpConsoleTitle);
  744. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Ansi)]
  745. public static extern int SetConsoleTitleA(
  746. [In] string lpConsoleTitle);
  747. [DllImport(ModuleName, SetLastError = true)]
  748. public static extern int SetConsoleTitleW(
  749. [In] IntPtr lpConsoleTitle);
  750. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Unicode)]
  751. public static extern int SetConsoleTitleW(
  752. [In] string lpConsoleTitle);
  753. [DllImport(ModuleName, SetLastError = true)]
  754. public static extern int SetConsoleWindowInfo(
  755. [In] IntPtr hConsoleOutput,
  756. [In] int bAbsolute,
  757. [In] IntPtr lpConsoleWindow);
  758. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  759. public static extern int SetConsoleWindowInfo(
  760. [In] IntPtr hConsoleOutput,
  761. [In] int bAbsolute,
  762. [In] ref SMALL_RECT lpConsoleWindow);
  763. [DllImport(ModuleName, SetLastError = true)]
  764. public static extern int SetCurrentConsoleFontEx(
  765. [In] IntPtr hConsoleOutput,
  766. [In] int bMaximumWindow,
  767. [In] IntPtr lpConsoleCurrentFontEx);
  768. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  769. public static extern int SetCurrentConsoleFontEx(
  770. [In] IntPtr hConsoleOutput,
  771. [In] int bMaximumWindow,
  772. [In] ref CONSOLE_FONT_INFOEX lpConsoleCurrentFontEx);
  773. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  774. public static extern int SetStdHandle(
  775. [In] uint nStdHandle,
  776. [In] IntPtr hHandle);
  777. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Ansi), CLSCompliant(false)]
  778. public static extern int WriteConsoleA(
  779. [In] IntPtr hConsoleOutput,
  780. [In] IntPtr lpBuffer,
  781. [In] uint nNumberOfCharsToWrite,
  782. [Out] IntPtr lpNumberOfCharsWritten,
  783. IntPtr lpReserved);
  784. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Ansi), CLSCompliant(false)]
  785. public static extern int WriteConsoleA(
  786. [In] IntPtr hConsoleOutput,
  787. [In] IntPtr lpBuffer,
  788. [In] uint nNumberOfCharsToWrite,
  789. [Out] out uint lpNumberOfCharsWritten,
  790. IntPtr lpReserved);
  791. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Unicode), CLSCompliant(false)]
  792. public static extern int WriteConsoleW(
  793. [In] IntPtr hConsoleOutput,
  794. [In] IntPtr lpBuffer,
  795. [In] uint nNumberOfCharsToWrite,
  796. [Out] IntPtr lpNumberOfCharsWritten,
  797. IntPtr lpReserved);
  798. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Unicode), CLSCompliant(false)]
  799. public static extern int WriteConsoleW(
  800. [In] IntPtr hConsoleOutput,
  801. [In] IntPtr lpBuffer,
  802. [In] uint nNumberOfCharsToWrite,
  803. [Out] out uint lpNumberOfCharsWritten,
  804. IntPtr lpReserved);
  805. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Ansi), CLSCompliant(false)]
  806. public static extern int WriteConsoleInputA(
  807. [In] IntPtr hConsoleInput,
  808. [In] IntPtr lpBuffer,
  809. [In] uint nLength,
  810. [Out] IntPtr lpNumberOfEvnetsWritten);
  811. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Ansi), CLSCompliant(false)]
  812. public static extern int WriteConsoleInputA(
  813. [In] IntPtr hConsoleInput,
  814. [In] IntPtr lpBuffer,
  815. [In] uint nLength,
  816. [Out] out uint lpNumberOfEvnetsWritten);
  817. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Unicode), CLSCompliant(false)]
  818. public static extern int WriteConsoleInputW(
  819. [In] IntPtr hConsoleInput,
  820. [In] IntPtr lpBuffer,
  821. [In] uint nLength,
  822. [Out] IntPtr lpNumberOfEvnetsWritten);
  823. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Unicode), CLSCompliant(false)]
  824. public static extern int WriteConsoleInputW(
  825. [In] IntPtr hConsoleInput,
  826. [In] IntPtr lpBuffer,
  827. [In] uint nLength,
  828. [Out] out uint lpNumberOfEvnetsWritten);
  829. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Ansi)]
  830. public static extern int WriteConsoleOutputA(
  831. [In] IntPtr hConsoleOutput,
  832. [In] IntPtr lpBuffer,
  833. [In] COORD dwBufferSize,
  834. [In] COORD dwBufferCoord,
  835. [In, Out] IntPtr lpWriteRegion);
  836. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Ansi), CLSCompliant(false)]
  837. public static extern int WriteConsoleOutputA(
  838. [In] IntPtr hConsoleOutput,
  839. [In] ref CHAR_INFO lpBuffer,
  840. [In] COORD dwBufferSize,
  841. [In] COORD dwBufferCoord,
  842. [In, Out] ref SMALL_RECT lpWriteRegion);
  843. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Unicode)]
  844. public static extern int WriteConsoleOutputW(
  845. [In] IntPtr hConsoleOutput,
  846. [In] IntPtr lpBuffer,
  847. [In] COORD dwBufferSize,
  848. [In] COORD dwBufferCoord,
  849. [In, Out] IntPtr lpWriteRegion);
  850. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Unicode), CLSCompliant(false)]
  851. public static extern int WriteConsoleOutputW(
  852. [In] IntPtr hConsoleOutput,
  853. [In] ref CHAR_INFO lpBuffer,
  854. [In] COORD dwBufferSize,
  855. [In] COORD dwBufferCoord,
  856. [In, Out] ref SMALL_RECT lpWriteRegion);
  857. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  858. public static extern int WriteConsoleOutputAttribute(
  859. [In] IntPtr hConsoleOutput,
  860. [In] IntPtr lpAttribute,
  861. [In] uint nLength,
  862. [In] COORD dwWriteCoord,
  863. [Out] IntPtr lpNumberOfAttrsWritten);
  864. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  865. public static extern int WriteConsoleOutputAttribute(
  866. [In] IntPtr hConsoleOutput,
  867. [In] ref ushort lpAttribute,
  868. [In] uint nLength,
  869. [In] COORD dwWriteCoord,
  870. [Out] out uint lpNumberOfAttrsWritten);
  871. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Ansi), CLSCompliant(false)]
  872. public static extern int WriteConsoleOutputCharacterA(
  873. [In] IntPtr hConsoleOutput,
  874. [In] IntPtr lpCharacter,
  875. [In] uint nLength,
  876. [In] COORD dwWriteCoord,
  877. [Out] IntPtr lpNumberOfCharsWritten);
  878. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Ansi), CLSCompliant(false)]
  879. public static extern int WriteConsoleOutputCharacterA(
  880. [In] IntPtr hConsoleOutput,
  881. [In] string lpCharacter,
  882. [In] uint nLength,
  883. [In] COORD dwWriteCoord,
  884. [Out] out uint lpNumberOfCharsWritten);
  885. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Unicode), CLSCompliant(false)]
  886. public static extern int WriteConsoleOutputCharacterW(
  887. [In] IntPtr hConsoleOutput,
  888. [In] IntPtr lpCharacter,
  889. [In] uint nLength,
  890. [In] COORD dwWriteCoord,
  891. [Out] IntPtr lpNumberOfCharsWritten);
  892. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Unicode), CLSCompliant(false)]
  893. public static extern int WriteConsoleOutputCharacterW(
  894. [In] IntPtr hConsoleOutput,
  895. [In] string lpCharacter,
  896. [In] uint nLength,
  897. [In] COORD dwWriteCoord,
  898. [Out] out uint lpNumberOfCharsWritten);
  899. }
  900. #endregion // Console functions
  901. #region Dynamic link library functions
  902. partial class kernel32
  903. {
  904. [DllImport(ModuleName, SetLastError = true)]
  905. public static extern int DisableThreadLibraryCalls(
  906. [In] IntPtr hModule);
  907. [DllImport(ModuleName, SetLastError = true)]
  908. public static extern int FreeLibrary(
  909. [In] IntPtr hModule);
  910. [DllImport(ModuleName)]
  911. public static extern void FreeLibraryAndExitThread(
  912. [In] IntPtr hModule,
  913. [In] int dwExitCode);
  914. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  915. public static extern uint GetDllDirectoryA(
  916. [In] uint nBufferLength,
  917. [Out] IntPtr lpBuffer);
  918. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Ansi), CLSCompliant(false)]
  919. public static extern uint GetDllDirectoryA(
  920. [In] uint nBufferLength,
  921. [Out] StringBuilder lpBuffer);
  922. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  923. public static extern uint GetDllDirectoryW(
  924. [In] uint nBufferLength,
  925. [Out] IntPtr lpBuffer);
  926. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Unicode), CLSCompliant(false)]
  927. public static extern uint GetDllDirectoryW(
  928. [In] uint nBufferLength,
  929. [Out] StringBuilder lpBuffer);
  930. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  931. public static extern uint GetModuleFileNameA(
  932. [In] IntPtr hModule,
  933. [Out] IntPtr lpFileName,
  934. [In] uint nSize);
  935. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Ansi), CLSCompliant(false)]
  936. public static extern uint GetModuleFileNameA(
  937. [In] IntPtr hModule,
  938. [Out] StringBuilder lpFileName,
  939. [In] uint nSize);
  940. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  941. public static extern uint GetModuleFileNameW(
  942. [In] IntPtr hModule,
  943. [Out] IntPtr lpFileName,
  944. [In] uint nSize);
  945. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Unicode), CLSCompliant(false)]
  946. public static extern uint GetModuleFileNameW(
  947. [In] IntPtr hModule,
  948. [Out] StringBuilder lpFileName,
  949. [In] uint nSize);
  950. [DllImport(ModuleName, SetLastError = true)]
  951. public static extern IntPtr GetModuleHandleA(
  952. [In] IntPtr lpModuleName);
  953. [DllImport(ModuleName, CharSet = CharSet.Ansi, SetLastError = true)]
  954. public static extern IntPtr GetModuleHandleA(
  955. [In] string lpModuleName);
  956. [DllImport(ModuleName, SetLastError = true)]
  957. public static extern IntPtr GetModuleHandleW(
  958. [In] IntPtr lpModuleName);
  959. [DllImport(ModuleName, CharSet = CharSet.Unicode, SetLastError = true)]
  960. public static extern IntPtr GetModuleHandleW(
  961. [In] string lpModuleName);
  962. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  963. public static extern IntPtr GetModuleHandleExA(
  964. [In] uint dwFlags,
  965. [In] IntPtr lpModuleName,
  966. [Out] IntPtr phModule);
  967. [DllImport(ModuleName, CharSet = CharSet.Ansi, SetLastError = true), CLSCompliant(false)]
  968. public static extern IntPtr GetModuleHandleExA(
  969. [In] uint dwFlags,
  970. [In] string lpModuleName,
  971. [Out] out IntPtr phModule);
  972. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  973. public static extern IntPtr GetModuleHandleExW(
  974. [In] uint dwFlags,
  975. [In] IntPtr lpModuleName,
  976. [Out] IntPtr phModule);
  977. [DllImport(ModuleName, CharSet = CharSet.Unicode, SetLastError = true), CLSCompliant(false)]
  978. public static extern IntPtr GetModuleHandleExW(
  979. [In] uint dwFlags,
  980. [In] string lpModuleName,
  981. [Out] out IntPtr phModule);
  982. [DllImport(ModuleName, SetLastError = true)]
  983. public static extern IntPtr GetProcAddressA(
  984. [In] IntPtr hModule,
  985. [In] IntPtr lpProcName);
  986. [DllImport(ModuleName, CharSet = CharSet.Ansi, SetLastError = true)]
  987. public static extern IntPtr GetProcAddressA(
  988. [In] IntPtr hModule,
  989. [In] string lpProcName);
  990. [DllImport(ModuleName, SetLastError = true)]
  991. public static extern IntPtr GetProcAddressW(
  992. [In] IntPtr hModule,
  993. [In] IntPtr lpProcName);
  994. [DllImport(ModuleName, CharSet = CharSet.Unicode, SetLastError = true)]
  995. public static extern IntPtr GetProcAddressW(
  996. [In] IntPtr hModule,
  997. [In] string lpProcName);
  998. [DllImport(ModuleName, SetLastError = true)]
  999. public static extern IntPtr LoadLibraryA(
  1000. [In] IntPtr lpFileName);
  1001. [DllImport(ModuleName, CharSet = CharSet.Ansi, SetLastError = true)]
  1002. public static extern IntPtr LoadLibraryA(
  1003. [In] string lpFileName);
  1004. [DllImport(ModuleName, SetLastError = true)]
  1005. public static extern IntPtr LoadLibraryW(
  1006. [In] IntPtr lpFileName);
  1007. [DllImport(ModuleName, CharSet = CharSet.Unicode, SetLastError = true)]
  1008. public static extern IntPtr LoadLibraryW(
  1009. [In] string lpFileName);
  1010. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1011. public static extern IntPtr LoadLibraryExA(
  1012. [In] IntPtr lpFileName,
  1013. IntPtr hFile,
  1014. [In] uint dwFlags);
  1015. [DllImport(ModuleName, CharSet = CharSet.Ansi, SetLastError = true), CLSCompliant(false)]
  1016. public static extern IntPtr LoadLibraryExA(
  1017. [In] string lpFileName,
  1018. IntPtr hFile,
  1019. [In] uint dwFlags);
  1020. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1021. public static extern IntPtr LoadLibraryExW(
  1022. [In] IntPtr lpFileName,
  1023. IntPtr hFile,
  1024. [In] uint dwFlags);
  1025. [DllImport(ModuleName, CharSet = CharSet.Unicode, SetLastError = true), CLSCompliant(false)]
  1026. public static extern IntPtr LoadLibraryExW(
  1027. [In] string lpFileName,
  1028. IntPtr hFile,
  1029. [In] uint dwFlags);
  1030. }
  1031. #endregion // Dynamic link library functions
  1032. #region Asynchronous functions
  1033. partial class kernel32
  1034. {
  1035. [DllImport(ModuleName, SetLastError = true)]
  1036. public static extern int GetOverlappedResult(IntPtr hFile, IntPtr lpOverlapped, IntPtr lpNumberOfBytesTransferred, int bWait);
  1037. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1038. public static extern int GetOverlappedResult(IntPtr hFile, ref OVERLAPPED lpOverlapped, ref uint lpNumberOfBytesTransferred, int bWait);
  1039. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1040. public static extern uint QueueUserAPC(IntPtr pfnAPC, IntPtr hThread, uint dwData);
  1041. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1042. public static extern uint QueueUserAPC(APCProc pfnAPC, IntPtr hThread, uint dwData);
  1043. }
  1044. #endregion // Asynchronous functions
  1045. #region Critical section functions
  1046. partial class kernel32
  1047. {
  1048. [DllImport(ModuleName)]
  1049. public static extern void DeleteCriticalSection(IntPtr lpCriticalSection);
  1050. [DllImport(ModuleName), CLSCompliant(false)]
  1051. public static extern void DeleteCriticalSection(ref RTL_CRITICAL_SECTION lpCriticalSection);
  1052. [DllImport(ModuleName)]
  1053. public static extern void EnterCriticalSection(IntPtr lpCriticalSection);
  1054. [DllImport(ModuleName), CLSCompliant(false)]
  1055. public static extern void EnterCriticalSection(ref RTL_CRITICAL_SECTION lpCriticalSection);
  1056. [DllImport(ModuleName)]
  1057. public static extern void InitializeCriticalSection(IntPtr lpCriticalSection);
  1058. [DllImport(ModuleName), CLSCompliant(false)]
  1059. public static extern void InitializeCriticalSection(ref RTL_CRITICAL_SECTION lpCriticalSection);
  1060. [DllImport(ModuleName), CLSCompliant(false)]
  1061. public static extern void InitializeCriticalSectionAndSpinCount(IntPtr lpCriticalSection, uint dwSpinCount);
  1062. [DllImport(ModuleName), CLSCompliant(false)]
  1063. public static extern void InitializeCriticalSectionAndSpinCount(ref RTL_CRITICAL_SECTION lpCriticalSection, uint dwSpinCount);
  1064. [DllImport(ModuleName)]
  1065. public static extern void LeaveCriticalSection(IntPtr lpCriticalSection);
  1066. [DllImport(ModuleName), CLSCompliant(false)]
  1067. public static extern void LeaveCriticalSection(ref RTL_CRITICAL_SECTION lpCriticalSection);
  1068. [DllImport(ModuleName), CLSCompliant(false)]
  1069. public static extern void SetCriticalSectionAndSpinCount(IntPtr lpCriticalSection, uint dwSpinCount);
  1070. [DllImport(ModuleName), CLSCompliant(false)]
  1071. public static extern void SetCriticalSectionAndSpinCount(ref RTL_CRITICAL_SECTION lpCriticalSection, uint dwSpinCount);
  1072. [DllImport(ModuleName)]
  1073. public static extern int TryEnterCriticalSection(IntPtr lpCriticalSection);
  1074. [DllImport(ModuleName), CLSCompliant(false)]
  1075. public static extern int TryEnterCriticalSection(ref RTL_CRITICAL_SECTION lpCriticalSection);
  1076. }
  1077. #endregion // Critical section functions
  1078. #region Event functions
  1079. partial class kernel32
  1080. {
  1081. [DllImport(ModuleName, SetLastError = true)]
  1082. public static extern IntPtr CreateEventA(IntPtr lpEventAttributes, int bManualReset, int bInitialState, IntPtr lpName);
  1083. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Ansi), CLSCompliant(false)]
  1084. public static extern IntPtr CreateEventA(ref SECURITY_ATTRIBUTES lpEventAttributes, int bManualReset, int bInitialState, string lpName);
  1085. [DllImport(ModuleName, SetLastError = true)]
  1086. public static extern IntPtr CreateEventW(IntPtr lpEventAttributes, int bManualReset, int bInitialState, IntPtr lpName);
  1087. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Unicode), CLSCompliant(false)]
  1088. public static extern IntPtr CreateEventW(ref SECURITY_ATTRIBUTES lpEventAttributes, int bManualReset, int bInitialState, string lpName);
  1089. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1090. public static extern IntPtr OpenEventA(uint dwDesiredAccess, int bInheritHandle, IntPtr lpName);
  1091. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Ansi), CLSCompliant(false)]
  1092. public static extern IntPtr OpenEventA(uint dwDesiredAccess, int bInheritHandle, string lpName);
  1093. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1094. public static extern IntPtr OpenEventW(uint dwDesiredAccess, int bInheritHandle, IntPtr lpName);
  1095. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Unicode), CLSCompliant(false)]
  1096. public static extern IntPtr OpenEventW(uint dwDesiredAccess, int bInheritHandle, string lpName);
  1097. [DllImport(ModuleName, SetLastError = true)]
  1098. public static extern int PulseEvent(IntPtr hEvent);
  1099. [DllImport(ModuleName, SetLastError = true)]
  1100. public static extern int ResetEvent(IntPtr hEvent);
  1101. [DllImport(ModuleName, SetLastError = true)]
  1102. public static extern int SetEvent(IntPtr hEvent);
  1103. }
  1104. #endregion // Event functions
  1105. #region Interlocked functions
  1106. partial class kernel32
  1107. {
  1108. [DllImport(ModuleName)]
  1109. public static extern int InterlockedCompareExchange(IntPtr Destination, int Exchange, int Comperand);
  1110. [DllImport(ModuleName)]
  1111. public static extern int InterlockedCompareExchange(ref int Destination, int Exchange, int Comperand);
  1112. [DllImport(ModuleName)]
  1113. public static extern IntPtr InterlockedCompareExchangePointer(IntPtr Destination, IntPtr Exchange, IntPtr Comperand);
  1114. [DllImport(ModuleName), CLSCompliant(false)]
  1115. public static extern IntPtr InterlockedCompareExchangePointer(ref IntPtr Destination, IntPtr Exchange, IntPtr Comperand);
  1116. [DllImport(ModuleName)]
  1117. public static extern int InterlockedDecrement(IntPtr lpAppend);
  1118. [DllImport(ModuleName)]
  1119. public static extern int InterlockedDecrement(ref int lpAppend);
  1120. [DllImport(ModuleName)]
  1121. public static extern int InterlockedExchange(IntPtr Target, int Value);
  1122. [DllImport(ModuleName)]
  1123. public static extern int InterlockedExchange(ref int Target, int Value);
  1124. [DllImport(ModuleName)]
  1125. public static extern int InterlockedExchangeAdd(IntPtr Addend, int Value);
  1126. [DllImport(ModuleName)]
  1127. public static extern int InterlockedExchangeAdd(ref int Addend, int Value);
  1128. [DllImport(ModuleName)]
  1129. public static extern IntPtr InterlockedExchangePointer(IntPtr Destination, IntPtr Value);
  1130. [DllImport(ModuleName), CLSCompliant(false)]
  1131. public static extern IntPtr InterlockedExchangePointer(ref IntPtr Destination, IntPtr Value);
  1132. [DllImport(ModuleName)]
  1133. public static extern int InterlockedIncrement(IntPtr lpAppend);
  1134. [DllImport(ModuleName)]
  1135. public static extern int InterlockedIncrement(ref int lpAppend);
  1136. }
  1137. #endregion // Interlocked functions
  1138. #region Mutex functions
  1139. partial class kernel32
  1140. {
  1141. [DllImport(ModuleName, SetLastError = true)]
  1142. public static extern IntPtr CreateMutexA(IntPtr lpMutexAttributes, int bInitialOwner, IntPtr lpName);
  1143. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Ansi), CLSCompliant(false)]
  1144. public static extern IntPtr CreateMutexA(ref SECURITY_ATTRIBUTES lpMutexAttributes, int bInitialOwner, string lpName);
  1145. [DllImport(ModuleName, SetLastError = true)]
  1146. public static extern IntPtr CreateMutexW(IntPtr lpMutexAttributes, int bInitialOwner, IntPtr lpName);
  1147. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Unicode), CLSCompliant(false)]
  1148. public static extern IntPtr CreateMutexW(ref SECURITY_ATTRIBUTES lpMutexAttributes, int bInitialOwner, string lpName);
  1149. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1150. public static extern IntPtr OpenMutexA(uint dwDesiredAccess, int bInheritHandle, IntPtr lpName);
  1151. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Ansi), CLSCompliant(false)]
  1152. public static extern IntPtr OpenMutexA(uint dwDesiredAccess, int bInheritHandle, string lpName);
  1153. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1154. public static extern IntPtr OpenMutexW(uint dwDesiredAccess, int bInheritHandle, IntPtr lpName);
  1155. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Unicode), CLSCompliant(false)]
  1156. public static extern IntPtr OpenMutexW(uint dwDesiredAccess, int bInheritHandle, string lpName);
  1157. [DllImport(ModuleName, SetLastError = true)]
  1158. public static extern int ReleaseMutex(IntPtr hMutex);
  1159. }
  1160. #endregion // Mutex functions
  1161. #region Semaphore functions
  1162. partial class kernel32
  1163. {
  1164. [DllImport(ModuleName, SetLastError = true)]
  1165. public static extern IntPtr CreateSemaphoreA(IntPtr lpSemaphoreAttributes, int lInitialCount, int lMaximumCount, IntPtr lpName);
  1166. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Ansi), CLSCompliant(false)]
  1167. public static extern IntPtr CreateSemaphoreA(ref SECURITY_ATTRIBUTES lpSemaphoreAttributes, int lInitialCount, int lMaximumCount, string lpName);
  1168. [DllImport(ModuleName, SetLastError = true)]
  1169. public static extern IntPtr CreateSemaphoreW(IntPtr lpSemaphoreAttributes, int lInitialCount, int lMaximumCount, IntPtr lpName);
  1170. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Unicode), CLSCompliant(false)]
  1171. public static extern IntPtr CreateSemaphoreW(ref SECURITY_ATTRIBUTES lpSemaphoreAttributes, int lInitialCount, int lMaximumCount, string lpName);
  1172. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1173. public static extern IntPtr OpenSemaphoreA(uint dwDesiredAccess, int bInheritHandle, IntPtr lpName);
  1174. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Ansi), CLSCompliant(false)]
  1175. public static extern IntPtr OpenSemaphoreA(uint dwDesiredAccess, int bInheritHandle, string lpName);
  1176. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1177. public static extern IntPtr OpenSemaphoreW(uint dwDesiredAccess, int bInheritHandle, IntPtr lpName);
  1178. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Unicode), CLSCompliant(false)]
  1179. public static extern IntPtr OpenSemaphoreW(uint dwDesiredAccess, int bInheritHandle, string lpName);
  1180. [DllImport(ModuleName, SetLastError = true)]
  1181. public static extern int ReleaseSemaphore(IntPtr hSemaphore, int lReleaseCount, IntPtr lpPreviousCount);
  1182. [DllImport(ModuleName, SetLastError = true)]
  1183. public static extern int ReleaseSemaphore(IntPtr hSemaphore, int lReleaseCount, ref int lpPreviousCount);
  1184. }
  1185. #endregion // Semaphore functions
  1186. #region Timer-Queue timer functions
  1187. partial class kernel32
  1188. {
  1189. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1190. public static extern int ChangeTimerQueueTimer(IntPtr TimerQueue, IntPtr Timer, uint DueTime, uint Period);
  1191. [DllImport(ModuleName, SetLastError = true)]
  1192. public static extern IntPtr CreateTimerQueue();
  1193. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1194. public static extern int CreateTimerQueueTimer(IntPtr phNewTimer, IntPtr TimerQueue, IntPtr Callback, IntPtr Parameter, uint DueTime, uint Period, uint Flags);
  1195. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1196. public static extern int CreateTimerQueueTimer(ref IntPtr phNewTimer, IntPtr TimerQueue, WaitOrTimerCallback Callback, IntPtr Parameter, uint DueTime, uint Period, uint Flags);
  1197. [DllImport(ModuleName, SetLastError = true)]
  1198. public static extern int DeleteTimerQueue(IntPtr TimerQueue);
  1199. [DllImport(ModuleName, SetLastError = true)]
  1200. public static extern int DeleteTimerQueue(IntPtr TimerQueue, IntPtr CompletionEvent);
  1201. [DllImport(ModuleName, SetLastError = true)]
  1202. public static extern int DeleteTimerQueueTimer(IntPtr TimerQueue, IntPtr Timer, IntPtr CompletionEvent);
  1203. }
  1204. #endregion // Timer-Queue timer functions
  1205. #region Wait functions
  1206. partial class kernel32
  1207. {
  1208. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1209. public static extern uint MsgWaitForMultipleObjects(uint nCount, IntPtr pHandles, int bWaitAll, uint dwMilliseconds, uint dwWakeMask);
  1210. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1211. public static extern uint MsgWaitForMultipleObjects(uint nCount, IntPtr[] pHandles, int bWaitAll, uint dwMilliseconds, uint dwWakeMask);
  1212. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1213. public static extern uint MsgWaitForMultipleObjectsEx(uint nCount, IntPtr pHandles, uint dwMilliseconds, uint dwWakeMask, uint dwFlags);
  1214. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1215. public static extern uint MsgWaitForMultipleObjectsEx(uint nCount, IntPtr[] pHandles, uint dwMilliseconds, uint dwWakeMask, uint dwFlags);
  1216. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1217. public static extern int RegisterWaitForSingleObject(IntPtr phNewWaitObject, IntPtr hObject, IntPtr Callback, IntPtr Context, uint dwMilliseconds, uint dwFlags);
  1218. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1219. public static extern int RegisterWaitForSingleObject(ref IntPtr phNewWaitObject, IntPtr hObject, WaitOrTimerCallback Callback, IntPtr Context, uint dwMilliseconds, uint dwFlags);
  1220. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1221. public static extern uint SignalObjectAndWait(IntPtr hObjectToSignal, IntPtr hObjectToWaitOn, uint dwMilliseconds, int bAlertable);
  1222. [DllImport(ModuleName, SetLastError = true)]
  1223. public static extern int UnregisterWait(IntPtr WaitHandle);
  1224. [DllImport(ModuleName, SetLastError = true)]
  1225. public static extern int UnregisterWaitEx(IntPtr WaitHandle, IntPtr CompletionEvent);
  1226. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1227. public static extern uint WaitForMultipleObjects(uint nCount, IntPtr lpHandles, int bWaitAll, uint dwMilliseconds);
  1228. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1229. public static extern uint WaitForMultipleObjects(uint nCount, IntPtr[] lpHandles, int bWaitAll, uint dwMilliseconds);
  1230. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1231. public static extern uint WaitForMultipleObjectsEx(uint nCount, IntPtr lpHandles, int bWaitAll, uint dwMilliseconds, int bAlertable);
  1232. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1233. public static extern uint WaitForMultipleObjectsEx(uint nCount, IntPtr[] lpHandles, int bWaitAll, uint dwMilliseconds, int bAlertable);
  1234. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1235. public static extern int WaitForSingleObject(IntPtr hHandle, uint dwMilliseconds);
  1236. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1237. public static extern int WaitForSingleObjectEx(IntPtr hHandle, uint dwMilliseconds, int bAlertable);
  1238. }
  1239. #endregion // Wait functions
  1240. #region Waitable timer functions
  1241. partial class kernel32
  1242. {
  1243. [DllImport(ModuleName, SetLastError = true)]
  1244. public static extern int CancelWaitableTimer(IntPtr hTimer);
  1245. [DllImport(ModuleName, SetLastError = true)]
  1246. public static extern IntPtr CreateWaitableTimerA(IntPtr lpTimerAttributes, int bManualReset, IntPtr lpTimerName);
  1247. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Ansi), CLSCompliant(false)]
  1248. public static extern IntPtr CreateWaitableTimerA(ref SECURITY_ATTRIBUTES lpTimerAttributes, int bManualReset, string lpTimerName);
  1249. [DllImport(ModuleName, SetLastError = true)]
  1250. public static extern IntPtr CreateWaitableTimerW(IntPtr lpTimerAttributes, int bManualReset, IntPtr lpTimerName);
  1251. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Unicode), CLSCompliant(false)]
  1252. public static extern IntPtr CreateWaitableTimerW(ref SECURITY_ATTRIBUTES lpTimerAttributes, int bManualReset, string lpTimerName);
  1253. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1254. public static extern IntPtr OpenWaitableTimerA(uint dwDesiredAccess, int bInheritHandle, IntPtr lpTimerName);
  1255. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Ansi), CLSCompliant(false)]
  1256. public static extern IntPtr OpenWaitableTimerA(uint dwDesiredAccess, int bInheritHandle, string lpTimerName);
  1257. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1258. public static extern IntPtr OpenWaitableTimerW(uint dwDesiredAccess, int bInheritHandle, IntPtr lpTimerName);
  1259. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Unicode), CLSCompliant(false)]
  1260. public static extern IntPtr OpenWaitableTimerW(uint dwDesiredAccess, int bInheritHandle, string lpTimerName);
  1261. [DllImport(ModuleName, SetLastError = true)]
  1262. public static extern int SetWaitableTimer(IntPtr hTimer, IntPtr pDueTime, int lPeriod, IntPtr pfnCompletionRoutine, IntPtr lpArgToCompletionRoutine, int fResume);
  1263. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1264. public static extern int SetWaitableTimer(IntPtr hTimer, ref LARGE_INTEGER pDueTime, int lPeriod, TimerAPCProc pfnCompletionRoutine, IntPtr lpArgToCompletionRoutine, int fResume);
  1265. }
  1266. #endregion // Waitable timer functions
  1267. #region File I/O functions
  1268. partial class kernel32
  1269. {
  1270. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1271. [Obsolete("This function is provided only for compatibility with 16-bit versions of Windows. Use 'ReadFile' function instead.", false)]
  1272. public static extern int _hread(IntPtr hFile, IntPtr lpBuffer, int lBytes);
  1273. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1274. [Obsolete("This function is provided only for compatibility with 16-bit versions of Windows. Use 'WriteFile' function instead.", false)]
  1275. public static extern int _hwrite(IntPtr hFile, IntPtr lpBuffer, int lBytes);
  1276. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Ansi), CLSCompliant(false)]
  1277. [Obsolete("This function is provided only for compatibility with 16-bit versions of Windows. Use 'WriteFile' function instead.", false)]
  1278. public static extern int _hwrite(IntPtr hFile, string lpBuffer, int lBytes);
  1279. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1280. [Obsolete("This function is provided only for compatibility with 16-bit versions of Windows. Use 'CloseHandle' function instead.", false)]
  1281. public static extern IntPtr _lclose(IntPtr hFile);
  1282. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1283. [Obsolete("This function is provided only for compatibility with 16-bit versions of Windows. Use 'CreateFile' function instead.", false)]
  1284. public static extern IntPtr _lcreat(IntPtr lpPathName, int iAttribute);
  1285. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Ansi), CLSCompliant(false)]
  1286. [Obsolete("This function is provided only for compatibility with 16-bit versions of Windows. Use 'CreateFile' function instead.", false)]
  1287. public static extern IntPtr _lcreat(string lpPathName, int iAttribute);
  1288. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1289. [Obsolete("This function is provided only for compatibility with 16-bit versions of Windows. Use 'SetFilePointer' function instead.", false)]
  1290. public static extern int _llseek(IntPtr hFile, int lOffset, int iOrigin);
  1291. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1292. [Obsolete("This function is provided only for compatibility with 16-bit versions of Windows. Use 'CreateFile' function instead.", false)]
  1293. public static extern IntPtr _lopen(IntPtr lpPathName, int iReadWrite);
  1294. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Ansi), CLSCompliant(false)]
  1295. [Obsolete("This function is provided only for compatibility with 16-bit versions of Windows. Use 'CreateFile' function instead.", false)]
  1296. public static extern IntPtr _lopen(string lpPathName, int iReadWrite);
  1297. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1298. [Obsolete("This function is provided only for compatibility with 16-bit versions of Windows. Use 'ReadFile' function instead.", false)]
  1299. public static extern int _lread(IntPtr hFile, IntPtr lpBuffer, uint uBytes);
  1300. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1301. [Obsolete("This function is provided only for compatibility with 16-bit versions of Windows. Use 'WriteFile' function instead.", false)]
  1302. public static extern int _lwrite(IntPtr hFile, IntPtr lpBuffer, uint uBytes);
  1303. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Ansi), CLSCompliant(false)]
  1304. [Obsolete("This function is provided only for compatibility with 16-bit versions of Windows. Use 'WriteFile' function instead.", false)]
  1305. public static extern int _lwrite(IntPtr hFile, string lpBuffer, uint uBytes);
  1306. [DllImport(ModuleName, SetLastError = true)]
  1307. public static extern int AreFileApisANSI();
  1308. [DllImport(ModuleName, SetLastError = true)]
  1309. public static extern int CancelIo(IntPtr hFile);
  1310. [DllImport(ModuleName, SetLastError = true)]
  1311. public static extern int CopyFileA(IntPtr lpExistingFileName, IntPtr lpNewFileName, int bFailIfExists);
  1312. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Ansi)]
  1313. public static extern int CopyFileA(string lpExistingFileName, string lpNewFileName, int bFailIfExists);
  1314. [DllImport(ModuleName, SetLastError = true)]
  1315. public static extern int CopyFileW(IntPtr lpExistingFileName, IntPtr lpNewFileName, int bFailIfExists);
  1316. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Ansi)]
  1317. public static extern int CopyFileW(string lpExistingFileName, string lpNewFileName, int bFailIfExists);
  1318. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1319. public static extern int CopyFileExA(IntPtr lpExistingFileName, IntPtr lpNewFileName, IntPtr lpProgressRoutine, IntPtr lpData, IntPtr pbCancel, uint dwCopyFlags);
  1320. [DllImport(ModuleName, CharSet = CharSet.Ansi), CLSCompliant(false)]
  1321. public static extern int CopyFileExA(string lpExistingFileName, string lpNewFileName, CopyProgressRoutine lpProgressRoutine, IntPtr lpData, ref int pbCancel, uint dwCopyFlags);
  1322. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1323. public static extern int CopyFileExW(IntPtr lpExistingFileName, IntPtr lpNewFileName, IntPtr lpProgressRoutine, IntPtr lpData, IntPtr pbCancel, uint dwCopyFlags);
  1324. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Unicode), CLSCompliant(false)]
  1325. public static extern int CopyFileExW(string lpExistingFileName, string lpNewFileName, CopyProgressRoutine lpProgressRoutine, IntPtr lpData, ref int pbCancel, uint dwCopyFlags);
  1326. [DllImport(ModuleName, SetLastError = true)]
  1327. public static extern int CreateDirectoryA(IntPtr lpPathName, IntPtr lpSecurityAttributes);
  1328. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Ansi), CLSCompliant(false)]
  1329. public static extern int CreateDirectoryA(string lpPathName, ref SECURITY_ATTRIBUTES lpSecurityAttributes);
  1330. [DllImport(ModuleName, SetLastError = true)]
  1331. public static extern int CreateDirectoryW(IntPtr lpPathName, IntPtr lpSecurityAttributes);
  1332. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Unicode), CLSCompliant(false)]
  1333. public static extern int CreateDirectoryW(string lpPathName, ref SECURITY_ATTRIBUTES lpSecurityAttributes);
  1334. [DllImport(ModuleName, SetLastError = true)]
  1335. public static extern int CreateDirectoryExA(IntPtr lpTemplateDirectory, IntPtr lpNewDirectory, IntPtr lpSecurityAttributes);
  1336. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Ansi), CLSCompliant(false)]
  1337. public static extern int CreateDirectoryExA(string lpTemplateDirectory, string lpNewDirectory, ref SECURITY_ATTRIBUTES lpSecurityAttributes);
  1338. [DllImport(ModuleName, SetLastError = true)]
  1339. public static extern int CreateDirectoryExW(IntPtr lpTemplateDirectory, IntPtr lpNewDirectory, IntPtr lpSecurityAttributes);
  1340. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Unicode), CLSCompliant(false)]
  1341. public static extern int CreateDirectoryExW(string lpTemplateDirectory, string lpNewDirectory, ref SECURITY_ATTRIBUTES lpSecurityAttributes);
  1342. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1343. public static extern IntPtr CreateFileA(IntPtr lpFileName, uint dwDesiredAccess, uint dwShareMode, IntPtr lpSecurityAttributes, uint dwCreationDisposition, uint dwFlagsAndAttributes, IntPtr hTemplateFile);
  1344. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Ansi), CLSCompliant(false)]
  1345. public static extern IntPtr CreateFileA(string lpFileName, uint dwDesiredAccess, uint dwShareMode, ref SECURITY_ATTRIBUTES lpSecurityAttributes, uint dwCreationDisposition, uint dwFlagsAndAttributes, IntPtr hTemplateFile);
  1346. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1347. public static extern IntPtr CreateFileW(IntPtr lpFileName, uint dwDesiredAccess, uint dwShareMode, IntPtr lpSecurityAttributes, uint dwCreationDisposition, uint dwFlagsAndAttributes, IntPtr hTemplateFile);
  1348. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Unicode), CLSCompliant(false)]
  1349. public static extern IntPtr CreateFileW(string lpFileName, uint dwDesiredAccess, uint dwShareMode, ref SECURITY_ATTRIBUTES lpSecurityAttributes, uint dwCreationDisposition, uint dwFlagsAndAttributes, IntPtr hTemplateFile);
  1350. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1351. public static extern IntPtr CreateIoCompletionPort(IntPtr FileHandle, IntPtr ExistingCompletionPort, uint CompletionKey, uint NumberOfConcurrentThreads);
  1352. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1353. public static extern int DefineDosDeviceA(uint dwFlags, IntPtr lpDeviceName, IntPtr lpTargetPath);
  1354. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Ansi), CLSCompliant(false)]
  1355. public static extern int DefineDosDeviceA(uint dwFlags, string lpDeviceName, string lpTargetPath);
  1356. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1357. public static extern int DefineDosDeviceW(uint dwFlags, IntPtr lpDeviceName, IntPtr lpTargetPath);
  1358. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Unicode), CLSCompliant(false)]
  1359. public static extern int DefineDosDeviceW(uint dwFlags, string lpDeviceName, string lpTargetPath);
  1360. [DllImport(ModuleName, SetLastError = true)]
  1361. public static extern int DeleteFileA(IntPtr lpFileName);
  1362. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Ansi)]
  1363. public static extern int DeleteFileA(string lpFileName);
  1364. [DllImport(ModuleName, SetLastError = true)]
  1365. public static extern int DeleteFileW(IntPtr lpFileName);
  1366. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Unicode)]
  1367. public static extern int DeleteFileW(string lpFileName);
  1368. [DllImport(ModuleName, SetLastError = true)]
  1369. public static extern int FindClose(IntPtr hFindFile);
  1370. [DllImport(ModuleName, SetLastError = true)]
  1371. public static extern int FindCloseChangeNotification(IntPtr hChangeHandle);
  1372. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1373. public static extern IntPtr FindFirstChangeNotificationA(IntPtr lpPathName, int bWatchSubtree, uint dwNotifyFilter);
  1374. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Ansi), CLSCompliant(false)]
  1375. public static extern IntPtr FindFirstChangeNotificationA(string lpPathName, int bWatchSubtree, uint dwNotifyFilter);
  1376. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1377. public static extern IntPtr FindFirstChangeNotificationW(IntPtr lpPathName, int bWatchSubtree, uint dwNotifyFilter);
  1378. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Unicode), CLSCompliant(false)]
  1379. public static extern IntPtr FindFirstChangeNotificationW(string lpPathName, int bWatchSubtree, uint dwNotifyFilter);
  1380. [DllImport(ModuleName, SetLastError = true)]
  1381. public static extern IntPtr FindFirstFileA(IntPtr lpFileName, IntPtr lpFindFileData);
  1382. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Ansi), CLSCompliant(false)]
  1383. public static extern IntPtr FindFirstFileA(string lpFileName, ref WIN32_FIND_DATA lpFindFileData);
  1384. [DllImport(ModuleName, SetLastError = true)]
  1385. public static extern IntPtr FindFirstFileW(IntPtr lpFileName, IntPtr lpFindFileData);
  1386. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Unicode), CLSCompliant(false)]
  1387. public static extern IntPtr FindFirstFileW(string lpFileName, ref WIN32_FIND_DATA lpFindFileData);
  1388. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1389. public static extern IntPtr FindFirstFileExA(IntPtr lpFileName, FINDEX_INFO_LEVELS fInfoLevelId, IntPtr lpFindFileData, FINDEX_SEARCH_OPS fSearchOp, IntPtr lpSearchFilter, uint dwAdditionalFlag);
  1390. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Ansi), CLSCompliant(false)]
  1391. public static extern IntPtr FindFirstFileExA(string lpFileName, FINDEX_INFO_LEVELS fInfoLevelId, IntPtr lpFindFileData, FINDEX_SEARCH_OPS fSearchOp, IntPtr lpSearchFilter, uint dwAdditionalFlag);
  1392. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1393. public static extern IntPtr FindFirstFileExW(IntPtr lpFileName, FINDEX_INFO_LEVELS fInfoLevelId, IntPtr lpFindFileData, FINDEX_SEARCH_OPS fSearchOp, IntPtr lpSearchFilter, uint dwAdditionalFlag);
  1394. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Unicode), CLSCompliant(false)]
  1395. public static extern IntPtr FindFirstFileExW(string lpFileName, FINDEX_INFO_LEVELS fInfoLevelId, IntPtr lpFindFileData, FINDEX_SEARCH_OPS fSearchOp, IntPtr lpSearchFilter, uint dwAdditionalFlag);
  1396. [DllImport(ModuleName, SetLastError = true)]
  1397. public static extern int FindNextChangeNotification(IntPtr hChangeHandle);
  1398. [DllImport(ModuleName, SetLastError = true)]
  1399. public static extern int FindNextFileA(IntPtr hFindFile, IntPtr lpFindFileData);
  1400. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Ansi), CLSCompliant(false)]
  1401. public static extern int FindNextFileA(IntPtr hFindFile, ref WIN32_FIND_DATA lpFindFileData);
  1402. [DllImport(ModuleName, SetLastError = true)]
  1403. public static extern int FindNextFileW(IntPtr hFindFile, IntPtr lpFindFileData);
  1404. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Unicode), CLSCompliant(false)]
  1405. public static extern int FindNextFileW(IntPtr hFindFile, ref WIN32_FIND_DATA lpFindFileData);
  1406. [DllImport(ModuleName, SetLastError = true)]
  1407. public static extern int FlushFileBuffers(IntPtr hFile);
  1408. [DllImport(ModuleName, SetLastError = true)]
  1409. public static extern int GetBinaryTypeA(IntPtr lpApplicationName, IntPtr lpBinaryType);
  1410. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Ansi), CLSCompliant(false)]
  1411. public static extern int GetBinaryTypeA(string lpApplicationName, ref uint lpBinaryType);
  1412. [DllImport(ModuleName, SetLastError = true)]
  1413. public static extern int GetBinaryTypeW(IntPtr lpApplicationName, IntPtr lpBinaryType);
  1414. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Unicode), CLSCompliant(false)]
  1415. public static extern int GetBinaryTypeW(string lpApplicationName, ref uint lpBinaryType);
  1416. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1417. public static extern uint GetCurrentDirectoryA(uint nBufferLength, IntPtr lpBuffer);
  1418. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Ansi), CLSCompliant(false)]
  1419. public static extern uint GetCurrentDirectoryA(uint nBufferLength, StringBuilder lpBuffer);
  1420. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1421. public static extern uint GetCurrentDirectoryW(uint nBufferLength, IntPtr lpBuffer);
  1422. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Unicode), CLSCompliant(false)]
  1423. public static extern uint GetCurrentDirectoryW(uint nBufferLength, StringBuilder lpBuffer);
  1424. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1425. public static extern uint GetDriveTypeA(IntPtr lpRootPathName);
  1426. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Ansi), CLSCompliant(false)]
  1427. public static extern uint GetDriveTypeA(string lpRootPathName);
  1428. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1429. public static extern uint GetDriveTypeW(IntPtr lpRootPathName);
  1430. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Unicode), CLSCompliant(false)]
  1431. public static extern uint GetDriveTypeW(string lpRootPathName);
  1432. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1433. public static extern uint GetFileAttributesA(IntPtr lpFileName);
  1434. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Ansi), CLSCompliant(false)]
  1435. public static extern uint GetFileAttributesA(string lpFileName);
  1436. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1437. public static extern uint GetFileAttributesW(IntPtr lpFileName);
  1438. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Unicode), CLSCompliant(false)]
  1439. public static extern uint GetFileAttributesW(string lpFileName);
  1440. [DllImport(ModuleName, SetLastError = true)]
  1441. public static extern int GetFileAttributesExA(IntPtr lpFileName, FINDEX_INFO_LEVELS fInfoLevelId, IntPtr lpFileInformation);
  1442. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Ansi)]
  1443. public static extern int GetFileAttributesExA(string lpFileName, FINDEX_INFO_LEVELS fInfoLevelId, IntPtr lpFileInformation);
  1444. [DllImport(ModuleName, SetLastError = true)]
  1445. public static extern int GetFileAttributesExW(IntPtr lpFileName, FINDEX_INFO_LEVELS fInfoLevelId, IntPtr lpFileInformation);
  1446. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Unicode)]
  1447. public static extern int GetFileAttributesExW(string lpFileName, FINDEX_INFO_LEVELS fInfoLevelId, IntPtr lpFileInformation);
  1448. [DllImport(ModuleName, SetLastError = true)]
  1449. public static extern int GetFileInformationByHandle(IntPtr hFile, IntPtr lpFileInformation);
  1450. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1451. public static extern int GetFileInformationByHandle(IntPtr hFile, ref BY_HANDLE_FILE_INFORMATION lpFileInformation);
  1452. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1453. public static extern uint GetFileType(IntPtr hFile);
  1454. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1455. public static extern uint GetFullPathNameA(IntPtr lpFileName, uint nBufferLength, IntPtr lpBuffer, IntPtr lpFilePart);
  1456. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1457. public static extern uint GetFullPathNameA(IntPtr lpFileName, uint nBufferLength, IntPtr lpBuffer, ref IntPtr lpFilePart);
  1458. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Ansi), CLSCompliant(false)]
  1459. public static extern uint GetFullPathNameA(string lpFileName, uint nBufferLength, StringBuilder lpBuffer, ref IntPtr lpFilePart);
  1460. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1461. public static extern uint GetFullPathNameW(IntPtr lpFileName, uint nBufferLength, IntPtr lpBuffer, IntPtr lpFilePart);
  1462. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1463. public static extern uint GetFullPathNameW(IntPtr lpFileName, uint nBufferLength, IntPtr lpBuffer, ref IntPtr lpFilePart);
  1464. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Unicode), CLSCompliant(false)]
  1465. public static extern uint GetFullPathNameW(string lpFileName, uint nBufferLength, StringBuilder lpBuffer, ref IntPtr lpFilePart);
  1466. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1467. public static extern uint GetLongPathNameA(IntPtr lpszShortPath, IntPtr lpszLongPath, uint cchBuffer);
  1468. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Ansi), CLSCompliant(false)]
  1469. public static extern uint GetLongPathNameA(string lpszShortPath, StringBuilder lpszLongPath, uint cchBuffer);
  1470. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1471. public static extern uint GetLongPathNameW(IntPtr lpszShortPath, IntPtr lpszLongPath, uint cchBuffer);
  1472. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Unicode), CLSCompliant(false)]
  1473. public static extern uint GetLongPathNameW(string lpszShortPath, StringBuilder lpszLongPath, uint cchBuffer);
  1474. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1475. public static extern int GetQueuedCompletionStatus(IntPtr CompletionPort, IntPtr lpNumberOfBytes, IntPtr lpCompletionKey, IntPtr lpOverlapped, uint dwMilliseconds);
  1476. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1477. public static extern int GetQueuedCompletionStatus(IntPtr CompletionPort, ref uint lpNumberOfBytes, ref uint lpCompletionKey, ref OVERLAPPED lpOverlapped, uint dwMilliseconds);
  1478. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1479. public static extern uint GetShortPathNameA(IntPtr lpszLongPath, IntPtr lpszShortPath, uint cchBuffer);
  1480. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Ansi), CLSCompliant(false)]
  1481. public static extern uint GetShortPathNameA(string lpszLongPath, StringBuilder lpszShortPath, uint cchBuffer);
  1482. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1483. public static extern uint GetShortPathNameW(IntPtr lpszLongPath, IntPtr lpszShortPath, uint cchBuffer);
  1484. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Unicode), CLSCompliant(false)]
  1485. public static extern uint GetShortPathNameW(string lpszLongPath, StringBuilder lpszShortPath, uint cchBuffer);
  1486. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1487. public static extern uint GetTempFileNameA(IntPtr lpPathName, IntPtr lpPrefixString, uint uUnique, IntPtr lpTempFileName);
  1488. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Ansi), CLSCompliant(false)]
  1489. public static extern uint GetTempFileNameA(string lpPathName, string lpPrefixString, uint uUnique, StringBuilder lpTempFileName);
  1490. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1491. public static extern uint GetTempFileNameW(IntPtr lpPathName, IntPtr lpPrefixString, uint uUnique, IntPtr lpTempFileName);
  1492. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Unicode), CLSCompliant(false)]
  1493. public static extern uint GetTempFileNameW(string lpPathName, string lpPrefixString, uint uUnique, StringBuilder lpTempFileName);
  1494. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1495. public static extern uint GetTempPathA(uint nBufferLength, IntPtr lpBuffer);
  1496. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Ansi), CLSCompliant(false)]
  1497. public static extern uint GetTempPathA(uint nBufferLength, StringBuilder lpBuffer);
  1498. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1499. public static extern uint GetTempPathW(uint nBufferLength, IntPtr lpBuffer);
  1500. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Unicode), CLSCompliant(false)]
  1501. public static extern uint GetTempPathW(uint nBufferLength, StringBuilder lpBuffer);
  1502. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1503. public static extern int LockFile(IntPtr hFile, uint dwFileOffsetLow, uint dwFileOffsetHigh, uint nNumberOfBytesToLockLow, uint nNumberOfBytesToLockHigh);
  1504. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1505. public static extern int LockFileEx(IntPtr hFile, uint dwFileOffsetLow, uint dwFileOffsetHigh, uint nNumberOfBytesToLockLow, uint nNumberOfBytesToLockHigh, IntPtr lpOverlapped);
  1506. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1507. public static extern int LockFileEx(IntPtr hFile, uint dwFileOffsetLow, uint dwFileOffsetHigh, uint nNumberOfBytesToLockLow, uint nNumberOfBytesToLockHigh, ref OVERLAPPED lpOverlapped);
  1508. [DllImport(ModuleName, SetLastError = true)]
  1509. public static extern int MoveFileA(IntPtr lpExistingFileName, IntPtr lpNewFileName);
  1510. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Ansi)]
  1511. public static extern int MoveFileA(string lpExistingFileName, string lpNewFileName);
  1512. [DllImport(ModuleName, SetLastError = true)]
  1513. public static extern int MoveFileW(IntPtr lpExistingFileName, IntPtr lpNewFileName);
  1514. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Unicode)]
  1515. public static extern int MoveFileW(string lpExistingFileName, string lpNewFileName);
  1516. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1517. public static extern int MoveFileExA(IntPtr lpExistingFileName, IntPtr lpNewFileName, uint dwFlags);
  1518. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Ansi), CLSCompliant(false)]
  1519. public static extern int MoveFileExA(string lpExistingFileName, string lpNewFileName, uint dwFlags);
  1520. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1521. public static extern int MoveFileExW(IntPtr lpExistingFileName, IntPtr lpNewFileName, uint dwFlags);
  1522. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Unicode), CLSCompliant(false)]
  1523. public static extern int MoveFileExW(string lpExistingFileName, string lpNewFileName, uint dwFlags);
  1524. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1525. public static extern int MoveFileWithProgressA(IntPtr lpExistingFileName, IntPtr lpNewFileName, IntPtr lpProgressRoutine, IntPtr lpData, uint dwFlags);
  1526. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Ansi), CLSCompliant(false)]
  1527. public static extern int MoveFileWithProgressA(string lpExistingFileName, string lpNewFileName, CopyProgressRoutine lpProgressRoutine, IntPtr lpData, uint dwFlags);
  1528. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1529. public static extern int MoveFileWithProgressW(IntPtr lpExistingFileName, IntPtr lpNewFileName, IntPtr lpProgressRoutine, IntPtr lpData, uint dwFlags);
  1530. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Unicode), CLSCompliant(false)]
  1531. public static extern int MoveFileWithProgressW(string lpExistingFileName, string lpNewFileName, CopyProgressRoutine lpProgressRoutine, IntPtr lpData, uint dwFlags);
  1532. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1533. [Obsolete("This function is provided only for compatibility with 16-bit versions of Windows. Use 'CreateFile' function instead.", false)]
  1534. public static extern IntPtr OpenFile(IntPtr lpFileName, IntPtr lpReOpenBuff, uint uStyle);
  1535. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Ansi), CLSCompliant(false)]
  1536. [Obsolete("This function is provided only for compatibility with 16-bit versions of Windows. Use 'CreateFile' function instead.", false)]
  1537. public static extern IntPtr OpenFile(string lpFileName, ref OFSTRUCT lpReOpenBuff, uint uStyle);
  1538. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1539. public static extern int PostQueuedCompletionStatus(IntPtr CompletionPort, uint dwNumberOfBytesTransferred, uint dwCompletionKey, IntPtr lpOverlapped);
  1540. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1541. public static extern int PostQueuedCompletionStatus(IntPtr CompletionPort, uint dwNumberOfBytesTransferred, uint dwCompletionKey, ref OVERLAPPED lpOverlapped);
  1542. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1543. public static extern uint QueryDosDeviceA(IntPtr lpDeviceName, IntPtr lpTargetPath, uint ucchMax);
  1544. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Ansi), CLSCompliant(false)]
  1545. public static extern uint QueryDosDeviceA(string lpDeviceName, StringBuilder lpTargetPath, uint ucchMax);
  1546. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1547. public static extern uint QueryDosDeviceW(IntPtr lpDeviceName, IntPtr lpTargetPath, uint ucchMax);
  1548. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Unicode), CLSCompliant(false)]
  1549. public static extern uint QueryDosDeviceW(string lpDeviceName, StringBuilder lpTargetPath, uint ucchMax);
  1550. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1551. public static extern int ReadDirectoryChangeW(IntPtr hDirectory, IntPtr lpBuffer, uint nBufferLength, int bWatchSubtree, uint dwNotifyFilter, IntPtr lpBytesReturned, IntPtr lpOverlapped, IntPtr lpCompletionRoutine);
  1552. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1553. public static extern int ReadDirectoryChangeW(IntPtr hDirectory, IntPtr lpBuffer, uint nBufferLength, int bWatchSubtree, uint dwNotifyFilter, ref uint lpBytesReturned, ref OVERLAPPED lpOverlapped, FileIOCompletionRoutine lpCompletionRoutine);
  1554. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1555. public static extern int ReadFile(IntPtr hFile, IntPtr lpBuffer, uint nNumberOfBytesToRead, IntPtr lpNumberOfBytesRead, IntPtr lpOverlapped);
  1556. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1557. public static extern int ReadFile(IntPtr hFile, IntPtr lpBuffer, uint nNumberOfBytesToRead, ref uint lpNumberOfBytesRead, ref OVERLAPPED lpOverlapped);
  1558. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1559. public static extern int ReadFileEx(IntPtr hFile, IntPtr lpBuffer, uint nNumberOfBytesToRead, IntPtr lpOverlapped, IntPtr lpCompletionRoutine);
  1560. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1561. public static extern int ReadFileEx(IntPtr hFile, IntPtr lpBuffer, uint nNumberOfBytesToRead, ref OVERLAPPED lpOverlapped, FileIOCompletionRoutine lpCompletionRoutine);
  1562. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1563. public static extern int ReadFileScatter(IntPtr hFile, FILE_SEGMENT_ELEMENT[] aSegmentArray, uint nNumberOfBytesToRead, IntPtr lpReserved, IntPtr lpOverlapped);
  1564. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1565. public static extern int ReadFileScatter(IntPtr hFile, FILE_SEGMENT_ELEMENT[] aSegmentArray, uint nNumberOfBytesToRead, IntPtr lpReserved, ref OVERLAPPED lpOverlapped);
  1566. [DllImport(ModuleName, SetLastError = true)]
  1567. public static extern int RemoveDirectoryA(IntPtr lpPathName);
  1568. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Ansi)]
  1569. public static extern int RemoveDirectoryA(string lpPathName);
  1570. [DllImport(ModuleName, SetLastError = true)]
  1571. public static extern int RemoveDirectoryW(IntPtr lpPathName);
  1572. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Unicode)]
  1573. public static extern int RemoveDirectoryW(string lpPathName);
  1574. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1575. public static extern int ReplaceFileA(IntPtr lpReplacedFileName, IntPtr lpReplacementFileName, IntPtr lpBackupFileName, uint dwReplaceFlags, IntPtr lpExclude, IntPtr lpReserved);
  1576. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Ansi), CLSCompliant(false)]
  1577. public static extern int ReplaceFileA(string lpReplacedFileName, string lpReplacementFileName, string lpBackupFileName, uint dwReplaceFlags, IntPtr lpExclude, IntPtr lpReserved);
  1578. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1579. public static extern int ReplaceFileW(IntPtr lpReplacedFileName, IntPtr lpReplacementFileName, IntPtr lpBackupFileName, uint dwReplaceFlags, IntPtr lpExclude, IntPtr lpReserved);
  1580. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Unicode), CLSCompliant(false)]
  1581. public static extern int ReplaceFileW(string lpReplacedFileName, string lpReplacementFileName, string lpBackupFileName, uint dwReplaceFlags, IntPtr lpExclude, IntPtr lpReserved);
  1582. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1583. public static extern uint SearchPathA(IntPtr lpPath, IntPtr lpFileName, IntPtr lpExtension, uint nBufferLength, IntPtr lpBuffer, IntPtr lpFilePart);
  1584. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1585. public static extern uint SearchPathA(IntPtr lpPath, IntPtr lpFileName, IntPtr lpExtension, uint nBufferLength, IntPtr lpBuffer, ref IntPtr lpFilePart);
  1586. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Ansi), CLSCompliant(false)]
  1587. public static extern uint SearchPathA(string lpPath, string lpFileName, string lpExtension, uint nBufferLength, StringBuilder lpBuffer, ref IntPtr lpFilePart);
  1588. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1589. public static extern uint SearchPathW(IntPtr lpPath, IntPtr lpFileName, IntPtr lpExtension, uint nBufferLength, IntPtr lpBuffer, IntPtr lpFilePart);
  1590. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1591. public static extern uint SearchPathW(IntPtr lpPath, IntPtr lpFileName, IntPtr lpExtension, uint nBufferLength, IntPtr lpBuffer, ref IntPtr lpFilePart);
  1592. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Unicode), CLSCompliant(false)]
  1593. public static extern uint SearchPathW(string lpPath, string lpFileName, string lpExtension, uint nBufferLength, StringBuilder lpBuffer, ref IntPtr lpFilePart);
  1594. [DllImport(ModuleName, SetLastError = true)]
  1595. public static extern int SetCurrentDirectoryA(IntPtr lpPathName);
  1596. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Ansi)]
  1597. public static extern int SetCurrentDirectoryA(string lpPathName);
  1598. [DllImport(ModuleName, SetLastError = true)]
  1599. public static extern int SetCurrentDirectoryW(IntPtr lpPathName);
  1600. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Unicode)]
  1601. public static extern int SetCurrentDirectoryW(string lpPathName);
  1602. [DllImport(ModuleName, SetLastError = true)]
  1603. public static extern int SetEndOfFile(IntPtr hFile);
  1604. [DllImport(ModuleName)]
  1605. public static extern void SetFileApisToANSI();
  1606. [DllImport(ModuleName)]
  1607. public static extern void SetFileApisToOEM();
  1608. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1609. public static extern int SetFileAttributesA(IntPtr lpFileName, uint dwFileAttributes);
  1610. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Ansi), CLSCompliant(false)]
  1611. public static extern int SetFileAttributesA(string lpFileName, uint dwFileAttributes);
  1612. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1613. public static extern int SetFileAttributesW(IntPtr lpFileName, uint dwFileAttributes);
  1614. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Unicode), CLSCompliant(false)]
  1615. public static extern int SetFileAttributesW(string lpFileName, uint dwFileAttributes);
  1616. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1617. public static extern uint SetFilePointer(IntPtr hFile, int lDistanceToMove, IntPtr lpDistanceToMoveHigh, uint dwMoveMethod);
  1618. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1619. public static extern uint SetFilePointer(IntPtr hFile, int lDistanceToMove, ref int lpDistanceToMoveHigh, uint dwMoveMethod);
  1620. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1621. public static extern int SetFilePointerEx(IntPtr hFile, LARGE_INTEGER liDistanceToMove, IntPtr lpNewFilePointer, uint dwMoveMethod);
  1622. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1623. public static extern int SetFilePointerEx(IntPtr hFile, LARGE_INTEGER liDistanceToMove, ref LARGE_INTEGER lpNewFilePointer, uint dwMoveMethod);
  1624. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1625. public static extern int SetFileSecurityA(IntPtr lpFileName, SECURITY_INFORMATION SecurityInformation, IntPtr pSecurityDescriptor);
  1626. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Ansi), CLSCompliant(false)]
  1627. public static extern int SetFileSecurityA(string lpFileName, SECURITY_INFORMATION SecurityInformation, ref SECURITY_DESCRIPTOR pSecurityDescriptor);
  1628. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1629. public static extern int SetFileSecurityW(IntPtr lpFileName, SECURITY_INFORMATION SecurityInformation, IntPtr pSecurityDescriptor);
  1630. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Unicode), CLSCompliant(false)]
  1631. public static extern int SetFileSecurityW(string lpFileName, SECURITY_INFORMATION SecurityInformation, ref SECURITY_DESCRIPTOR pSecurityDescriptor);
  1632. [DllImport(ModuleName, SetLastError = true)]
  1633. public static extern int SetFileShortNameA(IntPtr hFile, IntPtr lpShortName);
  1634. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Ansi)]
  1635. public static extern int SetFileShortNameA(IntPtr hFile, string lpShortName);
  1636. [DllImport(ModuleName, SetLastError = true)]
  1637. public static extern int SetFileShortNameW(IntPtr hFile, IntPtr lpShortName);
  1638. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Unicode)]
  1639. public static extern int SetFileShortNameW(IntPtr hFile, string lpShortName);
  1640. [DllImport(ModuleName, SetLastError = true)]
  1641. public static extern int SetFileValidData(IntPtr hFile, long ValidDataLength);
  1642. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1643. public static extern int UnlockFile(IntPtr hFile, uint dwFileOffsetLow, uint dwFileOffsetHigh, uint nNumberOfBytesToUnlockLow, uint nNumberOfBytesToUnlockHigh);
  1644. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1645. public static extern int UnlockFileEx(IntPtr hFile, uint dwReserved, uint nNumberOfBytesToUnlockLow, uint nNumberOfBytesToUnlockHigh, IntPtr lpOverlapped);
  1646. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1647. public static extern int UnlockFileEx(IntPtr hFile, uint dwReserved, uint nNumberOfBytesToUnlockLow, uint nNumberOfBytesToUnlockHigh, ref OVERLAPPED lpOverlapped);
  1648. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1649. public static extern int WriteFile(IntPtr hFile, IntPtr lpBuffer, uint nNumberOfBytesToWrite, IntPtr lpNumberOfBytesWritten, IntPtr lpOverlapped);
  1650. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1651. public static extern int WriteFile(IntPtr hFile, IntPtr lpBuffer, uint nNumberOfBytesToWrite, ref uint lpNumberOfBytesWritten, ref OVERLAPPED lpOverlapped);
  1652. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1653. public static extern int WriteFileEx(IntPtr hFile, IntPtr lpBuffer, uint nNumberOfBytesToWrite, IntPtr lpOverlapped, IntPtr lpCompletionRoutine);
  1654. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1655. public static extern int WriteFileEx(IntPtr hFile, IntPtr lpBuffer, uint nNumberOfBytesToWrite, ref OVERLAPPED lpOverlapped, FileIOCompletionRoutine lpCompletionRoutine);
  1656. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1657. public static extern int WriteFileGather(IntPtr hFile, FILE_SEGMENT_ELEMENT[] aSegmentArray, uint nNumberOfBytesToWrite, IntPtr lpReserved, IntPtr lpOverlapped);
  1658. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1659. public static extern int WriteFileGather(IntPtr hFile, FILE_SEGMENT_ELEMENT[] aSegmentArray, uint nNumberOfBytesToWrite, IntPtr lpReserved, ref OVERLAPPED lpOverlapped);
  1660. }
  1661. #endregion // File I/O functions
  1662. #region File mapping functions
  1663. partial class kernel32
  1664. {
  1665. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1666. public static extern IntPtr CreateFileMappingA(IntPtr hFile, IntPtr lpAttributes, uint flProtect, uint dwMaximumSizeHigh, uint dwMaximumSizeLow, IntPtr lpName);
  1667. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Ansi), CLSCompliant(false)]
  1668. public static extern IntPtr CreateFileMappingA(IntPtr hFile, ref SECURITY_ATTRIBUTES lpAttributes, uint flProtect, uint dwMaximumSizeHigh, uint dwMaximumSizeLow, string lpName);
  1669. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1670. public static extern IntPtr CreateFileMappingW(IntPtr hFile, IntPtr lpAttributes, uint flProtect, uint dwMaximumSizeHigh, uint dwMaximumSizeLow, IntPtr lpName);
  1671. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Unicode), CLSCompliant(false)]
  1672. public static extern IntPtr CreateFileMappingW(IntPtr hFile, ref SECURITY_ATTRIBUTES lpAttributes, uint flProtect, uint dwMaximumSizeHigh, uint dwMaximumSizeLow, string lpName);
  1673. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1674. public static extern int FlushViewOfFile(IntPtr lpBaseAddress, uint dwNumberOfBytesToFlush);
  1675. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1676. public static extern IntPtr MapViewOfFile(IntPtr hFileMappingObject, uint dwDesiredAccess, uint dwFileOffsetHigh, uint dwFileOffsetLow, uint dwNumberOfBytesToMap);
  1677. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1678. public static extern IntPtr MapViewOfFileEx(IntPtr hFileMappingObject, uint dwDesiredAccess, uint dwFileOffsetHigh, uint dwFileOffsetLow, uint dwNumberOfBytesToMap, IntPtr lpBaseAddress);
  1679. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1680. public static extern IntPtr OpenFileMappingA(uint dwDesiredAccess, int bInheritHandle, IntPtr lpName);
  1681. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Ansi), CLSCompliant(false)]
  1682. public static extern IntPtr OpenFileMappingA(uint dwDesiredAccess, int bInheritHandle, string lpName);
  1683. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1684. public static extern IntPtr OpenFileMappingW(uint dwDesiredAccess, int bInheritHandle, IntPtr lpName);
  1685. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Unicode), CLSCompliant(false)]
  1686. public static extern IntPtr OpenFileMappingW(uint dwDesiredAccess, int bInheritHandle, string lpName);
  1687. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1688. public static extern int UnmapViewOfFile(IntPtr lpBaseAddress);
  1689. }
  1690. #endregion // File mapping functions
  1691. #region File system functions (general)
  1692. partial class kernel32
  1693. {
  1694. [DllImport(ModuleName, SetLastError = true)]
  1695. public static extern int CreateHardLinkA(IntPtr lpFileName, IntPtr lpExistingFileName, IntPtr lpSecurityAttributes);
  1696. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Ansi), CLSCompliant(false)]
  1697. public static extern int CreateHardLinkA(string lpFileName, string lpExistingFileName, ref SECURITY_ATTRIBUTES lpSecurityAttributes);
  1698. [DllImport(ModuleName, SetLastError = true)]
  1699. public static extern int CreateHardLinkW(IntPtr lpFileName, IntPtr lpExistingFileName, IntPtr lpSecurityAttributes);
  1700. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Unicode), CLSCompliant(false)]
  1701. public static extern int CreateHardLinkW(string lpFileName, string lpExistingFileName, ref SECURITY_ATTRIBUTES lpSecurityAttributes);
  1702. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1703. public static extern uint GetCompressedFileSizeA(IntPtr lpFileName, IntPtr lpFileSizeHigh);
  1704. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Ansi), CLSCompliant(false)]
  1705. public static extern uint GetCompressedFileSizeA(string lpFileName, ref uint lpFileSizeHigh);
  1706. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1707. public static extern uint GetCompressedFileSizeW(IntPtr lpFileName, IntPtr lpFileSizeHigh);
  1708. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Unicode), CLSCompliant(false)]
  1709. public static extern uint GetCompressedFileSizeW(string lpFileName, ref uint lpFileSizeHigh);
  1710. [DllImport(ModuleName, SetLastError = true)]
  1711. public static extern int GetDiskFreeSpaceA(IntPtr lpRootPathName, IntPtr lpSectorsPerCluster, IntPtr lpBytesPerSector, IntPtr lpNumberOfFreeClusters, IntPtr lpTotalNumberOfClusters);
  1712. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Ansi), CLSCompliant(false)]
  1713. public static extern int GetDiskFreeSpaceA(string lpRootPathName, ref uint lpSectorsPerCluster, ref uint lpBytesPerSector, ref uint lpNumberOfFreeClusters, ref uint lpTotalNumberOfClusters);
  1714. [DllImport(ModuleName, SetLastError = true)]
  1715. public static extern int GetDiskFreeSpaceW(IntPtr lpRootPathName, IntPtr lpSectorsPerCluster, IntPtr lpBytesPerSector, IntPtr lpNumberOfFreeClusters, IntPtr lpTotalNumberOfClusters);
  1716. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Unicode), CLSCompliant(false)]
  1717. public static extern int GetDiskFreeSpaceW(string lpRootPathName, ref uint lpSectorsPerCluster, ref uint lpBytesPerSector, ref uint lpNumberOfFreeClusters, ref uint lpTotalNumberOfClusters);
  1718. [DllImport(ModuleName, SetLastError = true)]
  1719. public static extern int GetDiskFreeSpaceExA(IntPtr lpDirectoryName, IntPtr lpFreeBytesAvailable, IntPtr lpTotalNumberOfBytes, IntPtr lpTotalNumberOfFreeBytes);
  1720. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Ansi), CLSCompliant(false)]
  1721. public static extern int GetDiskFreeSpaceExA(string lpDirectoryName, ref ULARGE_INTEGER lpFreeBytesAvailable, ref ULARGE_INTEGER lpTotalNumberOfBytes, ref ULARGE_INTEGER lpTotalNumberOfFreeBytes);
  1722. [DllImport(ModuleName, SetLastError = true)]
  1723. public static extern int GetDiskFreeSpaceExW(IntPtr lpDirectoryName, IntPtr lpFreeBytesAvailable, IntPtr lpTotalNumberOfBytes, IntPtr lpTotalNumberOfFreeBytes);
  1724. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Unicode), CLSCompliant(false)]
  1725. public static extern int GetDiskFreeSpaceExW(string lpDirectoryName, ref ULARGE_INTEGER lpFreeBytesAvailable, ref ULARGE_INTEGER lpTotalNumberOfBytes, ref ULARGE_INTEGER lpTotalNumberOfFreeBytes);
  1726. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1727. public static extern uint GetFileSize(IntPtr hFile, IntPtr lpFileSizeHigh);
  1728. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1729. public static extern uint GetFileSize(IntPtr hFile, ref uint lpFileSizeHigh);
  1730. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1731. public static extern uint GetFileSizeEx(IntPtr hFile, IntPtr lpFileSize);
  1732. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1733. public static extern uint GetFileSizeEx(IntPtr hFile, ref LARGE_INTEGER lpFileSize);
  1734. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1735. public static extern uint GetLogicalDrives();
  1736. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1737. public static extern uint GetLogicalDriveStringsA(uint nBufferLength, IntPtr lpBuffer);
  1738. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1739. public static extern uint GetLogicalDriveStringsW(uint nBufferLength, IntPtr lpBuffer);
  1740. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1741. public static extern int GetVolumeInformationA(IntPtr lpRootPathName, IntPtr lpVolumeNameBuffer, uint nVolumeNameSize, IntPtr lpVolumeSerialNumber, IntPtr lpMaximumComponentLength, IntPtr lpFileSystemFlags, IntPtr lpFileSystemNameBuffer, uint nFileSystemNameSize);
  1742. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Ansi), CLSCompliant(false)]
  1743. public static extern int GetVolumeInformationA(string lpRootPathName, StringBuilder lpVolumeNameBuffer, uint nVolumeNameSize, ref uint lpVolumeSerialNumber, ref uint lpMaximumComponentLength, ref uint lpFileSystemFlags, StringBuilder lpFileSystemNameBuffer, uint nFileSystemNameSize);
  1744. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1745. public static extern int GetVolumeInformationW(IntPtr lpRootPathName, IntPtr lpVolumeNameBuffer, uint nVolumeNameSize, IntPtr lpVolumeSerialNumber, IntPtr lpMaximumComponentLength, IntPtr lpFileSystemFlags, IntPtr lpFileSystemNameBuffer, uint nFileSystemNameSize);
  1746. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Unicode), CLSCompliant(false)]
  1747. public static extern int GetVolumeInformationW(string lpRootPathName, StringBuilder lpVolumeNameBuffer, uint nVolumeNameSize, ref uint lpVolumeSerialNumber, ref uint lpMaximumComponentLength, ref uint lpFileSystemFlags, StringBuilder lpFileSystemNameBuffer, uint nFileSystemNameSize);
  1748. [DllImport(ModuleName, SetLastError = true)]
  1749. public static extern int SetVolumeLabelA(IntPtr lpRootPathName, IntPtr lpVolumeName);
  1750. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Ansi)]
  1751. public static extern int SetVolumeLabelA(string lpRootPathName, string lpVolumeName);
  1752. [DllImport(ModuleName, SetLastError = true)]
  1753. public static extern int SetVolumeLabelW(IntPtr lpRootPathName, IntPtr lpVolumeName);
  1754. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Unicode)]
  1755. public static extern int SetVolumeLabelW(string lpRootPathName, string lpVolumeName);
  1756. }
  1757. #endregion // File system functions (general)
  1758. #region File system functions (mount points)
  1759. partial class kernel32
  1760. {
  1761. [DllImport(ModuleName, SetLastError = true)]
  1762. public static extern int DeleteVolumeMountPointA(IntPtr lpszVolumeMountPoint);
  1763. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Ansi)]
  1764. public static extern int DeleteVolumeMountPointA(string lpszVolumeMountPoint);
  1765. [DllImport(ModuleName, SetLastError = true)]
  1766. public static extern int DeleteVolumeMountPointW(IntPtr lpszVolumeMountPoint);
  1767. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Unicode)]
  1768. public static extern int DeleteVolumeMountPointW(string lpszVolumeMountPoint);
  1769. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1770. public static extern IntPtr FindFirstVolumeA(IntPtr lpszVolumeName, uint cchBufferLength);
  1771. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Ansi), CLSCompliant(false)]
  1772. public static extern IntPtr FindFirstVolumeA(StringBuilder lpszVolumeName, uint cchBufferLength);
  1773. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1774. public static extern IntPtr FindFirstVolumeW(IntPtr lpszVolumeName, uint cchBufferLength);
  1775. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Unicode), CLSCompliant(false)]
  1776. public static extern IntPtr FindFirstVolumeW(StringBuilder lpszVolumeName, uint cchBufferLength);
  1777. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1778. public static extern IntPtr FindFirstVolumeMountPointA(IntPtr lpszRootPathName, IntPtr lpszVolumeMountPoint, uint cchBufferLength);
  1779. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Ansi), CLSCompliant(false)]
  1780. public static extern IntPtr FindFirstVolumeMountPointA(string lpszRootPathName, StringBuilder lpszVolumeMountPoint, uint cchBufferLength);
  1781. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1782. public static extern IntPtr FindFirstVolumeMountPointW(IntPtr lpszRootPathName, IntPtr lpszVolumeMountPoint, uint cchBufferLength);
  1783. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Unicode), CLSCompliant(false)]
  1784. public static extern IntPtr FindFirstVolumeMountPointW(string lpszRootPathName, StringBuilder lpszVolumeMountPoint, uint cchBufferLength);
  1785. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1786. public static extern int FindNextVolumeA(IntPtr hFindVolume, IntPtr lpszVolumeName, uint cchBufferLength);
  1787. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Ansi), CLSCompliant(false)]
  1788. public static extern int FindNextVolumeA(IntPtr hFindVolume, StringBuilder lpszVolumeName, uint cchBufferLength);
  1789. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1790. public static extern int FindNextVolumeW(IntPtr hFindVolume, IntPtr lpszVolumeName, uint cchBufferLength);
  1791. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Unicode), CLSCompliant(false)]
  1792. public static extern int FindNextVolumeW(IntPtr hFindVolume, StringBuilder lpszVolumeName, uint cchBufferLength);
  1793. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1794. public static extern int FindNextVolumeMountPointA(IntPtr hFindVolumeMountPoint, IntPtr lpszVolumeMountPoint, uint cchBufferLength);
  1795. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Ansi), CLSCompliant(false)]
  1796. public static extern int FindNextVolumeMountPointA(IntPtr hFindVolumeMountPoint, StringBuilder lpszVolumeMountPoint, uint cchBufferLength);
  1797. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1798. public static extern int FindNextVolumeMountPointW(IntPtr hFindVolumeMountPoint, IntPtr lpszVolumeMountPoint, uint cchBufferLength);
  1799. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Unicode), CLSCompliant(false)]
  1800. public static extern int FindNextVolumeMountPointW(IntPtr hFindVolumeMountPoint, StringBuilder lpszVolumeMountPoint, uint cchBufferLength);
  1801. [DllImport(ModuleName, SetLastError = true)]
  1802. public static extern int FindVolumeClose(IntPtr hFindVolume);
  1803. [DllImport(ModuleName, SetLastError = true)]
  1804. public static extern int FindVolumeMountPointClose(IntPtr hFindVolume);
  1805. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1806. public static extern int GetVolumeNameForVolumeMountPointA(IntPtr lpszVolumeMountPoint, IntPtr lpszVolumeName, uint cchBufferLength);
  1807. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Ansi), CLSCompliant(false)]
  1808. public static extern int GetVolumeNameForVolumeMountPointA(string lpszVolumeMountPoint, StringBuilder lpszVolumeName, uint cchBufferLength);
  1809. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1810. public static extern int GetVolumeNameForVolumeMountPointW(IntPtr lpszVolumeMountPoint, IntPtr lpszVolumeName, uint cchBufferLength);
  1811. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Unicode), CLSCompliant(false)]
  1812. public static extern int GetVolumeNameForVolumeMountPointW(string lpszVolumeMountPoint, StringBuilder lpszVolumeName, uint cchBufferLength);
  1813. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1814. public static extern int GetVolumePathNameA(IntPtr lpszFileName, IntPtr lpszVolumePathName, uint cchBufferLength);
  1815. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Ansi), CLSCompliant(false)]
  1816. public static extern int GetVolumePathNameA(string lpszFileName, StringBuilder lpszVolumePathName, uint cchBufferLength);
  1817. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1818. public static extern int GetVolumePathNameW(IntPtr lpszFileName, IntPtr lpszVolumePathName, uint cchBufferLength);
  1819. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Unicode), CLSCompliant(false)]
  1820. public static extern int GetVolumePathNameW(string lpszFileName, StringBuilder lpszVolumePathName, uint cchBufferLength);
  1821. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1822. public static extern int GetVolumePathNamesForVolumeNameA(IntPtr lpszVolumeName, IntPtr lpszVolumePathNames, uint cchBufferLength, IntPtr lpcchReturnLength);
  1823. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Ansi), CLSCompliant(false)]
  1824. public static extern int GetVolumePathNamesForVolumeNameA(string lpszVolumeName, StringBuilder lpszVolumePathNames, uint cchBufferLength, ref uint lpcchReturnLength);
  1825. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1826. public static extern int GetVolumePathNamesForVolumeNameW(IntPtr lpszVolumeName, IntPtr lpszVolumePathNames, uint cchBufferLength, IntPtr lpcchReturnLength);
  1827. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Unicode), CLSCompliant(false)]
  1828. public static extern int GetVolumePathNamesForVolumeNameW(string lpszVolumeName, StringBuilder lpszVolumePathNames, uint cchBufferLength, ref uint lpcchReturnLength);
  1829. [DllImport(ModuleName, SetLastError = true)]
  1830. public static extern int SetVolumeMountPointA(IntPtr lpszVolumeMountPoint, IntPtr lpszVolumeName);
  1831. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Ansi)]
  1832. public static extern int SetVolumeMountPointA(string lpszVolumeMountPoint, string lpszVolumeName);
  1833. [DllImport(ModuleName, SetLastError = true)]
  1834. public static extern int SetVolumeMountPointW(IntPtr lpszVolumeMountPoint, IntPtr lpszVolumeName);
  1835. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Unicode)]
  1836. public static extern int SetVolumeMountPointW(string lpszVolumeMountPoint, string lpszVolumeName);
  1837. }
  1838. #endregion // File system functions (mount points)
  1839. #region Tape backup functions
  1840. partial class kernel32
  1841. {
  1842. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1843. public static extern int BackupRead(
  1844. [In] IntPtr hFile,
  1845. [Out] IntPtr lpBuffer,
  1846. [In] uint nNumberOfBytesToRead,
  1847. [Out] IntPtr lpNumberOfBytesRead,
  1848. [In] int bAbort,
  1849. [In] int bProcessSecurity,
  1850. [Out] IntPtr lpContext);
  1851. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1852. public static extern int BackupRead(
  1853. [In] IntPtr hFile,
  1854. [Out] IntPtr lpBuffer,
  1855. [In] uint nNumberOfBytesToRead,
  1856. [Out] out uint lpNumberOfBytesRead,
  1857. [In] int bAbort,
  1858. [In] int bProcessSecurity,
  1859. [Out] IntPtr lpContext);
  1860. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1861. public static extern int BackupSeek(
  1862. [In] IntPtr hFile,
  1863. [In] uint dwLowBytesToSeek,
  1864. [In] uint dwHighBytesToSeek,
  1865. [Out] IntPtr lpdwLowBytesSeeked,
  1866. [Out] IntPtr lpdwHighBytesSeeked,
  1867. [In] IntPtr lpContext);
  1868. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1869. public static extern int BackupSeek(
  1870. [In] IntPtr hFile,
  1871. [In] uint dwLowBytesToSeek,
  1872. [In] uint dwHighBytesToSeek,
  1873. [Out] out uint lpdwLowBytesSeeked,
  1874. [Out] out uint lpdwHighBytesSeeked,
  1875. [In] IntPtr lpContext);
  1876. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1877. public static extern int BackupWrite(
  1878. [In] IntPtr hFile,
  1879. [In] IntPtr lpBuffer,
  1880. [In] uint nNumberOfBytesToWrite,
  1881. [Out] IntPtr lpNumberOfBytesWritten,
  1882. [In] int bAbort,
  1883. [In] int bProcessSecurity,
  1884. [Out] IntPtr lpContext);
  1885. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1886. public static extern int BackupWrite(
  1887. [In] IntPtr hFile,
  1888. [In] IntPtr lpBuffer,
  1889. [In] uint nNumberOfBytesToWrite,
  1890. [Out] out uint lpNumberOfBytesWritten,
  1891. [In] int bAbort,
  1892. [In] int bProcessSecurity,
  1893. [Out] IntPtr lpContext);
  1894. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1895. public static extern uint CreateTapePartition(
  1896. [In] IntPtr hDevice,
  1897. [In] uint dwPartitionMethod,
  1898. [In] uint dwCount,
  1899. [In] uint dwSize);
  1900. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1901. public static extern uint EraseType(
  1902. [In] IntPtr hDevice,
  1903. [In] uint dwEraseType,
  1904. [In] int bImmediate);
  1905. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1906. public static extern uint GetTapeParameters(
  1907. [In] IntPtr hDevice,
  1908. [In] uint dwOperation,
  1909. [Out] IntPtr lpdwSize,
  1910. [Out] IntPtr lpTapeInformation);
  1911. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1912. public static extern uint GetTapeParameters(
  1913. [In] IntPtr hDevice,
  1914. [In] uint dwOperation,
  1915. [Out] out uint lpdwSize,
  1916. [Out] IntPtr lpTapeInformation);
  1917. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1918. public static extern uint GetTapeParameters(
  1919. [In] IntPtr hDevice,
  1920. [In] uint dwOperation,
  1921. [Out] out uint lpdwSize,
  1922. [Out] out TAPE_GET_MEDIA_PARAMETERS lpTapeInformation);
  1923. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1924. public static extern uint GetTapeParameters(
  1925. [In] IntPtr hDevice,
  1926. [In] uint dwOperation,
  1927. [Out] out uint lpdwSize,
  1928. [Out] out TAPE_GET_DRIVE_PARAMETERS lpTapeInformation);
  1929. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1930. public static extern uint GetTapePosition(
  1931. [In] IntPtr hDevice,
  1932. [In] uint dwPositionType,
  1933. [Out] IntPtr lpdwPartition,
  1934. [Out] IntPtr lpdwOffsetLow,
  1935. [Out] IntPtr lpdwOffsetHigh);
  1936. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1937. public static extern uint GetTapePosition(
  1938. [In] IntPtr hDevice,
  1939. [In] uint dwPositionType,
  1940. [Out] out uint lpdwPartition,
  1941. [Out] out uint lpdwOffsetLow,
  1942. [Out] out uint lpdwOffsetHigh);
  1943. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1944. public static extern uint GetTapeStatus(
  1945. [In] IntPtr hDevice);
  1946. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1947. public static extern uint PrepareTape(
  1948. [In] IntPtr hDevice,
  1949. [In] uint dwOperation,
  1950. [In] int bImmediate);
  1951. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1952. public static extern uint SetTapeParameters(
  1953. [In] IntPtr hDevice,
  1954. [In] uint dwOperation,
  1955. [In] IntPtr lpTapeInformation);
  1956. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1957. public static extern uint SetTapePosition(
  1958. [In] IntPtr hDevice,
  1959. [In] uint dwPositionMethod,
  1960. [In] uint dwPartition,
  1961. [In] uint dwOffsetLow,
  1962. [In] uint dwOffsetHigh,
  1963. [In] int bImmediate);
  1964. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1965. public static extern uint WriteTapemark(
  1966. [In] IntPtr hDevice,
  1967. [In] uint dwTapemarkType,
  1968. [In] uint dwTapemarkCount,
  1969. [In] int bImmediate);
  1970. }
  1971. #endregion // Tape backup functions
  1972. #region Handle and object functions
  1973. partial class kernel32
  1974. {
  1975. [DllImport(ModuleName, SetLastError = true)]
  1976. public static extern int CloseHandle(IntPtr hObject);
  1977. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1978. public static extern int DuplicateHandle(IntPtr hSourceProcessHandle, IntPtr hSourceHandle, IntPtr hTargetProcessHandle, IntPtr lpTargetHandle, uint dwDesiredAccess, int bInheritHandle, uint dwOptions);
  1979. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1980. public static extern int DuplicateHandle(IntPtr hSourceProcessHandle, IntPtr hSourceHandle, IntPtr hTargetProcessHandle, ref IntPtr lpTargetHandle, uint dwDesiredAccess, int bInheritHandle, uint dwOptions);
  1981. [DllImport(ModuleName, SetLastError = true)]
  1982. public static extern int GetHandleInformation(IntPtr hObject, IntPtr lpdwFlags);
  1983. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1984. public static extern int GetHandleInformation(IntPtr hObject, ref uint lpdwFlags);
  1985. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  1986. public static extern int SetHandleInformation(IntPtr hObject, uint dwMask, uint dwFlags);
  1987. }
  1988. #endregion // Handle and object functions
  1989. #region Large integer operation functions
  1990. partial class kernel32
  1991. {
  1992. [DllImport(ModuleName)]
  1993. public static extern int MulDiv(int nNumber, int nNumerator, int nDenominator);
  1994. }
  1995. #endregion // Large integer operation functions
  1996. #region Memory management functions
  1997. partial class kernel32
  1998. {
  1999. [DllImport(ModuleName), CLSCompliant(false)]
  2000. public static extern void CopyMemory(IntPtr Destination, IntPtr Source, uint Length);
  2001. [DllImport(ModuleName), CLSCompliant(false)]
  2002. public static extern void FillMemory(IntPtr Destination, uint Length, byte Fill);
  2003. [DllImport(ModuleName, SetLastError = true)]
  2004. public static extern IntPtr GetProcessHeap();
  2005. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2006. public static extern uint GetProcessHeaps(uint NumberOfHeaps, IntPtr ProcessHeaps);
  2007. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2008. public static extern uint GetProcessHeaps(uint NumberOfHeaps, ref IntPtr ProcessHeaps);
  2009. [DllImport(ModuleName)]
  2010. public static extern void GlobalMemoryStatus(IntPtr lpBuffer);
  2011. [DllImport(ModuleName), CLSCompliant(false)]
  2012. public static extern void GlobalMemoryStatus(ref MEMORYSTATUS lpBuffer);
  2013. [DllImport(ModuleName), CLSCompliant(false)]
  2014. public static extern IntPtr HeapAlloc(IntPtr hHeap, uint dwFlags, uint dwBytes);
  2015. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2016. public static extern uint HeapCompact(IntPtr hHeap, uint dwFlags);
  2017. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2018. public static extern IntPtr HeapCreate(uint flOptions, uint dwInitialSize, uint dwMaximumSize);
  2019. [DllImport(ModuleName, SetLastError = true)]
  2020. public static extern int HeapDestroy(IntPtr hHeap);
  2021. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2022. public static extern int HeapFree(IntPtr hHeap, uint dwFlags, IntPtr lpMem);
  2023. [DllImport(ModuleName, SetLastError = true)]
  2024. public static extern int HeapLock(IntPtr hHeap);
  2025. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2026. public static extern IntPtr HeapReAlloc(IntPtr hHeap, uint dwFlags, IntPtr lpMem, uint dwBytes);
  2027. [DllImport(ModuleName), CLSCompliant(false)]
  2028. public static extern uint HeapSize(IntPtr hHeap, uint dwFlags, IntPtr lpMem);
  2029. [DllImport(ModuleName, SetLastError = true)]
  2030. public static extern int HeapUnlock(IntPtr hHeap);
  2031. [DllImport(ModuleName), CLSCompliant(false)]
  2032. public static extern int HeapValidate(IntPtr hHeap, uint dwFlags, IntPtr lpMem);
  2033. [DllImport(ModuleName, SetLastError = true)]
  2034. public static extern int HeapWalk(IntPtr hHeap, IntPtr lpEntry);
  2035. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2036. public static extern int HeapWalk(IntPtr hHeap, ref PROCESS_HEAP_ENTRY lpEntry);
  2037. [DllImport(ModuleName, SetLastError = true)]
  2038. public static extern int IsBadCodePtr(IntPtr lpfn);
  2039. [DllImport(ModuleName), CLSCompliant(false)]
  2040. public static extern int IsBadReadPtr(IntPtr lp, uint ucb);
  2041. [DllImport(ModuleName), CLSCompliant(false)]
  2042. public static extern int IsBadStringPtrA(IntPtr lpsz, uint ucchMax);
  2043. [DllImport(ModuleName, CharSet = CharSet.Ansi), CLSCompliant(false)]
  2044. public static extern int IsBadStringPtrA(string lpsz, uint ucchMax);
  2045. [DllImport(ModuleName), CLSCompliant(false)]
  2046. public static extern int IsBadStringPtrW(IntPtr lpsz, uint ucchMax);
  2047. [DllImport(ModuleName, CharSet = CharSet.Unicode), CLSCompliant(false)]
  2048. public static extern int IsBadStringPtrW(string lpsz, uint ucchMax);
  2049. [DllImport(ModuleName), CLSCompliant(false)]
  2050. public static extern int IsBadWritePtr(IntPtr lp, uint ucb);
  2051. [DllImport(ModuleName), CLSCompliant(false)]
  2052. public static extern void MoveMemory(IntPtr Destination, IntPtr Source, uint Length);
  2053. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2054. public static extern IntPtr VirtualAlloc(IntPtr lpAddress, uint dwSize, uint flAllocationType, uint flProtect);
  2055. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2056. public static extern IntPtr VirtualAllocEx(IntPtr hProcess, IntPtr lpAddress, uint dwSize, uint flAllocationType, uint flProtect);
  2057. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2058. public static extern int VirtualFree(IntPtr lpAddress, uint dwSize, uint dwFreeType);
  2059. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2060. public static extern int VirtualFreeEx(IntPtr hProcess, IntPtr lpAddress, uint dwSize, uint dwFreeType);
  2061. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2062. public static extern int VirtualLock(IntPtr lpAddress, uint dwSize);
  2063. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2064. public static extern int VirtualProtect(IntPtr lpAddress, uint dwSize, uint flNewProtect, IntPtr lpflOldProtect);
  2065. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2066. public static extern int VirtualProtect(IntPtr lpAddress, uint dwSize, uint flNewProtect, ref uint lpflOldProtect);
  2067. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2068. public static extern int VirtualProtectEx(IntPtr hProcess, IntPtr lpAddress, uint dwSize, uint flNewProtect, IntPtr lpflOldProtect);
  2069. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2070. public static extern int VirtualProtectEx(IntPtr hProcess, IntPtr lpAddress, uint dwSize, uint flNewProtect, ref uint lpflOldProtect);
  2071. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2072. public static extern uint VirtualQuery(IntPtr lpAddress, IntPtr lpBuffer, uint dwLength);
  2073. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2074. public static extern uint VirtualQuery(IntPtr lpAddress, ref MEMORY_BASIC_INFORMATION lpBuffer, uint dwLength);
  2075. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2076. public static extern uint VirtualQueryEx(IntPtr hProcess, IntPtr lpAddress, IntPtr lpBuffer, uint dwLength);
  2077. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2078. public static extern uint VirtualQueryEx(IntPtr hProcess, IntPtr lpAddress, ref MEMORY_BASIC_INFORMATION lpBuffer, uint dwLength);
  2079. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2080. public static extern int VirtualUnlock(IntPtr lpAddress, uint dwSize);
  2081. [DllImport(ModuleName), CLSCompliant(false)]
  2082. public static extern void ZeroMemory(IntPtr Destination, uint Length);
  2083. }
  2084. #endregion // Memory management functions
  2085. #region Global and local functions
  2086. partial class kernel32
  2087. {
  2088. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2089. public static extern IntPtr GlobalAlloc(uint uFlags, uint dwBytes);
  2090. [DllImport(ModuleName, SetLastError = true)]
  2091. public static extern IntPtr GlobalDiscard(IntPtr hglbMem);
  2092. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2093. public static extern uint GlobalFlags(IntPtr hMem);
  2094. [DllImport(ModuleName, SetLastError = true)]
  2095. public static extern IntPtr GlobalFree(IntPtr hMem);
  2096. [DllImport(ModuleName, SetLastError = true)]
  2097. public static extern IntPtr GlobalHandle(IntPtr pMem);
  2098. [DllImport(ModuleName, SetLastError = true)]
  2099. public static extern IntPtr GlobalLock(IntPtr hMem);
  2100. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2101. public static extern IntPtr GlobalReAlloc(IntPtr hMem, uint dwBytes, uint uFlags);
  2102. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2103. public static extern uint GlobalSize(IntPtr hMem);
  2104. [DllImport(ModuleName, SetLastError = true)]
  2105. public static extern int GlobalUnlock(IntPtr hMem);
  2106. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2107. public static extern IntPtr LocalAlloc(uint uFlags, uint dwBytes);
  2108. [DllImport(ModuleName, SetLastError = true)]
  2109. public static extern IntPtr LocalDiscard(IntPtr hlocMem);
  2110. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2111. public static extern uint LocalFlags(IntPtr hMem);
  2112. [DllImport(ModuleName, SetLastError = true)]
  2113. public static extern IntPtr LocalFree(IntPtr hMem);
  2114. [DllImport(ModuleName, SetLastError = true)]
  2115. public static extern IntPtr LocalHandle(IntPtr pMem);
  2116. [DllImport(ModuleName, SetLastError = true)]
  2117. public static extern IntPtr LocalLock(IntPtr hMem);
  2118. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2119. public static extern IntPtr LocalReAlloc(IntPtr hMem, uint uBytes, uint uFlags);
  2120. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2121. public static extern uint LocalSize(IntPtr hMem);
  2122. [DllImport(ModuleName, SetLastError = true)]
  2123. public static extern int LocalUnlock(IntPtr hMem);
  2124. // Missing obsolete functions:
  2125. // GlobalCompact, GlobalFix, GlobalUnfix, GlobalUnWire, GlobalWire, IsBadHugeReadPtr, IsBadHugeWritePtr, LocalCompact, LocalShrink
  2126. }
  2127. #endregion // Global and local functions
  2128. #region String manipulation functions
  2129. partial class kernel32
  2130. {
  2131. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2132. public static extern int CompareStringA(LCID Locale, uint dwCmpFlags, IntPtr lpString1, int cchCount1, IntPtr lpString2, int cchCount2);
  2133. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Ansi), CLSCompliant(false)]
  2134. public static extern int CompareStringA(LCID Locale, uint dwCmpFlags, string lpString1, int cchCount1, string lpString2, int cchCount2);
  2135. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2136. public static extern int CompareStringW(LCID Locale, uint dwCmpFlags, IntPtr lpString1, int cchCount1, IntPtr lpString2, int cchCount2);
  2137. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Unicode), CLSCompliant(false)]
  2138. public static extern int CompareStringW(LCID Locale, uint dwCmpFlags, string lpString1, int cchCount1, string lpString2, int cchCount2);
  2139. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2140. public static extern int FoldStringA(uint dwMapFlags, IntPtr lpSrcStr, int cchSrc, IntPtr lpDestStr, int cchDest);
  2141. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Ansi), CLSCompliant(false)]
  2142. public static extern int FoldStringA(uint dwMapFlags, string lpSrcStr, int cchSrc, StringBuilder lpDestStr, int cchDest);
  2143. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2144. public static extern int FoldStringW(uint dwMapFlags, IntPtr lpSrcStr, int cchSrc, IntPtr lpDestStr, int cchDest);
  2145. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Unicode), CLSCompliant(false)]
  2146. public static extern int FoldStringW(uint dwMapFlags, string lpSrcStr, int cchSrc, StringBuilder lpDestStr, int cchDest);
  2147. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2148. public static extern int GetStringTypeA(LCID Locale, uint dwInfoType, IntPtr lpSrcStr, int cchSrc, IntPtr lpCharType);
  2149. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Ansi), CLSCompliant(false)]
  2150. public static extern int GetStringTypeA(LCID Locale, uint dwInfoType, string lpSrcStr, int cchSrc, ref uint lpCharType);
  2151. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2152. public static extern int GetStringTypeW(LCID Locale, uint dwInfoType, IntPtr lpSrcStr, int cchSrc, IntPtr lpCharType);
  2153. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Unicode), CLSCompliant(false)]
  2154. public static extern int GetStringTypeW(LCID Locale, uint dwInfoType, string lpSrcStr, int cchSrc, ref uint lpCharType);
  2155. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2156. public static extern int GetStringTypeExA(LCID Locale, uint dwInfoType, IntPtr lpSrcStr, int cchSrc, IntPtr lpCharType);
  2157. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Ansi), CLSCompliant(false)]
  2158. public static extern int GetStringTypeExA(LCID Locale, uint dwInfoType, string lpSrcStr, int cchSrc, ref uint lpCharType);
  2159. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2160. public static extern int GetStringTypeExW(LCID Locale, uint dwInfoType, IntPtr lpSrcStr, int cchSrc, IntPtr lpCharType);
  2161. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Unicode), CLSCompliant(false)]
  2162. public static extern int GetStringTypeExW(LCID Locale, uint dwInfoType, string lpSrcStr, int cchSrc, ref uint lpCharType);
  2163. [DllImport(ModuleName, ExactSpelling = true, SetLastError = true)]
  2164. public static extern IntPtr lstrcat(IntPtr lpString1, IntPtr lpString2);
  2165. [DllImport(ModuleName, CharSet = CharSet.Auto, ExactSpelling = true, SetLastError = true)]
  2166. public static extern string lstrcat(StringBuilder lpString1, string lpString2);
  2167. [DllImport(ModuleName, ExactSpelling = true, SetLastError = true)]
  2168. public static extern IntPtr lstrcatA(IntPtr lpString1, IntPtr lpString2);
  2169. [DllImport(ModuleName, CharSet = CharSet.Ansi, ExactSpelling = true, SetLastError = true)]
  2170. public static extern string lstrcatA(StringBuilder lpString1, string lpString2);
  2171. [DllImport(ModuleName, ExactSpelling = true, SetLastError = true)]
  2172. public static extern IntPtr lstrcatW(IntPtr lpString1, IntPtr lpString2);
  2173. [DllImport(ModuleName, CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)]
  2174. public static extern string lstrcatW(StringBuilder lpString1, string lpString2);
  2175. [DllImport(ModuleName, ExactSpelling = true, SetLastError = true)]
  2176. public static extern int lstrcmp(IntPtr lpString1, IntPtr lpString2);
  2177. [DllImport(ModuleName, CharSet = CharSet.Auto, ExactSpelling = true, SetLastError = true)]
  2178. public static extern int lstrcmp(string lpString1, string lpString2);
  2179. [DllImport(ModuleName, ExactSpelling = true, SetLastError = true)]
  2180. public static extern int lstrcmpA(IntPtr lpString1, IntPtr lpString2);
  2181. [DllImport(ModuleName, CharSet = CharSet.Ansi, ExactSpelling = true, SetLastError = true)]
  2182. public static extern int lstrcmpA(string lpString1, string lpString2);
  2183. [DllImport(ModuleName, ExactSpelling = true, SetLastError = true)]
  2184. public static extern int lstrcmpW(IntPtr lpString1, IntPtr lpString2);
  2185. [DllImport(ModuleName, CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)]
  2186. public static extern int lstrcmpW(string lpString1, string lpString2);
  2187. [DllImport(ModuleName, ExactSpelling = true, SetLastError = true)]
  2188. public static extern int lstrcmpi(IntPtr lpString1, IntPtr lpString2);
  2189. [DllImport(ModuleName, CharSet = CharSet.Auto, ExactSpelling = true, SetLastError = true)]
  2190. public static extern int lstrcmpi(string lpString1, string lpString2);
  2191. [DllImport(ModuleName, ExactSpelling = true, SetLastError = true)]
  2192. public static extern int lstrcmpiA(IntPtr lpString1, IntPtr lpString2);
  2193. [DllImport(ModuleName, CharSet = CharSet.Ansi, ExactSpelling = true, SetLastError = true)]
  2194. public static extern int lstrcmpiA(string lpString1, string lpString2);
  2195. [DllImport(ModuleName, ExactSpelling = true, SetLastError = true)]
  2196. public static extern int lstrcmpiW(IntPtr lpString1, IntPtr lpString2);
  2197. [DllImport(ModuleName, CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)]
  2198. public static extern int lstrcmpiW(string lpString1, string lpString2);
  2199. [DllImport(ModuleName, ExactSpelling = true, SetLastError = true)]
  2200. public static extern IntPtr lstrcpy(IntPtr lpString1, IntPtr lpString2);
  2201. [DllImport(ModuleName, CharSet = CharSet.Auto, ExactSpelling = true, SetLastError = true)]
  2202. public static extern string lstrcpy(StringBuilder lpString1, string lpString2);
  2203. [DllImport(ModuleName, ExactSpelling = true, SetLastError = true)]
  2204. public static extern IntPtr lstrcpyA(IntPtr lpString1, IntPtr lpString2);
  2205. [DllImport(ModuleName, CharSet = CharSet.Ansi, ExactSpelling = true, SetLastError = true)]
  2206. public static extern string lstrcpyA(StringBuilder lpString1, string lpString2);
  2207. [DllImport(ModuleName, ExactSpelling = true, SetLastError = true)]
  2208. public static extern IntPtr lstrcpyW(IntPtr lpString1, IntPtr lpString2);
  2209. [DllImport(ModuleName, CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)]
  2210. public static extern string lstrcpyW(StringBuilder lpString1, string lpString2);
  2211. [DllImport(ModuleName, ExactSpelling = true, SetLastError = true)]
  2212. public static extern IntPtr lstrcpyn(IntPtr lpString1, IntPtr lpString2, int iMaxLength);
  2213. [DllImport(ModuleName, CharSet = CharSet.Auto, ExactSpelling = true, SetLastError = true)]
  2214. public static extern string lstrcpyn(StringBuilder lpString1, string lpString2, int iMaxLength);
  2215. [DllImport(ModuleName, ExactSpelling = true, SetLastError = true)]
  2216. public static extern IntPtr lstrcpynA(IntPtr lpString1, IntPtr lpString2, int iMaxLength);
  2217. [DllImport(ModuleName, CharSet = CharSet.Ansi, ExactSpelling = true, SetLastError = true)]
  2218. public static extern string lstrcpynA(StringBuilder lpString1, string lpString2, int iMaxLength);
  2219. [DllImport(ModuleName, ExactSpelling = true, SetLastError = true)]
  2220. public static extern IntPtr lstrcpynW(IntPtr lpString1, IntPtr lpString2, int iMaxLength);
  2221. [DllImport(ModuleName, CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)]
  2222. public static extern string lstrcpynW(StringBuilder lpString1, string lpString2, int iMaxLength);
  2223. [DllImport(ModuleName, ExactSpelling = true, SetLastError = true)]
  2224. public static extern int lstrlen(IntPtr lpString);
  2225. [DllImport(ModuleName, CharSet = CharSet.Auto, ExactSpelling = true, SetLastError = true)]
  2226. public static extern int lstrlen(string lpString);
  2227. [DllImport(ModuleName, ExactSpelling = true, SetLastError = true)]
  2228. public static extern int lstrlenA(IntPtr lpString);
  2229. [DllImport(ModuleName, CharSet = CharSet.Ansi, ExactSpelling = true, SetLastError = true)]
  2230. public static extern int lstrlenA(string lpString);
  2231. [DllImport(ModuleName, ExactSpelling = true, SetLastError = true)]
  2232. public static extern int lstrlenW(IntPtr lpString);
  2233. [DllImport(ModuleName, CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)]
  2234. public static extern int lstrlenW(string lpString);
  2235. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2236. public static extern int MultiByteToWideChar(uint CodePage, uint dwFlags, IntPtr lpMultiByteStr, int cchMultiByte, IntPtr lpWideCharStr, int cchWideChar);
  2237. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Ansi), CLSCompliant(false)]
  2238. public static extern int MultiByteToWideChar(uint CodePage, uint dwFlags, string lpMultiByteStr, int cchMultiByte, IntPtr lpWideCharStr, int cchWideChar);
  2239. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2240. public static extern int WideCharToMultiByte(uint CodePage, uint dwFlags, IntPtr lpWideCharStr, int cchWideChar, IntPtr lpMultiByteStr, int cchMultiByte, IntPtr lpDefaultChar, IntPtr lpUsedDefaultChar);
  2241. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Unicode), CLSCompliant(false)]
  2242. public static extern int WideCharToMultiByte(uint CodePage, uint dwFlags, string lpWideCharStr, int cchWideChar, IntPtr lpMultiByteStr, int cchMultiByte, [MarshalAs(UnmanagedType.LPStr)] string lpDefaultChar, ref int lpUsedDefaultChar);
  2243. }
  2244. #endregion // String manipulation functions
  2245. #region Time functions
  2246. partial class kernel32
  2247. {
  2248. [DllImport(ModuleName)]
  2249. public static extern int CompareFileTime(IntPtr lpFileTime1, IntPtr lpFileTime2);
  2250. [DllImport(ModuleName), CLSCompliant(false)]
  2251. public static extern int CompareFileTime(ref FILETIME lpFileTime1, ref FILETIME lpFileTime2);
  2252. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2253. public static extern int DosDateTimeToFileTime(ushort wFatDate, ushort sFatTime, IntPtr lpFileTime);
  2254. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2255. public static extern int DosDateTimeToFileTime(ushort wFatDate, ushort sFatTime, ref FILETIME lpFileTime);
  2256. [DllImport(ModuleName, SetLastError = true)]
  2257. public static extern int FileTimeToDosDateTime(IntPtr lpFileTime, IntPtr lpFatDate, IntPtr lpFatTime);
  2258. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2259. public static extern int FileTimeToDosDateTime(ref FILETIME lpFileTime, ref ushort lpFatDate, ref ushort lpFatTime);
  2260. [DllImport(ModuleName, SetLastError = true)]
  2261. public static extern int FileTimeToLocalFileTime(IntPtr lpFileTime, IntPtr lpLocalFileTime);
  2262. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2263. public static extern int FileTimeToLocalFileTime(ref FILETIME lpFileTime, ref FILETIME lpLocalFileTime);
  2264. [DllImport(ModuleName, SetLastError = true)]
  2265. public static extern int FileTimeToSystemTime(IntPtr lpFileTime, IntPtr lpSystemTime);
  2266. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2267. public static extern int FileTimeToSystemTime(ref FILETIME lpFileTime, ref SYSTEMTIME lpSystemTime);
  2268. [DllImport(ModuleName, SetLastError = true)]
  2269. public static extern int GetFileTime(IntPtr hFile, IntPtr lpCreationTime, IntPtr lpLastAccessTime, IntPtr lpLastWriteTime);
  2270. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2271. public static extern int GetFileTime(IntPtr hFile, ref FILETIME lpCreationTime, ref FILETIME lpLastAccessTime, ref FILETIME lpLastWriteTime);
  2272. [DllImport(ModuleName, SetLastError = true)]
  2273. public static extern void GetSystemTime(IntPtr lpSystemTime);
  2274. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2275. public static extern void GetSystemTime(ref SYSTEMTIME lpSystemTime);
  2276. [DllImport(ModuleName, SetLastError = true)]
  2277. public static extern int GetSystemTimeAdjustment(IntPtr lpTimeAdjustment, IntPtr lpTimeIncrement, IntPtr lpTimeAdjustmentDisabled);
  2278. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2279. public static extern int GetSystemTimeAdjustment(ref uint lpTimeAdjustment, ref uint lpTimeIncrement, ref int lpTimeAdjustmentDisabled);
  2280. [DllImport(ModuleName, SetLastError = true)]
  2281. public static extern void GetSystemTimeAsFileTime(IntPtr lpSystemTimeAsFileTime);
  2282. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2283. public static extern void GetSystemTimeAsFileTime(ref FILETIME lpSystemTimeAsFileTime);
  2284. [DllImport(ModuleName), CLSCompliant(false)]
  2285. public static extern uint GetTickCount();
  2286. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2287. public static extern uint GetTimeZoneInformation(IntPtr lpTimeZoneInformation);
  2288. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2289. public static extern uint GetTimeZoneInformation(ref TIME_ZONE_INFORMATION lpTimeZoneInformation);
  2290. [DllImport(ModuleName, SetLastError = true)]
  2291. public static extern int LocalFileTimeToFileTime(IntPtr lpLocalFileTime, IntPtr lpFileTime);
  2292. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2293. public static extern int LocalFileTimeToFileTime(ref FILETIME lpLocalFileTime, ref FILETIME lpFileTime);
  2294. [DllImport(ModuleName, SetLastError = true)]
  2295. public static extern int SetFileTime(IntPtr hFile, IntPtr lpCreationTime, IntPtr lpLastAccessTime, IntPtr lpLastWriteTime);
  2296. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2297. public static extern int SetFileTime(IntPtr hFile, ref FILETIME lpCreationTime, ref FILETIME lpLastAccessTime, ref FILETIME lpLastWriteTime);
  2298. [DllImport(ModuleName, SetLastError = true)]
  2299. public static extern int SetLocalTime(IntPtr lpSystemTime);
  2300. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2301. public static extern int SetLocalTime(ref SYSTEMTIME lpSystemTime);
  2302. [DllImport(ModuleName, SetLastError = true)]
  2303. public static extern int SetSystemTime(IntPtr lpSystemTime);
  2304. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2305. public static extern int SetSystemTime(ref SYSTEMTIME lpSystemTime);
  2306. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2307. public static extern int SetSystemTimeAdjustment(uint dwTimeAdjustment, int bTimeAdjustmentDisabled);
  2308. [DllImport(ModuleName, SetLastError = true)]
  2309. public static extern int SetTimeZoneInformation(IntPtr lpTimeZoneInformation);
  2310. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2311. public static extern int SetTimeZoneInformation(ref TIME_ZONE_INFORMATION lpTimeZoneInformation);
  2312. [DllImport(ModuleName, SetLastError = true)]
  2313. public static extern int SystemTimeToFileTime(IntPtr lpSystemTime, IntPtr lpFileTime);
  2314. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2315. public static extern int SystemTimeToFileTime(ref SYSTEMTIME lpSystemTime, ref FILETIME lpFileTime);
  2316. [DllImport(ModuleName, SetLastError = true)]
  2317. public static extern int SystemTimeToTzSpecificLocalTime(IntPtr lpTimeZoneInformation, IntPtr lpUniversalTime, IntPtr lpLocalTime);
  2318. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2319. public static extern int SystemTimeToTzSpecificLocalTime(ref TIME_ZONE_INFORMATION lpTimeZoneInformation, ref SYSTEMTIME lpUniversalTime, ref SYSTEMTIME lpLocalTime);
  2320. }
  2321. #endregion // Time functions
  2322. #region Communication functions
  2323. partial class kernel32
  2324. {
  2325. [DllImport(ModuleName, SetLastError = true)]
  2326. public static extern int BuildCommDCBA(
  2327. [In] IntPtr lpDef,
  2328. [Out] IntPtr lpDCB);
  2329. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Ansi), CLSCompliant(false)]
  2330. public static extern int BuildCommDCBA(
  2331. [In] string lpDef,
  2332. [Out] out DCB lpDCB);
  2333. [DllImport(ModuleName, SetLastError = true)]
  2334. public static extern int BuildCommDCBW(
  2335. [In] IntPtr lpDef,
  2336. [Out] IntPtr lpDCB);
  2337. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Unicode), CLSCompliant(false)]
  2338. public static extern int BuildCommDCBW(
  2339. [In] string lpDef,
  2340. [Out] out DCB lpDCB);
  2341. [DllImport(ModuleName, SetLastError = true)]
  2342. public static extern int BuildCommDCBAndTimeoutsA(
  2343. [In] IntPtr lpDef,
  2344. [Out] IntPtr lpDCB,
  2345. [Out] IntPtr lpCommTimeouts);
  2346. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Ansi), CLSCompliant(false)]
  2347. public static extern int BuildCommDCBAndTimeoutsA(
  2348. [In] string lpDef,
  2349. [Out] out DCB lpDCB,
  2350. [Out] out COMMTIMEOUTS lpCommTimeouts);
  2351. [DllImport(ModuleName, SetLastError = true)]
  2352. public static extern int BuildCommDCBAndTimeoutsW(
  2353. [In] IntPtr lpDef,
  2354. [Out] IntPtr lpDCB,
  2355. [Out] IntPtr lpCommTimeouts);
  2356. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Unicode), CLSCompliant(false)]
  2357. public static extern int BuildCommDCBAndTimeoutsW(
  2358. [In] string lpDef,
  2359. [Out] out DCB lpDCB,
  2360. [Out] out COMMTIMEOUTS lpCommTimeouts);
  2361. [DllImport(ModuleName, SetLastError = true)]
  2362. public static extern int ClearCommBreak(
  2363. [In] IntPtr hFile);
  2364. [DllImport(ModuleName, SetLastError = true)]
  2365. public static extern int ClearCommError(
  2366. [In] IntPtr hFile,
  2367. [Out] IntPtr lpErrors,
  2368. [Out] IntPtr lpStat);
  2369. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2370. public static extern int ClearCommError(
  2371. [In] IntPtr hFile,
  2372. [Out] out uint lpErrors,
  2373. [Out] out COMSTAT lpStat);
  2374. [DllImport(ModuleName, SetLastError = true)]
  2375. public static extern int CommConfigDialogA(
  2376. [In] IntPtr lpszName,
  2377. [In] IntPtr hWnd,
  2378. [In, Out] IntPtr lpCC);
  2379. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Ansi), CLSCompliant(false)]
  2380. public static extern int CommConfigDialogA(
  2381. [In] string lpszName,
  2382. [In] IntPtr hWnd,
  2383. [In, Out] ref COMMCONFIG lpCC);
  2384. [DllImport(ModuleName, SetLastError = true)]
  2385. public static extern int CommConfigDialogW(
  2386. [In] IntPtr lpszName,
  2387. [In] IntPtr hWnd,
  2388. [In, Out] IntPtr lpCC);
  2389. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Unicode), CLSCompliant(false)]
  2390. public static extern int CommConfigDialogW(
  2391. [In] string lpszName,
  2392. [In] IntPtr hWnd,
  2393. [In, Out] ref COMMCONFIG lpCC);
  2394. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2395. public static extern int EscapeCommFunction(
  2396. [In] IntPtr hFile,
  2397. [In] uint dwFunc);
  2398. [DllImport(ModuleName, SetLastError = true)]
  2399. public static extern int GetCommConfig(
  2400. [In] IntPtr hCommDev,
  2401. [Out] IntPtr lpCC,
  2402. [In, Out] IntPtr lpdwSize);
  2403. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2404. public static extern int GetCommConfig(
  2405. [In] IntPtr hCommDev,
  2406. [Out] out COMMCONFIG lpCC,
  2407. [In, Out] ref uint lpdwSize);
  2408. [DllImport(ModuleName, SetLastError = true)]
  2409. public static extern int GetCommMask(
  2410. [In] IntPtr hFIle,
  2411. [Out] IntPtr lpEvtMask);
  2412. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2413. public static extern int GetCommMask(
  2414. [In] IntPtr hFIle,
  2415. [Out] out uint lpEvtMask);
  2416. [DllImport(ModuleName, SetLastError = true)]
  2417. public static extern int GetCommModemStatus(
  2418. [In] IntPtr hFile,
  2419. [Out] IntPtr lpModemStat);
  2420. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2421. public static extern int GetCommModemStatus(
  2422. [In] IntPtr hFile,
  2423. [Out] out uint lpModemStat);
  2424. [DllImport(ModuleName, SetLastError = true)]
  2425. public static extern int GetCommProperties(
  2426. [In] IntPtr hFile,
  2427. [Out] IntPtr lpCommProp);
  2428. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2429. public static extern int GetCommProperties(
  2430. [In] IntPtr hFile,
  2431. [Out] out COMMPROP lpCommProp);
  2432. [DllImport(ModuleName, SetLastError = true)]
  2433. public static extern int GetCommState(
  2434. [In] IntPtr hFile,
  2435. [Out] IntPtr lpDCB);
  2436. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2437. public static extern int GetCommState(
  2438. [In] IntPtr hFile,
  2439. [Out] out DCB lpDCB);
  2440. [DllImport(ModuleName, SetLastError = true)]
  2441. public static extern int GetCommTimeouts(
  2442. [In] IntPtr hFile,
  2443. [Out] IntPtr lpCommTimeouts);
  2444. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2445. public static extern int GetCommTimeouts(
  2446. [In] IntPtr hFile,
  2447. [Out] out COMMTIMEOUTS lpCommTimeouts);
  2448. [DllImport(ModuleName, SetLastError = true)]
  2449. public static extern int GetDefaultCommConfig(
  2450. [In] IntPtr hCommDev,
  2451. [Out] IntPtr lpCC,
  2452. [In, Out] IntPtr lpdwSize);
  2453. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2454. public static extern int GetDefaultCommConfig(
  2455. [In] IntPtr hCommDev,
  2456. [Out] out COMMCONFIG lpCC,
  2457. [In, Out] ref uint lpdwSize);
  2458. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2459. public static extern int PurgeComm(
  2460. [In] IntPtr hFile,
  2461. [In] uint dwFlags);
  2462. [DllImport(ModuleName, SetLastError = true)]
  2463. public static extern int SetCommBreak(
  2464. [In] IntPtr hFile);
  2465. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2466. public static extern int SetCommConfig(
  2467. [In] IntPtr hCommDev,
  2468. [In] IntPtr lpCC,
  2469. [In] uint dwSize);
  2470. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2471. public static extern int SetCommConfig(
  2472. [In] IntPtr hCommDev,
  2473. [In] ref COMMCONFIG lpCC,
  2474. [In] uint dwSize);
  2475. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2476. public static extern int SetCommMask(
  2477. [In] IntPtr hFile,
  2478. [In] uint dwEvtMask);
  2479. [DllImport(ModuleName, SetLastError = true)]
  2480. public static extern int SetCommState(
  2481. [In] IntPtr hFile,
  2482. [In] IntPtr lpDCB);
  2483. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2484. public static extern int SetCommState(
  2485. [In] IntPtr hFile,
  2486. [In] ref DCB lpDCB);
  2487. [DllImport(ModuleName, SetLastError = true)]
  2488. public static extern int SetCommTimeouts(
  2489. [In] IntPtr hFile,
  2490. [In] IntPtr lpCommTimeouts);
  2491. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2492. public static extern int SetCommTimeouts(
  2493. [In] IntPtr hFile,
  2494. [In] ref COMMTIMEOUTS lpCommTimeouts);
  2495. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2496. public static extern int SetDefaultCommConfig(
  2497. [In] IntPtr hCommDev,
  2498. [In] IntPtr lpCC,
  2499. [In] uint dwSize);
  2500. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2501. public static extern int SetDefaultCommConfig(
  2502. [In] IntPtr hCommDev,
  2503. [In] ref COMMCONFIG lpCC,
  2504. [In] uint dwSize);
  2505. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2506. public static extern int SetupComm(
  2507. [In] IntPtr hFile,
  2508. [In] uint dwInQueue,
  2509. [In] uint dwOutQueue);
  2510. [DllImport(ModuleName, SetLastError = true)]
  2511. public static extern int TransmitCommChar(
  2512. [In] IntPtr hFile,
  2513. [In] byte cChar);
  2514. [DllImport(ModuleName, SetLastError = true)]
  2515. public static extern int WaitCommEvent(
  2516. [In] IntPtr hFile,
  2517. [Out] IntPtr lpEvtMask,
  2518. [In] IntPtr lpOverlapped);
  2519. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2520. public static extern int WaitCommEvent(
  2521. [In] IntPtr hFile,
  2522. [Out] out uint lpEvtMask,
  2523. [In] ref OVERLAPPED lpOverlapped);
  2524. }
  2525. #endregion // Communication functions
  2526. #region Timer functions
  2527. partial class kernel32
  2528. {
  2529. [DllImport(ModuleName, SetLastError = true)]
  2530. public static extern int QueryPerformanceCounter(IntPtr lpPerformanceCount);
  2531. [DllImport(ModuleName, SetLastError = true)]
  2532. public static extern int QueryPerformanceCounter(ref LARGE_INTEGER lpPerformanceCount);
  2533. [DllImport(ModuleName, SetLastError = true)]
  2534. public static extern int QueryPerformanceCounterFrequency(IntPtr lpPerformanceCount);
  2535. [DllImport(ModuleName, SetLastError = true)]
  2536. public static extern int QueryPerformanceCounterFrequency(ref LARGE_INTEGER lpPerformanceCount);
  2537. }
  2538. #endregion // Timer functions
  2539. #region Device input and output functions
  2540. partial class kernel32
  2541. {
  2542. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2543. public static extern int DeviceIoControl(IntPtr hDevice, uint dwIoControlCode, IntPtr lpInBuffer, uint nInBufferSize, IntPtr lpOutBuffer, uint nOutBufferSize, IntPtr lpBytesReturned, IntPtr lpOverlapped);
  2544. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2545. public static extern int DeviceIoControl(IntPtr hDevice, uint dwIoControlCode, IntPtr lpInBuffer, uint nInBufferSize, IntPtr lpOutBuffer, uint nOutBufferSize, ref uint lpBytesReturned, ref OVERLAPPED lpOverlapped);
  2546. }
  2547. #endregion // Device input and output functions
  2548. #region National language support functions
  2549. partial class kernel32
  2550. {
  2551. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2552. public static extern LCID ConvertDefaultLocale(LCID Locale);
  2553. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2554. public static extern int EnumCalendarInfoA(IntPtr lpCalInfoEnumProc, LCID Locale, CALID Calendar, CALTYPE CalType);
  2555. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Ansi), CLSCompliant(false)]
  2556. public static extern int EnumCalendarInfoA(EnumCalendarInfoProc lpCalInfoEnumProc, LCID Locale, CALID Calendar, CALTYPE CalType);
  2557. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2558. public static extern int EnumCalendarInfoW(IntPtr lpCalInfoEnumProc, LCID Locale, CALID Calendar, CALTYPE CalType);
  2559. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Unicode), CLSCompliant(false)]
  2560. public static extern int EnumCalendarInfoW(EnumCalendarInfoProc lpCalInfoEnumProc, LCID Locale, CALID Calendar, CALTYPE CalType);
  2561. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2562. public static extern int EnumCalendarInfoExA(IntPtr lpCalInfoEnumProc, LCID Locale, CALID Calendar, CALTYPE CalType);
  2563. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Ansi), CLSCompliant(false)]
  2564. public static extern int EnumCalendarInfoExA(EnumCalendarInfoProcEx lpCalInfoEnumProc, LCID Locale, CALID Calendar, CALTYPE CalType);
  2565. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2566. public static extern int EnumCalendarInfoExW(IntPtr lpCalInfoEnumProc, LCID Locale, CALID Calendar, CALTYPE CalType);
  2567. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Unicode), CLSCompliant(false)]
  2568. public static extern int EnumCalendarInfoExW(EnumCalendarInfoProcEx lpCalInfoEnumProc, LCID Locale, CALID Calendar, CALTYPE CalType);
  2569. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2570. public static extern int EnumDateFormatsA(IntPtr lpDateFmtEnumProc, LCID Locale, uint dwFlags);
  2571. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Ansi), CLSCompliant(false)]
  2572. public static extern int EnumDateFormatsA(EnumDateFormatsProc lpDateFmtEnumProc, LCID Locale, uint dwFlags);
  2573. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2574. public static extern int EnumDateFormatsW(IntPtr lpDateFmtEnumProc, LCID Locale, uint dwFlags);
  2575. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Unicode), CLSCompliant(false)]
  2576. public static extern int EnumDateFormatsW(EnumDateFormatsProc lpDateFmtEnumProc, LCID Locale, uint dwFlags);
  2577. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2578. public static extern int EnumSystemCodePagesA(IntPtr lpCodePageEnumProc, uint dwFlags);
  2579. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Ansi), CLSCompliant(false)]
  2580. public static extern int EnumSystemCodePagesA(EnumCodePagesProc lpCodePageEnumProc, uint dwFlags);
  2581. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2582. public static extern int EnumSystemCodePagesW(IntPtr lpCodePageEnumProc, uint dwFlags);
  2583. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Unicode), CLSCompliant(false)]
  2584. public static extern int EnumSystemCodePagesW(EnumCodePagesProc lpCodePageEnumProc, uint dwFlags);
  2585. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2586. public static extern int EnumSystemLocalesA(IntPtr lpCodePageEnumProc, uint dwFlags);
  2587. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Ansi), CLSCompliant(false)]
  2588. public static extern int EnumSystemLocalesA(EnumLocalesProc lpCodePageEnumProc, uint dwFlags);
  2589. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2590. public static extern int EnumSystemLocalesW(IntPtr lpCodePageEnumProc, uint dwFlags);
  2591. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Unicode), CLSCompliant(false)]
  2592. public static extern int EnumSystemLocalesW(EnumLocalesProc lpCodePageEnumProc, uint dwFlags);
  2593. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2594. public static extern int EnumTimeFormatsA(IntPtr lpTimeFmtEnumProc, LCID Locale, uint dwFlags);
  2595. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Ansi), CLSCompliant(false)]
  2596. public static extern int EnumTimeFormatsA(EnumTimeFormatsProc lpTimeFmtEnumProc, LCID Locale, uint dwFlags);
  2597. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2598. public static extern int EnumTimeFormatsW(IntPtr lpTimeFmtEnumProc, LCID Locale, uint dwFlags);
  2599. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Unicode), CLSCompliant(false)]
  2600. public static extern int EnumTimeFormatsW(EnumTimeFormatsProc lpTimeFmtEnumProc, LCID Locale, uint dwFlags);
  2601. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2602. public static extern uint GetACP();
  2603. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2604. public static extern int GetCPInfo(uint CodePage, IntPtr lpCPInfo);
  2605. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2606. public static extern int GetCPInfo(uint CodePage, ref CPINFO lpCPInfo);
  2607. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2608. public static extern int GetCurrencyFormatA(LCID Locale, uint dwFlags, IntPtr lpValue, IntPtr lpFormat, IntPtr lpCurrencyStr, int cchCurrency);
  2609. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Ansi), CLSCompliant(false)]
  2610. public static extern int GetCurrencyFormatA(LCID Locale, uint dwFlags, string lpValue, ref CURRENCYFMT lpFormat, StringBuilder lpCurrencyStr, int cchCurrency);
  2611. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2612. public static extern int GetCurrencyFormatW(LCID Locale, uint dwFlags, IntPtr lpValue, IntPtr lpFormat, IntPtr lpCurrencyStr, int cchCurrency);
  2613. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Unicode), CLSCompliant(false)]
  2614. public static extern int GetCurrencyFormatW(LCID Locale, uint dwFlags, string lpValue, ref CURRENCYFMT lpFormat, StringBuilder lpCurrencyStr, int cchCurrency);
  2615. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2616. public static extern int GetDateFormatA(LCID Locale, uint dwFlags, IntPtr lpDate, IntPtr lpFormat, IntPtr lpDateStr, int cchDate);
  2617. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Ansi), CLSCompliant(false)]
  2618. public static extern int GetDateFormatA(LCID Locale, uint dwFlags, ref SYSTEMTIME lpDate, string lpFormat, StringBuilder lpDateStr, int cchDate);
  2619. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2620. public static extern int GetDateFormatW(LCID Locale, uint dwFlags, IntPtr lpDate, IntPtr lpFormat, IntPtr lpDateStr, int cchDate);
  2621. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Unicode), CLSCompliant(false)]
  2622. public static extern int GetDateFormatW(LCID Locale, uint dwFlags, ref SYSTEMTIME lpDate, string lpFormat, StringBuilder lpDateStr, int cchDate);
  2623. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2624. public static extern int GetLocaleInfoA(LCID Locale, LCTYPE LCType, IntPtr lpLCData, int cchData);
  2625. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Ansi), CLSCompliant(false)]
  2626. public static extern int GetLocaleInfoA(LCID Locale, LCTYPE LCType, StringBuilder lpLCData, int cchData);
  2627. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2628. public static extern int GetLocaleInfoW(LCID Locale, LCTYPE LCType, IntPtr lpLCData, int cchData);
  2629. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Unicode), CLSCompliant(false)]
  2630. public static extern int GetLocaleInfoW(LCID Locale, LCTYPE LCType, StringBuilder lpLCData, int cchData);
  2631. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2632. public static extern int GetNumberFormatA(LCID Locale, uint dwFlags, IntPtr lpValue, IntPtr lpFormat, IntPtr lpNumberStr, int cchNumber);
  2633. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Ansi), CLSCompliant(false)]
  2634. public static extern int GetNumberFormatA(LCID Locale, uint dwFlags, string lpValue, ref NUMBERFMT lpFormat, StringBuilder lpNumberStr, int cchNumber);
  2635. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2636. public static extern int GetNumberFormatW(LCID Locale, uint dwFlags, IntPtr lpValue, IntPtr lpFormat, IntPtr lpNumberStr, int cchNumber);
  2637. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Unicode), CLSCompliant(false)]
  2638. public static extern int GetNumberFormatW(LCID Locale, uint dwFlags, string lpValue, ref NUMBERFMT lpFormat, StringBuilder lpNumberStr, int cchNumber);
  2639. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2640. public static extern uint GetOEMCP();
  2641. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2642. public static extern LANGID GetSystemDefaultLangID();
  2643. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2644. public static extern LCID GetSystemDefaultLCID();
  2645. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2646. public static extern LCID GetThreadLocale();
  2647. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2648. public static extern int GetTimeFormatA(LCID Locale, uint dwFlags, IntPtr lpTime, IntPtr lpFormat, IntPtr lpTimeStr, int cchTime);
  2649. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Ansi), CLSCompliant(false)]
  2650. public static extern int GetTimeFormatA(LCID Locale, uint dwFlags, ref SYSTEMTIME lpTime, string lpFormat, StringBuilder lpTimeStr, int cchTime);
  2651. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2652. public static extern int GetTimeFormatW(LCID Locale, uint dwFlags, IntPtr lpTime, IntPtr lpFormat, IntPtr lpTimeStr, int cchTime);
  2653. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Unicode), CLSCompliant(false)]
  2654. public static extern int GetTimeFormatW(LCID Locale, uint dwFlags, ref SYSTEMTIME lpTime, string lpFormat, StringBuilder lpTimeStr, int cchTime);
  2655. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2656. public static extern LANGID GetUserDefaultLangID();
  2657. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2658. public static extern LCID GetUserDefaultLCID();
  2659. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2660. public static extern int IsValidCodePage(uint CodePage);
  2661. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2662. public static extern int IsValidLocale(LCID Locale, uint dwFlags);
  2663. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2664. public static extern int LCMapStringA(LCID Locale, uint dwMapFlags, IntPtr lpSrcStr, int cchSrc, IntPtr lpDestStr, int cchDest);
  2665. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Ansi), CLSCompliant(false)]
  2666. public static extern int LCMapStringA(LCID Locale, uint dwMapFlags, string lpSrcStr, int cchSrc, StringBuilder lpDestStr, int cchDest);
  2667. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2668. public static extern int LCMapStringW(LCID Locale, uint dwMapFlags, IntPtr lpSrcStr, int cchSrc, IntPtr lpDestStr, int cchDest);
  2669. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Unicode), CLSCompliant(false)]
  2670. public static extern int LCMapStringW(LCID Locale, uint dwMapFlags, string lpSrcStr, int cchSrc, StringBuilder lpDestStr, int cchDest);
  2671. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2672. public static extern int SetLocaleInfoA(LCID Locale, LCTYPE LCType, IntPtr lpLCData);
  2673. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Ansi), CLSCompliant(false)]
  2674. public static extern int SetLocaleInfoA(LCID Locale, LCTYPE LCType, string lpLCData);
  2675. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2676. public static extern int SetLocaleInfoW(LCID Locale, LCTYPE LCType, IntPtr lpLCData);
  2677. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Unicode), CLSCompliant(false)]
  2678. public static extern int SetLocaleInfoW(LCID Locale, LCTYPE LCType, string lpLCData);
  2679. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2680. public static extern int SetThreadLocale(LCID Locale);
  2681. }
  2682. #endregion // National language support functions
  2683. #region Mailslot functions
  2684. partial class kernel32
  2685. {
  2686. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2687. public static extern IntPtr CreateMailslotA(IntPtr lpName, uint nMaxMessageSize, uint lReadTimeOut, IntPtr lpSecurityAttributes);
  2688. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Ansi), CLSCompliant(false)]
  2689. public static extern IntPtr CreateMailslotA(string lpName, uint nMaxMessageSize, uint lReadTimeOut, ref SECURITY_ATTRIBUTES lpSecurityAttributes);
  2690. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2691. public static extern IntPtr CreateMailslotW(IntPtr lpName, uint nMaxMessageSize, uint lReadTimeOut, IntPtr lpSecurityAttributes);
  2692. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Unicode), CLSCompliant(false)]
  2693. public static extern IntPtr CreateMailslotW(string lpName, uint nMaxMessageSize, uint lReadTimeOut, ref SECURITY_ATTRIBUTES lpSecurityAttributes);
  2694. [DllImport(ModuleName, SetLastError = true)]
  2695. public static extern int GetMailslotInfo(IntPtr hMailslot, IntPtr lpMaxMessageSize, IntPtr lpNextSize, IntPtr lpMessageCount, IntPtr lpReadTimeout);
  2696. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2697. public static extern int GetMailslotInfo(IntPtr hMailslot, ref uint lpMaxMessageSize, ref uint lpNextSize, ref uint lpMessageCount, ref uint lpReadTimeout);
  2698. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2699. public static extern int SetMailslotInfo(IntPtr hMailslot, uint lReadTimeout);
  2700. }
  2701. #endregion // Mailslot functions
  2702. #region Pipe functions
  2703. partial class kernel32
  2704. {
  2705. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2706. public static extern int CallNamedPipeA(IntPtr lpNamedPipeName, IntPtr lpInBuffer, uint nInBufferSize, IntPtr lpOutBuffer, uint nOutBufferSize, IntPtr lpBytesRead, uint nTimeOut);
  2707. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Ansi), CLSCompliant(false)]
  2708. public static extern int CallNamedPipeA(string lpNamedPipeName, IntPtr lpInBuffer, uint nInBufferSize, IntPtr lpOutBuffer, uint nOutBufferSize, ref uint lpBytesRead, uint nTimeOut);
  2709. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2710. public static extern int CallNamedPipeW(IntPtr lpNamedPipeName, IntPtr lpInBuffer, uint nInBufferSize, IntPtr lpOutBuffer, uint nOutBufferSize, IntPtr lpBytesRead, uint nTimeOut);
  2711. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Unicode), CLSCompliant(false)]
  2712. public static extern int CallNamedPipeW(string lpNamedPipeName, IntPtr lpInBuffer, uint nInBufferSize, IntPtr lpOutBuffer, uint nOutBufferSize, ref uint lpBytesRead, uint nTimeOut);
  2713. [DllImport(ModuleName, SetLastError = true)]
  2714. public static extern int ConnectNamedPipe(IntPtr hNamedPipe, IntPtr lpOverlapped);
  2715. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2716. public static extern int ConnectNamedPipe(IntPtr hNamedPipe, ref OVERLAPPED lpOverlapped);
  2717. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2718. public static extern IntPtr CreateNamedPipeA(IntPtr lpName, uint dwOpenMode, uint dwPipeMode, uint nMaxInstances, uint nOutBufferSize, uint nInBufferSize, uint nDefaultTimeOut, IntPtr lpSecurityAttributes);
  2719. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Ansi), CLSCompliant(false)]
  2720. public static extern IntPtr CreateNamedPipeA(string lpName, uint dwOpenMode, uint dwPipeMode, uint nMaxInstances, uint nOutBufferSize, uint nInBufferSize, uint nDefaultTimeOut, IntPtr lpSecurityAttributes);
  2721. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2722. public static extern IntPtr CreateNamedPipeW(IntPtr lpName, uint dwOpenMode, uint dwPipeMode, uint nMaxInstances, uint nOutBufferSize, uint nInBufferSize, uint nDefaultTimeOut, IntPtr lpSecurityAttributes);
  2723. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Unicode), CLSCompliant(false)]
  2724. public static extern IntPtr CreateNamedPipeW(string lpName, uint dwOpenMode, uint dwPipeMode, uint nMaxInstances, uint nOutBufferSize, uint nInBufferSize, uint nDefaultTimeOut, IntPtr lpSecurityAttributes);
  2725. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2726. public static extern int CreatePipe(IntPtr hReadPipe, IntPtr hWritePipe, IntPtr lpPipeAttributes, uint nSize);
  2727. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2728. public static extern int CreatePipe(ref IntPtr hReadPipe, ref IntPtr hWritePipe, ref SECURITY_ATTRIBUTES lpPipeAttributes, uint nSize);
  2729. [DllImport(ModuleName, SetLastError = true)]
  2730. public static extern int DisconnectNamedPipe(IntPtr hNamedPipe);
  2731. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2732. public static extern int GetNamedPipeHandleStateA(IntPtr hNamedPipe, IntPtr lpState, IntPtr lpCurInstances, IntPtr lpMaxCollectionCount, IntPtr lpCollectDataTimeout, IntPtr lpUserName, uint nMaxUserNameSize);
  2733. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Ansi), CLSCompliant(false)]
  2734. public static extern int GetNamedPipeHandleStateA(IntPtr hNamedPipe, ref uint lpState, ref uint lpCurInstances, ref uint lpMaxCollectionCount, ref uint lpCollectDataTimeout, StringBuilder lpUserName, uint nMaxUserNameSize);
  2735. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2736. public static extern int GetNamedPipeHandleStateW(IntPtr hNamedPipe, IntPtr lpState, IntPtr lpCurInstances, IntPtr lpMaxCollectionCount, IntPtr lpCollectDataTimeout, IntPtr lpUserName, uint nMaxUserNameSize);
  2737. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Unicode), CLSCompliant(false)]
  2738. public static extern int GetNamedPipeHandleStateW(IntPtr hNamedPipe, ref uint lpState, ref uint lpCurInstances, ref uint lpMaxCollectionCount, ref uint lpCollectDataTimeout, StringBuilder lpUserName, uint nMaxUserNameSize);
  2739. [DllImport(ModuleName, SetLastError = true)]
  2740. public static extern int GetNamedPipeInfo(IntPtr hNamedPipe, IntPtr lpFlags, IntPtr lpOutBufferSize, IntPtr lpInBufferSize, IntPtr lpMaxInstances);
  2741. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2742. public static extern int GetNamedPipeInfo(IntPtr hNamedPipe, ref uint lpFlags, ref uint lpOutBufferSize, ref uint lpInBufferSize, ref uint lpMaxInstances);
  2743. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2744. public static extern int PeekNamedPipe(IntPtr hNamedPipe, IntPtr lpBuffer, uint nBufferSize, IntPtr lpBytesRead, IntPtr lpTotalBytesAvail, IntPtr lpBytesLeftThisMessage);
  2745. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2746. public static extern int PeekNamedPipe(IntPtr hNamedPipe, IntPtr lpBuffer, uint nBufferSize, ref uint lpBytesRead, ref uint lpTotalBytesAvail, ref uint lpBytesLeftThisMessage);
  2747. [DllImport(ModuleName, SetLastError = true)]
  2748. public static extern int SetNamedPipeHandleState(IntPtr hNamedPipe, IntPtr lpMode, IntPtr lpMaxCollectionCount, IntPtr lpCollectDataTimeout);
  2749. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2750. public static extern int SetNamedPipeHandleState(IntPtr hNamedPipe, ref uint lpMode, ref uint lpMaxCollectionCount, ref uint lpCollectDataTimeout);
  2751. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2752. public static extern int TransactNamedPipe(IntPtr hNamedPipe, IntPtr lpInBuffer, uint nInBufferSize, IntPtr lpOutBuffer, uint nOutBufferSize, IntPtr lpBytesRead, IntPtr lpOverlapped);
  2753. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2754. public static extern int TransactNamedPipe(IntPtr hNamedPipe, IntPtr lpInBuffer, uint nInBufferSize, IntPtr lpOutBuffer, uint nOutBufferSize, ref uint lpBytesRead, ref OVERLAPPED lpOverlapped);
  2755. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2756. public static extern int WaitNamedPipeA(IntPtr lpNamedPipe, uint nTimeOut);
  2757. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Ansi), CLSCompliant(false)]
  2758. public static extern int WaitNamedPipeA(string lpNamedPipe, uint nTimeOut);
  2759. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2760. public static extern int WaitNamedPipeW(IntPtr lpNamedPipe, uint nTimeOut);
  2761. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Unicode), CLSCompliant(false)]
  2762. public static extern int WaitNamedPipeW(string lpNamedPipe, uint nTimeOut);
  2763. }
  2764. #endregion // Pipe functions
  2765. #region Process and thread functions
  2766. partial class kernel32
  2767. {
  2768. [DllImport(ModuleName), CLSCompliant(false)]
  2769. public static extern int AttachThreadInput(uint idAttach, uint idAttachTo, int fAttach);
  2770. [DllImport(ModuleName, SetLastError = true)]
  2771. public static extern IntPtr CommandLineToArgvW(IntPtr lpCmdLine, IntPtr pNumArgs);
  2772. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Unicode)]
  2773. public static extern IntPtr CommandLineToArgvW(string lpCmdLine, ref int pNumArgs);
  2774. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2775. public static extern int CreateProcessA(IntPtr lpApplicationName, IntPtr lpCommandLine, IntPtr lpProcessAttributes, IntPtr lpThreadAttributes, int bInheritHandles, uint dwCreationFlags, IntPtr lpEnvironment, IntPtr lpCurrentDirectory, IntPtr lpStartupInfo, IntPtr lpProcessInformation);
  2776. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Ansi), CLSCompliant(false)]
  2777. public static extern int CreateProcessA(string lpApplicationName, string lpCommandLine, IntPtr lpProcessAttributes, IntPtr lpThreadAttributes, int bInheritHandles, uint dwCreationFlags, IntPtr lpEnvironment, string lpCurrentDirectory, IntPtr lpStartupInfo, IntPtr lpProcessInformation);
  2778. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Ansi), CLSCompliant(false)]
  2779. public static extern int CreateProcessA(string lpApplicationName, string lpCommandLine, IntPtr lpProcessAttributes, IntPtr lpThreadAttributes, int bInheritHandles, uint dwCreationFlags, IntPtr lpEnvironment, string lpCurrentDirectory, ref STARTUPINFO lpStartupInfo, ref PROCESS_INFORMATION lpProcessInformation);
  2780. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Ansi), CLSCompliant(false)]
  2781. public static extern int CreateProcessA(string lpApplicationName, string lpCommandLine, ref SECURITY_ATTRIBUTES lpProcessAttributes, ref SECURITY_ATTRIBUTES lpThreadAttributes, int bInheritHandles, uint dwCreationFlags, IntPtr lpEnvironment, string lpCurrentDirectory, ref STARTUPINFO lpStartupInfo, ref PROCESS_INFORMATION lpProcessInformation);
  2782. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2783. public static extern int CreateProcessW(IntPtr lpApplicationName, IntPtr lpCommandLine, IntPtr lpProcessAttributes, IntPtr lpThreadAttributes, int bInheritHandles, uint dwCreationFlags, IntPtr lpEnvironment, IntPtr lpCurrentDirectory, IntPtr lpStartupInfo, IntPtr lpProcessInformation);
  2784. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Unicode), CLSCompliant(false)]
  2785. public static extern int CreateProcessW(string lpApplicationName, string lpCommandLine, IntPtr lpProcessAttributes, IntPtr lpThreadAttributes, int bInheritHandles, uint dwCreationFlags, IntPtr lpEnvironment, string lpCurrentDirectory, IntPtr lpStartupInfo, IntPtr lpProcessInformation);
  2786. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Unicode), CLSCompliant(false)]
  2787. public static extern int CreateProcessW(string lpApplicationName, string lpCommandLine, IntPtr lpProcessAttributes, IntPtr lpThreadAttributes, int bInheritHandles, uint dwCreationFlags, IntPtr lpEnvironment, string lpCurrentDirectory, ref STARTUPINFO lpStartupInfo, ref PROCESS_INFORMATION lpProcessInformation);
  2788. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Unicode), CLSCompliant(false)]
  2789. public static extern int CreateProcessW(string lpApplicationName, string lpCommandLine, ref SECURITY_ATTRIBUTES lpProcessAttributes, ref SECURITY_ATTRIBUTES lpThreadAttributes, int bInheritHandles, uint dwCreationFlags, IntPtr lpEnvironment, string lpCurrentDirectory, ref STARTUPINFO lpStartupInfo, ref PROCESS_INFORMATION lpProcessInformation);
  2790. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2791. public static extern int CreateProcessAsUserA(IntPtr hToken, IntPtr lpApplicationName, IntPtr lpCommandLine, IntPtr lpProcessAttributes, IntPtr lpThreadAttributes, int bInheritHandles, uint dwCreationFlags, IntPtr lpEnvironment, IntPtr lpCurrentDirectory, IntPtr lpStartupInfo, IntPtr lpProcessInformation);
  2792. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Ansi), CLSCompliant(false)]
  2793. public static extern int CreateProcessAsUserA(IntPtr hToken, string lpApplicationName, string lpCommandLine, IntPtr lpProcessAttributes, IntPtr lpThreadAttributes, int bInheritHandles, uint dwCreationFlags, IntPtr lpEnvironment, string lpCurrentDirectory, IntPtr lpStartupInfo, IntPtr lpProcessInformation);
  2794. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Ansi), CLSCompliant(false)]
  2795. public static extern int CreateProcessAsUserA(IntPtr hToken, string lpApplicationName, string lpCommandLine, IntPtr lpProcessAttributes, IntPtr lpThreadAttributes, int bInheritHandles, uint dwCreationFlags, IntPtr lpEnvironment, string lpCurrentDirectory, ref STARTUPINFO lpStartupInfo, ref PROCESS_INFORMATION lpProcessInformation);
  2796. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Ansi), CLSCompliant(false)]
  2797. public static extern int CreateProcessAsUserA(IntPtr hToken, string lpApplicationName, string lpCommandLine, ref SECURITY_ATTRIBUTES lpProcessAttributes, ref SECURITY_ATTRIBUTES lpThreadAttributes, int bInheritHandles, uint dwCreationFlags, IntPtr lpEnvironment, string lpCurrentDirectory, ref STARTUPINFO lpStartupInfo, ref PROCESS_INFORMATION lpProcessInformation);
  2798. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2799. public static extern int CreateProcessAsUserW(IntPtr hToken, IntPtr lpApplicationName, IntPtr lpCommandLine, IntPtr lpProcessAttributes, IntPtr lpThreadAttributes, int bInheritHandles, uint dwCreationFlags, IntPtr lpEnvironment, IntPtr lpCurrentDirectory, IntPtr lpStartupInfo, IntPtr lpProcessInformation);
  2800. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Unicode), CLSCompliant(false)]
  2801. public static extern int CreateProcessAsUserW(IntPtr hToken, string lpApplicationName, string lpCommandLine, IntPtr lpProcessAttributes, IntPtr lpThreadAttributes, int bInheritHandles, uint dwCreationFlags, IntPtr lpEnvironment, string lpCurrentDirectory, IntPtr lpStartupInfo, IntPtr lpProcessInformation);
  2802. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Unicode), CLSCompliant(false)]
  2803. public static extern int CreateProcessAsUserW(IntPtr hToken, string lpApplicationName, string lpCommandLine, IntPtr lpProcessAttributes, IntPtr lpThreadAttributes, int bInheritHandles, uint dwCreationFlags, IntPtr lpEnvironment, string lpCurrentDirectory, ref STARTUPINFO lpStartupInfo, ref PROCESS_INFORMATION lpProcessInformation);
  2804. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Unicode), CLSCompliant(false)]
  2805. public static extern int CreateProcessAsUserW(IntPtr hToken, string lpApplicationName, string lpCommandLine, ref SECURITY_ATTRIBUTES lpProcessAttributes, ref SECURITY_ATTRIBUTES lpThreadAttributes, int bInheritHandles, uint dwCreationFlags, IntPtr lpEnvironment, string lpCurrentDirectory, ref STARTUPINFO lpStartupInfo, ref PROCESS_INFORMATION lpProcessInformation);
  2806. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2807. public static extern IntPtr CreateRemoteThread(IntPtr hProcess, IntPtr lpThreadAttributes, uint dwStackSize, IntPtr lpStartAddress, IntPtr lpParameter, uint dwCreationFlags, IntPtr lpThreadId);
  2808. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2809. public static extern IntPtr CreateRemoteThread(IntPtr hProcess, IntPtr lpThreadAttributes, uint dwStackSize, ref ThreadProc lpStartAddress, IntPtr lpParameter, uint dwCreationFlags, ref uint lpThreadId);
  2810. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2811. public static extern IntPtr CreateRemoteThread(IntPtr hProcess, ref SECURITY_ATTRIBUTES lpThreadAttributes, uint dwStackSize, ref ThreadProc lpStartAddress, IntPtr lpParameter, uint dwCreationFlags, ref uint lpThreadId);
  2812. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2813. public static extern IntPtr CreateThread(IntPtr lpThreadAttributes, uint dwStackSize, IntPtr lpStartAddress, IntPtr lpParameter, uint dwCreationFlags, IntPtr lpThreadId);
  2814. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2815. public static extern IntPtr CreateThread(IntPtr lpThreadAttributes, uint dwStackSize, ref ThreadProc lpStartAddress, IntPtr lpParameter, uint dwCreationFlags, ref uint lpThreadId);
  2816. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2817. public static extern IntPtr CreateThread(ref SECURITY_ATTRIBUTES lpThreadAttributes, uint dwStackSize, ref ThreadProc lpStartAddress, IntPtr lpParameter, uint dwCreationFlags, ref uint lpThreadId);
  2818. [DllImport(ModuleName), CLSCompliant(false)]
  2819. public static extern void ExitProcess(uint uExitCode);
  2820. [DllImport(ModuleName), CLSCompliant(false)]
  2821. public static extern void ExitThread(uint dwExitCode);
  2822. [DllImport(ModuleName, SetLastError = true)]
  2823. public static extern int FreeEnvironmentStringsA(IntPtr lpszEnvironmentBlock);
  2824. [DllImport(ModuleName, SetLastError = true)]
  2825. public static extern int FreeEnvironmentStringsW(IntPtr lpszEnvironmentBlock);
  2826. [DllImport(ModuleName)]
  2827. public static extern IntPtr GetCommandLineA();
  2828. [DllImport(ModuleName)]
  2829. public static extern IntPtr GetCommandLineW();
  2830. [DllImport(ModuleName)]
  2831. public static extern IntPtr GetCurrentProcess();
  2832. [DllImport(ModuleName), CLSCompliant(false)]
  2833. public static extern uint GetCurrentProcessId();
  2834. [DllImport(ModuleName)]
  2835. public static extern IntPtr GetCurrentThread();
  2836. [DllImport(ModuleName), CLSCompliant(false)]
  2837. public static extern uint GetCurrentThreadId();
  2838. [DllImport(ModuleName)]
  2839. public static extern IntPtr GetEnvironmentStringsA();
  2840. [DllImport(ModuleName)]
  2841. public static extern IntPtr GetEnvironmentStringsW();
  2842. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2843. public static extern uint GetEnvironmentVariableA(IntPtr lpName, IntPtr lpBuffer, uint nSize);
  2844. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Ansi), CLSCompliant(false)]
  2845. public static extern uint GetEnvironmentVariableA(string lpName, StringBuilder lpBuffer, uint nSize);
  2846. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2847. public static extern uint GetEnvironmentVariableW(IntPtr lpName, IntPtr lpBuffer, uint nSize);
  2848. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Unicode), CLSCompliant(false)]
  2849. public static extern uint GetEnvironmentVariableW(string lpName, StringBuilder lpBuffer, uint nSize);
  2850. [DllImport(ModuleName, SetLastError = true)]
  2851. public static extern int GetExitCodeProcess(IntPtr hProcess, IntPtr lpExitCode);
  2852. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2853. public static extern int GetExitCodeProcess(IntPtr hProcess, ref uint lpExitCode);
  2854. [DllImport(ModuleName, SetLastError = true)]
  2855. public static extern int GetExitCodeThread(IntPtr hThread, IntPtr lpExitCode);
  2856. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2857. public static extern int GetExitCodeThread(IntPtr hThread, ref uint lpExitCode);
  2858. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2859. public static extern uint GetPriorityClass(IntPtr hProcess);
  2860. [DllImport(ModuleName, SetLastError = true)]
  2861. public static extern int GetProcessAffinityMask(IntPtr hProcess, IntPtr lpProcessAffinityMask, IntPtr lpSystemAffinityMask);
  2862. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2863. public static extern int GetProcessAffinityMask(IntPtr hProcess, ref uint lpProcessAffinityMask, ref uint lpSystemAffinityMask);
  2864. [DllImport(ModuleName, SetLastError = true)]
  2865. public static extern int GetProcessPriorityBoost(IntPtr hProcess, IntPtr pDisablePriorityBoost);
  2866. [DllImport(ModuleName, SetLastError = true)]
  2867. public static extern int GetProcessPriorityBoost(IntPtr hProcess, ref int pDisablePriorityBoost);
  2868. [DllImport(ModuleName, SetLastError = true)]
  2869. public static extern int GetProcessShutdownParameters(IntPtr lpdwLevel, IntPtr lpdwFlags);
  2870. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2871. public static extern int GetProcessShutdownParameters(ref uint lpdwLevel, ref uint lpdwFlags);
  2872. [DllImport(ModuleName, SetLastError = true)]
  2873. public static extern int GetProcessTimes(IntPtr hProcess, IntPtr lpCreationTime, IntPtr lpExitTime, IntPtr lpKernelTime, IntPtr lpUserTime);
  2874. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2875. public static extern int GetProcessTimes(IntPtr hProcess, ref FILETIME lpCreationTime, ref FILETIME lpExitTime, ref FILETIME lpKernelTime, ref FILETIME lpUserTime);
  2876. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2877. public static extern uint GetProcessVersion(uint ProcessId);
  2878. [DllImport(ModuleName, SetLastError = true)]
  2879. public static extern int GetProcessWorkingSetSize(IntPtr hProcess, IntPtr lpMinimumWorkingSetSize, IntPtr lpMaximumWorkingSetSize);
  2880. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2881. public static extern int GetProcessWorkingSetSize(IntPtr hProcess, ref uint lpMinimumWorkingSetSize, ref uint lpMaximumWorkingSetSize);
  2882. [DllImport(ModuleName, SetLastError = true)]
  2883. public static extern void GetStartupInfo(IntPtr lpStartupInfo);
  2884. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2885. public static extern void GetStartupInfo(ref STARTUPINFO lpStartupInfo);
  2886. [DllImport(ModuleName, SetLastError = true)]
  2887. public static extern int GetThreadPriority(IntPtr hThread);
  2888. [DllImport(ModuleName, SetLastError = true)]
  2889. public static extern int GetThreadPriorityBoost(IntPtr hThread, IntPtr pDisablePriorityBoost);
  2890. [DllImport(ModuleName, SetLastError = true)]
  2891. public static extern int GetThreadPriorityBoost(IntPtr hThread, ref int pDisablePriorityBoost);
  2892. [DllImport(ModuleName, SetLastError = true)]
  2893. public static extern int GetThreadTimes(IntPtr hThread, IntPtr lpCreationTime, IntPtr lpExitTime, IntPtr lpKernelTime, IntPtr lpUserTime);
  2894. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2895. public static extern int GetThreadTimes(IntPtr hThread, ref FILETIME lpCreationTime, ref FILETIME lpExitTime, ref FILETIME lpKernelTime, ref FILETIME lpUserTime);
  2896. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2897. public static extern IntPtr OpenProcess(uint dwDesiredAccess, int bInheritHandle, uint dwProcessId);
  2898. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2899. public static extern uint ResumeThread(IntPtr hThread);
  2900. [DllImport(ModuleName, SetLastError = true)]
  2901. public static extern int SetEnvironmentVariableA(IntPtr lpName, IntPtr lpValue);
  2902. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Ansi)]
  2903. public static extern int SetEnvironmentVariableA(string lpName, string lpValue);
  2904. [DllImport(ModuleName, SetLastError = true)]
  2905. public static extern int SetEnvironmentVariableW(IntPtr lpName, IntPtr lpValue);
  2906. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Unicode)]
  2907. public static extern int SetEnvironmentVariableW(string lpName, string lpValue);
  2908. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2909. public static extern int SetPriorityClass(IntPtr hProcess, uint dwPriorityClass);
  2910. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2911. public static extern int SetProcessAffinityMask(IntPtr hProcess, uint dwProcessAffinityMask);
  2912. [DllImport(ModuleName, SetLastError = true)]
  2913. public static extern int SetProcessPriorityBoost(IntPtr hProcess, int DisablePriorityBoost);
  2914. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2915. public static extern int SetProcessShutdownParameters(uint dwLevel, uint dwFlags);
  2916. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2917. public static extern int SetProcessWorkingSetSize(IntPtr hProcess, uint dwMinimumWorkingSetSize, uint MaximumWorkingSetSize);
  2918. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2919. public static extern int SetThreadAffinityMask(IntPtr hProcess, uint dwThreadAffinityMask);
  2920. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2921. public static extern int SetThreadIdealProcessor(IntPtr hProcess, uint dwIdealProcessor);
  2922. [DllImport(ModuleName, SetLastError = true)]
  2923. public static extern int SetThreadPriority(IntPtr hProcess, int nPriority);
  2924. [DllImport(ModuleName, SetLastError = true)]
  2925. public static extern int SetThreadPriorityBoost(IntPtr hProcess, int DisablePriorityBoost);
  2926. [DllImport(ModuleName), CLSCompliant(false)]
  2927. public static extern void Sleep(uint dwMilliseconds);
  2928. [DllImport(ModuleName), CLSCompliant(false)]
  2929. public static extern void SleepEx(uint dwMilliseconds, int bAlertable);
  2930. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2931. public static extern uint SuspendThread(IntPtr hThread);
  2932. [DllImport(ModuleName)]
  2933. public static extern int SwitchToThread();
  2934. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2935. public static extern int TerminateProcess(IntPtr hProcess, uint uExitCode);
  2936. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2937. public static extern int TerminateThread(IntPtr hThread, uint dwExitCode);
  2938. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2939. public static extern uint TlsAlloc();
  2940. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2941. public static extern int TlsFree(uint dwTlsIndex);
  2942. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2943. public static extern IntPtr TlsGetValue(uint dwTlsIndex);
  2944. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2945. public static extern int TlsSetValue(uint dwTlsIndex, IntPtr lpTlsValue);
  2946. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2947. public static extern uint WaitForInputIdle(IntPtr hProcess, uint dwMilliseconds);
  2948. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2949. public static extern uint WinExec(IntPtr lpCmdLine, uint nCmdShow);
  2950. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Ansi), CLSCompliant(false)]
  2951. public static extern uint WinExec(string lpCmdLine, uint nCmdShow);
  2952. }
  2953. #endregion // Process and thread functions
  2954. #region Fiber functions
  2955. partial class kernel32
  2956. {
  2957. [DllImport(ModuleName, SetLastError = true)]
  2958. public static extern IntPtr ConvertThreadToFiber(IntPtr lpParameter);
  2959. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2960. public static extern IntPtr CreateFiber(uint dwStackSize, IntPtr lpStartAddress, IntPtr lpParameter);
  2961. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  2962. public static extern IntPtr CreateFiber(uint dwStackSize, FiberProc lpStartAddress, IntPtr lpParameter);
  2963. [DllImport(ModuleName)]
  2964. public static extern void DeleteFiber(IntPtr lpFiber);
  2965. [DllImport(ModuleName)]
  2966. public static extern IntPtr GetCurrentFiber();
  2967. [DllImport(ModuleName)]
  2968. public static extern IntPtr GetFiberData();
  2969. [DllImport(ModuleName)]
  2970. public static extern void SwitchToFiber(IntPtr lpFiber);
  2971. }
  2972. #endregion // Fiber functions
  2973. #region Activation context functions
  2974. partial class kernel32
  2975. {
  2976. [DllImport(ModuleName)]
  2977. public static extern int ActivateActCtx(IntPtr hActCtx, IntPtr lpCookie);
  2978. [DllImport(ModuleName), CLSCompliant(false)]
  2979. public static extern int ActivateActCtx(IntPtr hActCtx, ref uint lpCookie);
  2980. [DllImport(ModuleName)]
  2981. public static extern void AddRefActCtx(IntPtr hActCtx);
  2982. [DllImport(ModuleName)]
  2983. public static extern IntPtr CreateActCtx(IntPtr pActCtx);
  2984. [DllImport(ModuleName), CLSCompliant(false)]
  2985. public static extern IntPtr CreateActCtx(ref ACTCTX pActCtx);
  2986. [DllImport(ModuleName), CLSCompliant(false)]
  2987. public static extern int DeactivateActCtx(uint dwFlags, uint ulCookie);
  2988. [DllImport(ModuleName), CLSCompliant(false)]
  2989. public static extern int FindActCtxSectionGuid(uint dwFlags, IntPtr lpExtensionGuid, uint ulSectionId, IntPtr lpGuidToFind, IntPtr ReturnedData);
  2990. [DllImport(ModuleName), CLSCompliant(false)]
  2991. public static extern int FindActCtxSectionGuid(uint dwFlags, ref GUID lpExtensionGuid, uint ulSelectionId, ref GUID lpGuidToFind, ref ACTCTX_SECTION_KEYED_DATA ReturnedData);
  2992. [DllImport(ModuleName), CLSCompliant(false)]
  2993. public static extern int FindActCtxSectionStringA(uint dwFlags, IntPtr lpExtensionGuid, uint ulSelectionId, IntPtr lpStringToFind, IntPtr ReturnedData);
  2994. [DllImport(ModuleName, CharSet = CharSet.Ansi), CLSCompliant(false)]
  2995. public static extern int FindActCtxSectionStringA(uint dwFlags, ref GUID lpExtensionGuid, uint ulSelectionId, string lpStringToFind, ref ACTCTX_SECTION_KEYED_DATA ReturnedData);
  2996. [DllImport(ModuleName), CLSCompliant(false)]
  2997. public static extern int FindActCtxSectionStringW(uint dwFlags, IntPtr lpExtensionGuid, uint ulSelectionId, IntPtr lpStringToFind, IntPtr ReturnedData);
  2998. [DllImport(ModuleName, CharSet = CharSet.Unicode), CLSCompliant(false)]
  2999. public static extern int FindActCtxSectionStringW(uint dwFlags, ref GUID lpExtensionGuid, uint ulSelectionId, string lpStringToFind, ref ACTCTX_SECTION_KEYED_DATA ReturnedData);
  3000. [DllImport(ModuleName)]
  3001. public static extern int GetCurrentActCtx(IntPtr lphActCtx);
  3002. [DllImport(ModuleName), CLSCompliant(false)]
  3003. public static extern int GetCurrentActCtx(ref IntPtr lphActCtx);
  3004. [DllImport(ModuleName), CLSCompliant(false)]
  3005. public static extern int QueryActCtxW(uint dwFlags, IntPtr hActCtx, IntPtr pvSubInstance, uint ulInfoClass, IntPtr pvBuffer, uint cbBuffer, IntPtr pcbWrittenOrRequired);
  3006. [DllImport(ModuleName), CLSCompliant(false)]
  3007. public static extern int QueryActCtxW(uint dwFlags, IntPtr hActCtx, IntPtr pvSubInstance, uint ulInfoClass, IntPtr pvBuffer, uint cbBuffer, ref uint pcbWrittenOrRequired);
  3008. [DllImport(ModuleName)]
  3009. public static extern void ReleaseActCtx(IntPtr hActCtx);
  3010. [DllImport(ModuleName)]
  3011. public static extern int ZombifyActCtx(IntPtr hActCtx);
  3012. }
  3013. #endregion // Activation context functions
  3014. #region Address windowing extensions functions
  3015. partial class kernel32
  3016. {
  3017. [DllImport(ModuleName, SetLastError = true)]
  3018. public static extern int AllocateUserPhysicalPages(IntPtr hProcess, IntPtr NumberOfPages, IntPtr UserPfnArray);
  3019. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  3020. public static extern int AllocateUserPhysicalPages(IntPtr hProcess, ref uint NumberOfPages, uint[] UserPfnArray);
  3021. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  3022. public static extern int MapUserPhysicalPages(IntPtr lpAddress, uint NumberOfPages, IntPtr UserPfnArray);
  3023. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  3024. public static extern int MapUserPhysicalPages(IntPtr lpAddress, uint NumberOfPages, uint[] UserPfnArray);
  3025. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  3026. public static extern int MapUserPhysicalPagesScatter(IntPtr VirtualAddresses, uint NumberOfPages, IntPtr PageArray);
  3027. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  3028. public static extern int MapUserPhysicalPagesScatter(uint[] VirtualAddresses, uint NumberOfPages, uint[] PageArray);
  3029. [DllImport(ModuleName, SetLastError = true)]
  3030. public static extern int FreeUserPhysicalPages(IntPtr hProcess, IntPtr NumberOfPages, IntPtr UserPfnArray);
  3031. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  3032. public static extern int FreeUserPhysicalPages(IntPtr hProcess, ref uint NumberOfPages, uint[] UserPfnArray);
  3033. }
  3034. #endregion // Address windowing extensions functions
  3035. #region Job object functions
  3036. partial class kernel32
  3037. {
  3038. [DllImport(ModuleName, SetLastError = true)]
  3039. public static extern int AssignProcessToJobObject(IntPtr hJob, IntPtr hProcess);
  3040. [DllImport(ModuleName, SetLastError = true)]
  3041. public static extern IntPtr CreateJobObjectA(IntPtr lpJobAttributes, IntPtr lpName);
  3042. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Ansi)]
  3043. public static extern IntPtr CreateJobObjectA(IntPtr lpJobAttributes, string lpName);
  3044. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Ansi), CLSCompliant(false)]
  3045. public static extern IntPtr CreateJobObjectA(ref SECURITY_ATTRIBUTES lpJobAttributes, string lpName);
  3046. [DllImport(ModuleName, SetLastError = true)]
  3047. public static extern IntPtr CreateJobObjectW(IntPtr lpJobAttributes, IntPtr lpName);
  3048. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Unicode)]
  3049. public static extern IntPtr CreateJobObjectW(IntPtr lpJobAttributes, string lpName);
  3050. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Unicode), CLSCompliant(false)]
  3051. public static extern IntPtr CreateJobObjectW(ref SECURITY_ATTRIBUTES lpJobAttributes, string lpName);
  3052. [DllImport(ModuleName, SetLastError = true)]
  3053. public static extern int IsProcessInJob(IntPtr ProcessHandle, IntPtr JobHandle, IntPtr Result);
  3054. [DllImport(ModuleName, SetLastError = true)]
  3055. public static extern int IsProcessInJob(IntPtr ProcessHandle, IntPtr JobHandle, ref int Result);
  3056. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  3057. public static extern IntPtr OpenJobObjectA(uint dwDesiredAccess, int bInheritHandles, IntPtr lpName);
  3058. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Ansi), CLSCompliant(false)]
  3059. public static extern IntPtr OpenJobObjectA(uint dwDesiredAccess, int bInheritHandles, string lpName);
  3060. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  3061. public static extern IntPtr OpenJobObjectW(uint dwDesiredAccess, int bInheritHandles, IntPtr lpName);
  3062. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Unicode), CLSCompliant(false)]
  3063. public static extern IntPtr OpenJobObjectW(uint dwDesiredAccess, int bInheritHandles, string lpName);
  3064. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  3065. public static extern int QueryInformationJobObject(IntPtr hJob, JOBOBJECTINFOCLASS JobObjectInfoClass, IntPtr lpJobObjectInfo, uint cbJobObjectInfoLength, IntPtr lpReturnLength);
  3066. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  3067. public static extern int QueryInformationJobObject(IntPtr hJob, JOBOBJECTINFOCLASS JobObjectInfoClass, IntPtr lpJobObjectInfo, uint cbJobObjectInfoLength, ref uint lpReturnLength);
  3068. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  3069. public static extern int SetInformationJobObject(IntPtr hJob, JOBOBJECTINFOCLASS JobObjectInfoClass, IntPtr lpJobObjectInfo, uint cbJobObjectInfoLength);
  3070. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  3071. public static extern int TerminateJobObject(IntPtr hJob, uint uExitCode);
  3072. [DllImport(ModuleName, SetLastError = true)]
  3073. public static extern int UserHandleGrantAccess(IntPtr hUserHandle, IntPtr hJob, int bGrant);
  3074. }
  3075. #endregion // Job object functions
  3076. #region Thread pooling functions
  3077. partial class kernel32
  3078. {
  3079. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  3080. public static extern int BindIoCompletionCallback(IntPtr FileHandle, IntPtr Function, uint Flags);
  3081. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  3082. public static extern int BindIoCompletionCallback(IntPtr FileHandle, FileIOCompletionRoutine Function, uint Flags);
  3083. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  3084. public static extern int QueueUserWorkItem(IntPtr Function, IntPtr Context, uint Flags);
  3085. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  3086. public static extern int QueueUserWorkItem(ThreadProc Function, IntPtr Context, uint Flags);
  3087. }
  3088. #endregion // Thread pooling functions
  3089. #region NUMA functions
  3090. partial class kernel32
  3091. {
  3092. [DllImport(ModuleName, SetLastError = true)]
  3093. public static extern int GetNumaAvailableMemoryNode(byte Node, IntPtr AvailableBytes);
  3094. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  3095. public static extern int GetNumaAvailableMemoryNode(byte Node, ref ulong AvailableBytes);
  3096. [DllImport(ModuleName, SetLastError = true)]
  3097. public static extern int GetNumaHighestNodeNumber(IntPtr HighestNodeNumber);
  3098. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  3099. public static extern int GetNumaHighestNodeNumber(ref ulong HighestNodeNumber);
  3100. [DllImport(ModuleName, SetLastError = true)]
  3101. public static extern int GetNumaNodeProcessorMask(byte Node, IntPtr ProcessorMask);
  3102. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  3103. public static extern int GetNumaNodeProcessorMask(byte Node, ref ulong ProcessorMask);
  3104. [DllImport(ModuleName, SetLastError = true)]
  3105. public static extern int GetNumaProcessorNode(byte Processor, IntPtr NodeNumber);
  3106. [DllImport(ModuleName, SetLastError = true)]
  3107. public static extern int GetNumaProcessorNode(byte Processor, ref byte NodeNumber);
  3108. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  3109. public static extern ulong NumaVirtualQueryNode(uint NumberOfRangs, IntPtr RangeList, IntPtr VirtualPageAndNode, uint MaximumOutputLength);
  3110. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  3111. public static extern ulong NumaVirtualQueryNode(uint NumberOfRangs, uint[] RangeList, uint[] VirtualPageAndNode, uint MaximumOutputLength);
  3112. }
  3113. #endregion // NUMA functions
  3114. #region System information functions
  3115. partial class kernel32
  3116. {
  3117. [DllImport(ModuleName, SetLastError = true)]
  3118. public static extern int DnsHostnameToComputerNameA(IntPtr Hostname, IntPtr ComputerName, IntPtr nSize);
  3119. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Ansi), CLSCompliant(false)]
  3120. public static extern int DnsHostnameToComputerNameA(string Hostname, StringBuilder ComputerName, ref uint nSize);
  3121. [DllImport(ModuleName, SetLastError = true)]
  3122. public static extern int DnsHostnameToComputerNameW(IntPtr Hostname, IntPtr ComputerName, IntPtr nSize);
  3123. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Unicode), CLSCompliant(false)]
  3124. public static extern int DnsHostnameToComputerNameW(string Hostname, StringBuilder ComputerName, ref uint nSize);
  3125. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  3126. public static extern uint ExpandEnvironmentStringsA(IntPtr lpSrc, IntPtr lpDst, uint nSize);
  3127. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Ansi), CLSCompliant(false)]
  3128. public static extern uint ExpandEnvironmentStringsA(string lpSrc, StringBuilder lpDst, uint nSize);
  3129. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  3130. public static extern uint ExpandEnvironmentStringsW(IntPtr lpSrc, IntPtr lpDst, uint nSize);
  3131. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Unicode), CLSCompliant(false)]
  3132. public static extern uint ExpandEnvironmentStringsW(string lpSrc, StringBuilder lpDst, uint nSize);
  3133. [DllImport(ModuleName, SetLastError = true)]
  3134. public static extern int GetComputerNameA(IntPtr lpBuffer, IntPtr lpnSize);
  3135. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Ansi), CLSCompliant(false)]
  3136. public static extern int GetComputerNameA(StringBuilder lpBuffer, ref uint lpnSize);
  3137. [DllImport(ModuleName, SetLastError = true)]
  3138. public static extern int GetComputerNameW(IntPtr lpBuffer, IntPtr lpnSize);
  3139. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Unicode), CLSCompliant(false)]
  3140. public static extern int GetComputerNameW(StringBuilder lpBuffer, ref uint lpnSize);
  3141. [DllImport(ModuleName, SetLastError = true)]
  3142. public static extern int GetComputerNameExA(COMPUTER_NAME_FORMAT NameType, IntPtr lpBuffer, IntPtr lpnSize);
  3143. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Ansi), CLSCompliant(false)]
  3144. public static extern int GetComputerNameExA(COMPUTER_NAME_FORMAT NameType, StringBuilder lpBuffer, ref uint lpnSize);
  3145. [DllImport(ModuleName, SetLastError = true)]
  3146. public static extern int GetComputerNameExW(COMPUTER_NAME_FORMAT NameType, IntPtr lpBuffer, IntPtr lpnSize);
  3147. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Unicode), CLSCompliant(false)]
  3148. public static extern int GetComputerNameExW(COMPUTER_NAME_FORMAT NameType, StringBuilder lpBuffer, ref uint lpnSize);
  3149. [DllImport(ModuleName, SetLastError = true)]
  3150. public static extern void GetNativeSystemInfo(IntPtr lpSystemInfo);
  3151. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  3152. public static extern void GetNativeSystemInfo(ref SYSTEM_INFO lpSystemInfo);
  3153. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  3154. public static extern uint GetSystemDirectoryA(IntPtr lpBuffer, uint uSize);
  3155. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Ansi), CLSCompliant(false)]
  3156. public static extern uint GetSystemDirectoryA(StringBuilder lpBuffer, uint uSize);
  3157. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  3158. public static extern uint GetSystemDirectoryW(IntPtr lpBuffer, uint uSize);
  3159. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Unicode), CLSCompliant(false)]
  3160. public static extern uint GetSystemDirectoryW(StringBuilder lpBuffer, uint uSize);
  3161. [DllImport(ModuleName, SetLastError = true)]
  3162. public static extern void GetSystemInfo(IntPtr lpSystemInfo);
  3163. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  3164. public static extern void GetSystemInfo(ref SYSTEM_INFO lpSystemInfo);
  3165. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  3166. public static extern uint GetSystemWindowsDirectoryA(IntPtr lpBuffer, uint uSize);
  3167. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Ansi), CLSCompliant(false)]
  3168. public static extern uint GetSystemWindowsDirectoryA(StringBuilder lpBuffer, uint uSize);
  3169. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  3170. public static extern uint GetSystemWindowsDirectoryW(IntPtr lpBuffer, uint uSize);
  3171. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Unicode), CLSCompliant(false)]
  3172. public static extern uint GetSystemWindowsDirectoryW(StringBuilder lpBuffer, uint uSize);
  3173. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  3174. public static extern uint GetSystemWow64DirectoryA(IntPtr lpBuffer, uint uSize);
  3175. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Ansi), CLSCompliant(false)]
  3176. public static extern uint GetSystemWow64DirectoryA(StringBuilder lpBuffer, uint uSize);
  3177. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  3178. public static extern uint GetSystemWow64DirectoryW(IntPtr lpBuffer, uint uSize);
  3179. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Unicode), CLSCompliant(false)]
  3180. public static extern uint GetSystemWow64DirectoryW(StringBuilder lpBuffer, uint uSize);
  3181. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  3182. public static extern uint GetVersion();
  3183. [DllImport(ModuleName, SetLastError = true)]
  3184. public static extern int GetVersionExA(IntPtr lpVersionInfo);
  3185. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Ansi), CLSCompliant(false)]
  3186. public static extern int GetVersionExA(ref OSVERSIONINFO lpVersionInfo);
  3187. [DllImport(ModuleName, SetLastError = true)]
  3188. public static extern int GetVersionExW(IntPtr lpVersionInfo);
  3189. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Unicode), CLSCompliant(false)]
  3190. public static extern int GetVersionExW(ref OSVERSIONINFO lpVersionInfo);
  3191. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  3192. public static extern uint GetWindowsDirectoryA(IntPtr lpBuffer, uint uSize);
  3193. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Ansi), CLSCompliant(false)]
  3194. public static extern uint GetWindowsDirectoryA(StringBuilder lpBuffer, uint uSize);
  3195. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  3196. public static extern uint GetWindowsDirectoryW(IntPtr lpBuffer, uint uSize);
  3197. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Unicode), CLSCompliant(false)]
  3198. public static extern uint GetWindowsDirectoryW(StringBuilder lpBuffer, uint uSize);
  3199. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  3200. public static extern int IsProcessorFeaturePresent(uint ProcessorFeature);
  3201. [DllImport(ModuleName, SetLastError = true)]
  3202. public static extern int IsWow64Process(IntPtr hProcess, IntPtr Wow64Process);
  3203. [DllImport(ModuleName, SetLastError = true)]
  3204. public static extern int IsWow64Process(IntPtr hProcess, ref int Wow64Process);
  3205. [DllImport(ModuleName, SetLastError = true)]
  3206. public static extern int SetComputerNameA(IntPtr lpComputerName);
  3207. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Ansi)]
  3208. public static extern int SetComputerNameA(string lpComputerName);
  3209. [DllImport(ModuleName, SetLastError = true)]
  3210. public static extern int SetComputerNameW(IntPtr lpComputerName);
  3211. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Unicode)]
  3212. public static extern int SetComputerNameW(string lpComputerName);
  3213. [DllImport(ModuleName, SetLastError = true)]
  3214. public static extern int SetComputerNameExA(COMPUTER_NAME_FORMAT NameType, IntPtr lpBuffer);
  3215. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Ansi)]
  3216. public static extern int SetComputerNameExA(COMPUTER_NAME_FORMAT NameType, string lpBuffer);
  3217. [DllImport(ModuleName, SetLastError = true)]
  3218. public static extern int SetComputerNameExW(COMPUTER_NAME_FORMAT NameType, IntPtr lpBuffer);
  3219. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Unicode)]
  3220. public static extern int SetComputerNameExW(COMPUTER_NAME_FORMAT NameType, string lpBuffer);
  3221. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  3222. public static extern int VerifyVersionInfoA(IntPtr lpVersionInfo, uint dwTypeMask, ulong dwlConditionMask);
  3223. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Ansi), CLSCompliant(false)]
  3224. public static extern int VerifyVersionInfoA(ref OSVERSIONINFOEX lpVersionInfo, uint dwTypeMask, ulong dwlConditionMask);
  3225. [DllImport(ModuleName, SetLastError = true), CLSCompliant(false)]
  3226. public static extern int VerifyVersionInfoW(IntPtr lpVersionInfo, uint dwTypeMask, ulong dwlConditionMask);
  3227. [DllImport(ModuleName, SetLastError = true, CharSet = CharSet.Unicode), CLSCompliant(false)]
  3228. public static extern int VerifyVersionInfoW(ref OSVERSIONINFOEX lpVersionInfo, uint dwTypeMask, ulong dwlConditionMask);
  3229. [DllImport(ModuleName), CLSCompliant(false)]
  3230. public static extern ulong VerSetConditionMask(ulong dwlConditionMask, uint dwTypeBitMask, byte dwConditionMask);
  3231. }
  3232. #endregion // System information functions
  3233. #region Application recovery and restart functions (Windows NT 6.x or Higher only)
  3234. partial class kernel32
  3235. {
  3236. [DllImport(ModuleName, CallingConvention = CallingConvention.Winapi)]
  3237. public static extern void ApplicationRecoveryFinished(
  3238. [In] int bSuccess);
  3239. [DllImport(ModuleName, CallingConvention = CallingConvention.Winapi)]
  3240. public static extern int ApplicationRecoveryInProgress(
  3241. [Out] IntPtr pbCanceled);
  3242. [DllImport(ModuleName, CallingConvention = CallingConvention.Winapi)]
  3243. public static extern int ApplicationRecoveryInProgress(
  3244. [Out] out int pbCanceled);
  3245. [DllImport(ModuleName, CallingConvention = CallingConvention.Winapi), CLSCompliant(false)]
  3246. public static extern int GetApplicationRecoveryCallback(
  3247. [In] IntPtr hProcess,
  3248. [Out] ApplicationRecoveryCallback pRecoveryCallback,
  3249. [Out] IntPtr ppvParameter,
  3250. [Out] uint dwPingInterval,
  3251. [Out] uint dwFlags);
  3252. [DllImport(ModuleName, CallingConvention = CallingConvention.Winapi, CharSet = CharSet.Unicode), CLSCompliant(false)]
  3253. public static extern int GetApplicationRestartSettings(
  3254. [In] IntPtr hProcess,
  3255. [Out] StringBuilder pwzCommandLine,
  3256. [In] ref uint pcchSize,
  3257. [Out] out uint pdwFlags);
  3258. [DllImport(ModuleName, CallingConvention = CallingConvention.Winapi), CLSCompliant(false)]
  3259. public static extern int RegisterApplicationRecoveryCallback(
  3260. [In] ApplicationRecoveryCallback pRecoveryCallback,
  3261. [In] IntPtr pvParameter,
  3262. [In] uint dwPingInterval,
  3263. [In] uint dwFlags);
  3264. [DllImport(ModuleName, CallingConvention = CallingConvention.Winapi), CLSCompliant(false)]
  3265. public static extern int RegisterApplicationRestart(
  3266. [In] IntPtr pwzCommandLine,
  3267. [In] uint dwFlags);
  3268. [DllImport(ModuleName, CallingConvention = CallingConvention.Winapi, CharSet = CharSet.Unicode), CLSCompliant(false)]
  3269. public static extern int RegisterApplicationRestart(
  3270. [In] string pwzCommandLine,
  3271. [In] uint dwFlags);
  3272. [DllImport(ModuleName, CallingConvention = CallingConvention.Winapi)]
  3273. public static extern int UnregisterApplicationRecoveryCallback();
  3274. [DllImport(ModuleName, CallingConvention = CallingConvention.Winapi)]
  3275. public static extern int UnregisterApplicationRestart();
  3276. }
  3277. #endregion // Application recovery and restart functions (Windows NT 6.x or Higher only)
  3278. }