| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- using System;
- using System.Collections.Generic;
- using System.Text;
- 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;
- }
- }
|