using System;
using System.Runtime.InteropServices;
#region 프로세스 생성하기 - CreateProcess(applicationName, commandLine, processAttributes, threadAttributes, inheritHandles, creationFlag, environmentHandle, currentDirectoryPath, startupInfo, processInformation)
/// <summary>
/// 프로세스 생성하기
/// </summary>
/// <param name="applicationName">애플리케이션명</param>
/// <param name="commandLine">명령줄</param>
/// <param name="processAttributes">프로세스 어트리뷰트</param>
/// <param name="threadAttributes">스레드 어트리뷰트</param>
/// <param name="inheritHandles">핸들 상속 여부</param>
/// <param name="creationFlag">생성 플래그</param>
/// <param name="environmentHandle">환경 핸들</param>
/// <param name="currentDirectoryPath">현재 디렉토리 경로</param>
/// <param name="startupInfo">시작시 정보</param>
/// <param name="processInformation">프로세스 정보</param>
/// <returns>처리 결과</returns>
[DllImport("kernel32")]
[return: MarshalAs(UnmanagedType.Bool)]
private static extern bool CreateProcess
(
string applicationName,
string commandLine,
ref SECURITY_ATTRIBUTES processAttributes,
ref SECURITY_ATTRIBUTES threadAttributes,
bool inheritHandles,
uint creationFlag,
IntPtr environmentHandle,
string currentDirectoryPath,
[In] ref STARTUPINFOEX startupInfo,
out PROCESS_INFORMATION processInformation
);
#endregion
/// <summary>
/// 보안 어트리뷰트
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public struct SECURITY_ATTRIBUTES
{
//////////////////////////////////////////////////////////////////////////////////////////////////// Field
////////////////////////////////////////////////////////////////////////////////////////// Public
#region Field
/// <summary>
/// 길이
/// </summary>
public int Length;
/// <summary>
/// 보안 설명자
/// </summary>
public IntPtr SecurityDescriptor;
/// <summary>
/// 핸들 상속 여부
/// </summary>
[MarshalAs(UnmanagedType.Bool)]
public bool InheritHandle;
#endregion
}
/// <summary>
/// 시작시 정보
/// </summary>
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct STARTUPINFO
{
//////////////////////////////////////////////////////////////////////////////////////////////////// Field
////////////////////////////////////////////////////////////////////////////////////////// Public
#region Field
/// <summary>
/// 바이트 카운트
/// </summary>
public int ByteCount;
/// <summary>
/// 예약
/// </summary>
public string Reserved;
/// <summary>
/// 데스크톱
/// </summary>
public string Desktop;
/// <summary>
/// 제목
/// </summary>
public string Title;
/// <summary>
/// X
/// </summary>
public int X;
/// <summary>
/// Y
/// </summary>
public int Y;
/// <summary>
/// X 크기
/// </summary>
public int XSize;
/// <summary>
/// Y 크기
/// </summary>
public int YSize;
/// <summary>
/// X 문자 카운트
/// </summary>
public int XCountCharacters;
/// <summary>
/// Y 문자 카운트
/// </summary>
public int YCountCharacters;
/// <summary>
/// 칠하기 어트리뷰트
/// </summary>
public int FillAttribute;
/// <summary>
/// 플래그
/// </summary>
public int Flag;
/// <summary>
/// 윈도우 표시
/// </summary>
public short ShowWindow;
/// <summary>
/// 예약 2 바이트 카운트
/// </summary>
public short Reserved2ByteCount;
/// <summary>
/// 예약 2 핸들
/// </summary>
public IntPtr Reserved2Handle;
/// <summary>
/// 표준 입력 핸들
/// </summary>
public IntPtr StandardInputHandle;
/// <summary>
/// 표준 출력 핸들
/// </summary>
public IntPtr StandardOutputHandle;
/// <summary>
/// 표준 에러 핸들
/// </summary>
public IntPtr StandardErrorHandle;
#endregion
}
/// <summary>
/// 시작시 정보 (확장)
/// </summary>
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct STARTUPINFOEX
{
//////////////////////////////////////////////////////////////////////////////////////////////////// Field
////////////////////////////////////////////////////////////////////////////////////////// Public
#region Field
/// <summary>
/// 시작시 정보
/// </summary>
public STARTUPINFO StartupInfo;
/// <summary>
/// 어트리뷰트 리스트 핸들
/// </summary>
public IntPtr AttributeListHandle;
#endregion
}