■ Process 클래스에서 명령줄을 구하는 방법을 보여준다.
▶ Process 클래스 : 명령줄 구하기 예제 (C#)
1 2 3 4 5 6 7 |
using System.Diagnostics; Process process = Process.GetCurrentProcess(); string commandLine = GetCommandLine(process); |
▶ Process 클래스 : 명령줄 구하기 (C#)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
using System.Diagnostics; using System.Management; using System.Text; #region 명령줄 구하기 - GetCommandLine(process) /// <summary> /// 명령줄 구하기 /// </summary> /// <param name="process">프로세스</param> /// <returns>명령줄</returns> private static string GetCommandLine(Process process) { StringBuilder stringBuilder = new StringBuilder(); using ( ManagementObjectSearcher searcher = new ManagementObjectSearcher ( "SELECT CommandLine FROM Win32_Process WHERE ProcessId = " + process.Id ) ) { foreach(ManagementBaseObject baseObject in searcher.Get()) { stringBuilder.Append(baseObject["CommandLine"]); stringBuilder.Append(" "); } } string commandLine = stringBuilder.ToString().Trim(); return commandLine; } #endregion |