| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- using System;
- using System.Runtime.InteropServices;
- namespace winsw
- {
- /// <summary>
- /// kernel32.dll P/Invoke wrappers
- /// </summary>
- internal class Kernel32
- {
- [DllImport("Kernel32.dll", SetLastError = true)]
- internal static extern int SetStdHandle(int device, IntPtr handle);
- [DllImport("kernel32.dll", SetLastError = true)]
- internal static extern bool CreateProcess(string lpApplicationName,
- string lpCommandLine, IntPtr lpProcessAttributes,
- IntPtr lpThreadAttributes, bool bInheritHandles,
- uint dwCreationFlags, IntPtr lpEnvironment, string lpCurrentDirectory,
- [In] ref STARTUPINFO lpStartupInfo,
- out PROCESS_INFORMATION lpProcessInformation);
- [DllImport("kernel32.dll")]
- internal static extern int GetLastError();
- }
- [StructLayout(LayoutKind.Sequential)]
- internal struct PROCESS_INFORMATION
- {
- public IntPtr hProcess;
- public IntPtr hThread;
- public int dwProcessId;
- public int dwThreadId;
- }
- [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
- struct STARTUPINFO
- {
- public Int32 cb;
- public string lpReserved;
- public string lpDesktop;
- public string lpTitle;
- public Int32 dwX;
- public Int32 dwY;
- public Int32 dwXSize;
- public Int32 dwYSize;
- public Int32 dwXCountChars;
- public Int32 dwYCountChars;
- public Int32 dwFillAttribute;
- public Int32 dwFlags;
- public Int16 wShowWindow;
- public Int16 cbReserved2;
- public IntPtr lpReserved2;
- public IntPtr hStdInput;
- public IntPtr hStdOutput;
- public IntPtr hStdError;
- }
- }
|