Introduction SW 운용 중 예상치 못한 exception은 언제나 발생한다. 만약 pdb 파일과 함께 프로세스가 실행중이라면 코드상의 어느 라인에서 예외가 발생했는지까지 윈도우 이벤트 로그를 통해 확인 가능하지만, 대략적인 정보만이 넘어오게 된다. 이 때, dump 파일의 정보가 있으면 비주얼 스튜디오 등을 통해 해당 시점의 SW 상태를 자세히 알 수 있어 분석이 빠르게 진행된다. Example - Declaration of minidump writer 아래는 구현할 Dump() 메서드의 간략한 정보이다. Return type Method Description void Dump() Make minidumps. (Dividen mini and full dump files) Dump type in..
Introduction 상기 그림과 같이, 윈도우에는 색 모드를 설정할 수 있는 옵션이 있다. 다음은 코드를 이용해 윈도우 색 모드 설정값을 얻어오는 방법이다. 레지스트리를 통해 현재 설정값을 판단한다. 값 설명 -1 레지스트리 미발견 0 다크 1 라이트 Code using Microsoft.Win32; namespace WindowsTheme { public static class WindowsThemeColor { public static bool IsDarkTheme() { // 1은 라이트, 0은 다크, -1은 못찾았음 int res = (int)Registry.GetValue($"HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Theme..
Introduction 다음은 코드를 이용해 Form 상태를 지정하는 방법이다. Win32의 user32.dll을 이용하여 form을 조작한다. Code using System; using System.Runtime.InteropServices; using System.Windows.Forms; namespace Win32Test { public static class GUI { [DllImport("user32.dll")] private static extern int ShowWindow(IntPtr hWnd, uint nCmdShow); private const uint SW_RESTORE = 0x09; public static int SetWindow(Form form, uint statusCode..
Introduction C#을 이용하여 레지스트리를 읽고 쓰려는 경우 Win32 API를 통해야한다. 레지스트리 기본 키와 서브 키를 사용하여 레지스트리 값을 읽고 쓸 수 있다. Code using Microsoft.Win32; using System; namespace Registry { public static class Registry { static RegistryKey BaseKey = Microsoft.Win32.Registry.CurrentUser.CreateSubKey(@"Software\Peponi"); public static bool AppendRegistry(string name, string value) { try { BaseKey.SetValue(name, value); } ca..