c#) args 처리하기 ffmpeg 같은 명령줄 프로그램 같은경우를 보면 -o, -s, -h 등 처리할수 있는 인자값들이 많다. 이걸 C#에서 처리해보자 먼저 argument로 부터 인자값을 받을수있게 함수를 생성한다. static string GetArgument(IEnumerable args, string option) => args.SkipWhile(i => i != option).Skip(1).Take(1).FirstOrDefault(); 방금 만든 GetArgument 함수를 이용하여 --hi098123 다음전달 받은값을 변수에 집어넣거나 바로 처리할 수 있다. var hi098123 = GetArgument(args, "--hi098123"); /* hi098123 변수에 --hi098123 다음으로 입력된 값이 저..
C#) Console.WriteLine 와 Console.Write 차이 차이점 Console.WriteLine 는 출력 이후 줄을 바꿉니다. Console.Write 는 출력만 합니다. 만약, Console.Write에서 줄을 바꾸려면? Console.Write("\n"); 와 같이 써주시면 됩니다. 예시 코드 using System; using System.Collections.Generic; using System.Linq; using System.Text; class Program { static void Main() { Console.Write("1"); Console.Write("2"); Console.Write("3"); Console.WriteLine(); Console.WriteLine("4"); Console.Write("5"); } } 실행결과 123 4 5
C#) 윈도우 정품인증 체크하기 다음과 같은 코드로 확인할 수 있다. public static bool IsWindowsActivated() { ManagementScope scope = new ManagementScope(@"\\" + System.Environment.MachineName + @"\root\cimv2"); scope.Connect(); SelectQuery searchQuery = new SelectQuery("SELECT * FROM SoftwareLicensingProduct WHERE ApplicationID = '55c92734-d682-4d71-983e-d6ec3f16059f' and LicenseStatus = 1"); ManagementObjectSearcher searcherObj = new Manag..
.NET) formclosing vs closing 이 둘의 차이 윈폼에서 종료될때 이벤트는 formclosing 과 closing 이 있습니다. 둘은 어떤 차이가 있을까요? 구글링에서도 그닥 많은 정보를 주지 않아 정리해보았습니다. Closing .net 2.0 이전의 방식입니다. 현재에도 사용 가능하나 안쓰는게 좋습니다. 마이크로소프트에서는 FormClosing 사용을 권장합니다. FormClosing .net 2.0 이후 방식. 종료되는 시간에 뭔가를 하려면 이 기능을 활용하는게 권장됩니다. 예) 종료를 중단 private void front_FormClosing(object sender, FormClosingEventArgs e) { e.cancel = true; } Private Sub front_FormClosing(sender As Object, e As ..
.NET 크로스 스레드 작업이 잘못되었습니다. C# private delegate void Delegatep(object sender, 여기1 e); private void AAA(object sender, 여기1 e) { if (this.InvokeRequired) { Delegatep tmpDelegate; tmpDelegate = new Delegatep(AAA); // AAA 에는 나 자신을 쓴다. this.Invoke(tmpDelegate, sender, e); // 내 자신 쓰레드에서 가능하게 > 다시 나를 호출 } else //다시 나를 호출 이후 > 실제 로 실행 하려던 코드 } VB.NET Private Delegate Sub Delegatep(ByVal sender As Object, ByVal e As 여기1) Private Su..