From: newton-cn Date: Sat, 3 May 2025 08:08:25 +0000 (+0900) Subject: 테스트 X-Git-Url: https://git.insang.kr/gitweb/?a=commitdiff_plain;h=34aa28110ba7a69babf2d3a60ba2ed913aafade1;p=newton-cn_pos.git 테스트 --- diff --git a/.vs/newton-cn/v16/.suo b/.vs/newton-cn/v16/.suo index 6f7f6d9..ecf2578 100644 Binary files a/.vs/newton-cn/v16/.suo and b/.vs/newton-cn/v16/.suo differ diff --git a/newton-cn/USBControl.cs b/newton-cn/USBControl.cs index e8207a6..8486e3f 100644 --- a/newton-cn/USBControl.cs +++ b/newton-cn/USBControl.cs @@ -1,4 +1,5 @@ using System; +using System.IO; using System.Management; // ##### 유기중.... 언젠가 해야지 @@ -23,13 +24,12 @@ class USBControl } return result; } - public static void test() - { - } // 장치 비활성화 public static void DisableDevice(string where) { + string textFile = @"c:\temp\newton-cn_log.txt"; + string deviceId = getDeviceId(where); try { @@ -38,11 +38,42 @@ class USBControl foreach (ManagementObject device in searcher.Get()) { ManagementBaseObject outParams = device.InvokeMethod("Disable", null, null); + if (!System.IO.File.Exists(textFile)) + { + using (StreamWriter sw = File.CreateText(textFile)) + { + sw.WriteLine($"장치 {deviceId}가 비활성화되었습니다."); + } + } + else + { + using (StreamWriter sw= File.AppendText(textFile)) + { + sw.WriteLine($"장치 {deviceId}가 비활성화되었습니다."); + } + } Console.WriteLine($"장치 {deviceId}가 비활성화되었습니다."); } } catch (Exception ex) { + if (!System.IO.File.Exists(textFile)) + { + if (!System.IO.File.Exists(textFile)) + { + using (StreamWriter sw = File.CreateText(textFile)) + { + sw.WriteLine($"USB 장치 정보를 가져오는 중 오류 발생: {ex.Message}"); + } + } + else + { + using (StreamWriter sw = File.AppendText(textFile)) + { + sw.WriteLine($"USB 장치 정보를 가져오는 중 오류 발생: {ex.Message}"); + } + } + } Console.WriteLine($"USB 장치 정보를 가져오는 중 오류 발생: {ex.Message}"); } } @@ -50,6 +81,7 @@ class USBControl // 장치 활성화 public static void EnableDevice(string where) { + string textFile = @"c:\temp\newton-cn_log.txt"; string deviceId = getDeviceId(where); try { @@ -58,11 +90,39 @@ class USBControl foreach (ManagementObject device in searcher.Get()) { ManagementBaseObject outParams = device.InvokeMethod("Enable", null, null); + if (!System.IO.File.Exists(textFile)) + { + using (StreamWriter sw = File.CreateText(textFile)) + { + sw.WriteLine($"장치 {deviceId}가 활성화되었습니다."); + } + } + else + { + using (StreamWriter sw = File.AppendText(textFile)) + { + sw.WriteLine($"장치 {deviceId}가 활성화되었습니다."); + } + } Console.WriteLine($"장치 {deviceId}가 활성화되었습니다."); } } catch (Exception ex) { + if (!System.IO.File.Exists(textFile)) + { + using (StreamWriter sw = File.CreateText(textFile)) + { + sw.WriteLine($"USB 장치 정보를 가져오는 중 오류 발생: {ex.Message}"); + } + } + else + { + using (StreamWriter sw = File.AppendText(textFile)) + { + sw.WriteLine($"USB 장치 정보를 가져오는 중 오류 발생: {ex.Message}"); + } + } Console.WriteLine($"USB 장치 정보를 가져오는 중 오류 발생: {ex.Message}"); } diff --git a/newton-cn/bin/Debug/newton-cn.exe b/newton-cn/bin/Debug/newton-cn.exe index 4af8ac4..03dcd18 100644 Binary files a/newton-cn/bin/Debug/newton-cn.exe and b/newton-cn/bin/Debug/newton-cn.exe differ diff --git a/newton-cn/bin/Debug/newton-cn.pdb b/newton-cn/bin/Debug/newton-cn.pdb index 33d684c..170a19f 100644 Binary files a/newton-cn/bin/Debug/newton-cn.pdb and b/newton-cn/bin/Debug/newton-cn.pdb differ diff --git a/newton-cn/bin/Release/newton-cn.exe b/newton-cn/bin/Release/newton-cn.exe index f18b07f..6233d1a 100644 Binary files a/newton-cn/bin/Release/newton-cn.exe and b/newton-cn/bin/Release/newton-cn.exe differ diff --git a/newton-cn/bin/Release/newton-cn.pdb b/newton-cn/bin/Release/newton-cn.pdb index f9322bf..a61b6ba 100644 Binary files a/newton-cn/bin/Release/newton-cn.pdb and b/newton-cn/bin/Release/newton-cn.pdb differ diff --git a/newton-cn/obj/Debug/DesignTimeResolveAssemblyReferences.cache b/newton-cn/obj/Debug/DesignTimeResolveAssemblyReferences.cache index 2660994..bf06e01 100644 Binary files a/newton-cn/obj/Debug/DesignTimeResolveAssemblyReferences.cache and b/newton-cn/obj/Debug/DesignTimeResolveAssemblyReferences.cache differ diff --git a/newton-cn/obj/Debug/newton-cn.exe b/newton-cn/obj/Debug/newton-cn.exe index 4af8ac4..03dcd18 100644 Binary files a/newton-cn/obj/Debug/newton-cn.exe and b/newton-cn/obj/Debug/newton-cn.exe differ diff --git a/newton-cn/obj/Debug/newton-cn.pdb b/newton-cn/obj/Debug/newton-cn.pdb index 33d684c..170a19f 100644 Binary files a/newton-cn/obj/Debug/newton-cn.pdb and b/newton-cn/obj/Debug/newton-cn.pdb differ diff --git a/newton-cn/obj/Release/newton-cn.exe b/newton-cn/obj/Release/newton-cn.exe index f18b07f..6233d1a 100644 Binary files a/newton-cn/obj/Release/newton-cn.exe and b/newton-cn/obj/Release/newton-cn.exe differ diff --git a/newton-cn/obj/Release/newton-cn.pdb b/newton-cn/obj/Release/newton-cn.pdb index f9322bf..a61b6ba 100644 Binary files a/newton-cn/obj/Release/newton-cn.pdb and b/newton-cn/obj/Release/newton-cn.pdb differ