๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
728x90
๋ฐ˜์‘ํ˜•

๐Ÿ‘จ๐Ÿผ‍๐Ÿ’ป๊ฐœ๋ฐœ/C#23

C# - Application.Exit() ๋ช…๋ น์–ด ์•ˆ๋  ๊ฒฝ์šฐ (Environment.Exit(Environment.ExitCode)) Environment.Exit(Environment.ExitCode); ์ถœ์ฒ˜: https://stackoverflow.com/questions/25050341/application-is-still-running-in-memory-after-application-exit-is-called Application is still running in memory after Application.Exit() is called The application I am building is still running in memory (checked in Task Manager) after it is closed using Application.Exit(). Because of this when I am running i.. 2022. 9. 26.
C# - .NET ๋””์ปดํŒŒ์ผ๋Ÿฌ ๋ฐ ์–ด์…ˆ๋ธ”๋ฆฌ ๋ธŒ๋ผ์šฐ์ €(dotPeek) https://www.jetbrains.com/ko-kr/decompiler/ dotPeek: JetBrains๊ฐ€ ๋งŒ๋“  ๋ฌด๋ฃŒ .NET ๋””์ปดํŒŒ์ผ๋Ÿฌ ๋ฐ ์–ด์…ˆ๋ธ”๋ฆฌ ๋ธŒ๋ผ์šฐ์ € www.jetbrains.com 2022. 9. 4.
C# - setTimeout ๊ตฌํ˜„ ๋ฐฉ๋ฒ• 1. Task.Delay(delay).ContinueWith((task) => { /* Code */ }); ๋ฐฉ๋ฒ• 2. public void setTimeout(Action TheAction, int Timeout) { Thread t = new Thread( () => { Thread.Sleep(Timeout); TheAction.Invoke(); } ); t.Start(); } ์ถœ์ฒ˜: https://stackoverflow.com/questions/4331149/winforms-equivalent-of-javascript-settimeout Winforms equivalent of javascript setTimeout Is there a simple solution/idea/strategy t.. 2022. 8. 28.
C# - ํ”„๋กœ์„ธ์Šค ์ด๋ฆ„์œผ๋กœ ํ”„๋กœ์„ธ์Šค ์ฃฝ์ด๊ธฐ(Process) ์ฝ”๋“œ public void killPorcesses(string pname) { Process[] processList = Process.GetProcessesByName(pname); if(processList.Length > 0) { for(int i=0; i < processList.Length; i++) { processList[i].Kill(); } } } killPorcesses("notepad"); ์ถœ์ฒ˜: https://infodbbase.tistory.com/92 C# Process ์‚ฌ์šฉํ•˜๊ธฐ #3 ( ํŠน์ • ํ”„๋กœ์„ธ์Šค ์ข…๋ฃŒ(Kill) ) ์•ˆ๋…•ํ•˜์„ธ์š”, ์ด๋ฒˆ ํฌ์ŠคํŒ…์€ C# ์—์„œ Process ๋ฅผ ์ด์šฉํ•˜์—ฌ ํŠน์ • ํ”„๋กœ์„ธ์Šค๋ฅผ ์ข…๋ฃŒ์‹œํ‚ค๋Š” ๋ฐฉ๋ฒ•์„ ์ •๋ฆฌํ•˜์˜€์Šต๋‹ˆ๋‹ค. 1. ํŠน์ • ํ”„๋กœ์„ธ์Šค ๊ฐ€ ์‹คํ–‰ ๋˜์–ด ์žˆ์„ ๊ฒฝ์šฐ.. 2022. 8. 28.
C# - ๋‹ค๋ฅธ ํ”„๋กœ๊ทธ๋žจ ์‹คํ–‰ ์‹œํ‚ค๊ธฐ(Porcess.Start) with ์‹œ์ž‘ ๊ฒฝ๋กœ ์ง€์ • ์˜ˆ์ œ ํ•œ ์ค„๋กœ ํ”„๋กœ๊ทธ๋žจ ์‹คํ–‰์‹œํ‚ค๊ธฐ System.Diagnostics.Process.Start(".\\Agents\\MCROAgent" + idx.ToString() + "\\clicker.exe"); ํ”„๋กœ๊ทธ๋žจ ์‹œ์ž‘ ๊ฒฝ๋กœ ๋“ฑ ๋‹ค์–‘ํ•œ ์˜ต์…˜ ์„ค์ • Process process = new Process(); process.StartInfo.WorkingDirectory = "Agents\\MCROAgent" + idx.ToString(); // ์‹œ์ž‘ ๊ฒฝ๋กœ process.StartInfo.FileName = "clicker.exe"; // ํŒŒ์ผ ์ด๋ฆ„ process.Start(); * ํ”„๋กœ๊ทธ๋žจ์˜ ํด๋” ๋‚ด์—์„œ ์‹คํ–‰์‹œ์ผœ์•ผ๋งŒ ํ•  ๊ฒฝ์šฐ ์ถœ์ฒ˜: https://heon-dev.tistory.com/7 Process.Start(.. 2022. 8. 28.
C# - ํ”„๋กœ๊ทธ๋žจ ์ค‘๋ณต ์‹คํ–‰ ๋ฐฉ์ง€ํ•˜๊ธฐ ๋ฐฉ๋ฒ• 1. ํ”„๋กœ์„ธ์Šค ์ด๋ฆ„ ์ค‘๋ณต ๊ฐ์ง€ //์ด๋ฏธ ํ”„๋กœ๊ทธ๋žจ์ด ์‹คํ–‰ ์ค‘ ์ผ๋•Œ... System.Diagnostics.Process[] processes = null; string strCurrentProcess = System.Diagnostics.Process.GetCurrentProcess().ProcessName.ToUpper(); processes = System.Diagnostics.Process.GetProcessesByName(strCurrentProcess); if (processes.Length > 1) { MessageBox.Show(string.Format("'{0}' ํ”„๋กœ๊ทธ๋žจ์ด ์ด๋ฏธ ์‹คํ–‰ ์ค‘์ž…๋‹ˆ๋‹ค.", System.Diagnostics.Process.GetCurrentProcess().Pr.. 2022. 8. 26.
C# - ๋‹ค๋ฅธ ํ”„๋กœ์„ธ์Šค๋ผ๋ฆฌ ๋ฉ”์‹œ์ง€(string) ์ „๋‹ฌํ•˜๊ธฐ(SendMessage) ์ˆ˜์‹  const int WM_COPYDATA = 0x4A; public struct COPYDATASTRUCT { public IntPtr dwData; public int cbData; [MarshalAs(UnmanagedType.LPStr)] public string lpData; } protected override void WndProc(ref Message m) { try { switch (m.Msg) { case WM_COPYDATA: COPYDATASTRUCT cds = (COPYDATASTRUCT)m.GetLParam(typeof(COPYDATASTRUCT)); MessageBox.Show(cds.lpData); break; default: base.WndProc(ref m); break;.. 2022. 8. 24.
C# - ๋‹ค๋ฅธ ์‘์šฉํ”„๋กœ๊ทธ๋žจ์„ ์ œ์–ดํ•ด ๋ณด์ž. feat.SPY++ ๊ฐ„ํ˜น ๊ฐœ๋ฐœ์„ ํ•˜๋‹ค๋ณด๋ฉด ์™ธ๋ถ€ ์‘์šฉํ”„๋กœ๊ทธ๋žจ์„ ์—ฐ๊ณ„ํ•˜๊ฑฐ๋‚˜ ์ œ์–ดํ•ด์•ผํ•  ์ผ์ด ์žˆ๋‹ค. ์ผ๋ฐ˜์ ์œผ๋กœ ๋ณธ์ธ์ด ๋งŒ๋“ (์†Œ์Šค๊ฐ€ ์žˆ๋Š”) ํ”„๋กœ๊ทธ๋žจ์ด๋ผ๋ฉด ์†์‰ฝ๊ฒ ์ง€๋งŒ ์•„๋‹Œ๊ฒฝ์šฐ๊ฐ€ ๋Œ€๋ถ€๋ถ„์ด๋‹ค. ๊ทธ๋Ÿด๋•Œ๋Š” Window Message๋ฅผ ์ด์šฉํ•˜์—ฌ ๋‹ค๋ฅธ ์‘์šฉํ”„๋กœ๊ทธ๋žจ์„ ์ œ์–ดํ•  ์ˆ˜ ์žˆ๋‹ค. ๋ชจ๋“  ์œˆ๋„์šฐ ์‘์šฉํ”„๋กœ๊ทธ๋žจ์€ ์œˆ๋„์šฐ์ฆˆ ์•ˆ์—์„œ ๋™์ž‘ํ•˜๊ธฐ๋•Œ๋ฌธ์— ๊ณตํ†ต๋œ ๋ฉ”์‹œ์ง€๋ฅผ ์ด์šฉํ•˜์—ฌ ์ œ์–ดํ•˜๋Š” ๋ฐฉ๋ฒ•์ด๋‹ค. ์˜ˆ์ œ ๋‹ค์Œ์€ ๊ณ„์‚ฐ๊ธฐ ์‘์šฉํ”„๋กœ๊ทธ๋žจ์˜ ํ•ธ๋“ค์„ ์ฐพ์•„์„œ ํ•ด๋‹น ํ•ธ๋“ค์— ๋ฉ”์‹œ์ง€๋ฅผ ๋ณด๋‚ด๋Š” ์˜ˆ์ œ์ด๋‹ค. using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windo.. 2022. 8. 24.
C# - ์Šค๋ ˆ๋“œ์—์„œ ์œ„์ ฏ ์กฐ์ž‘ํ•˜๊ธฐ private void AggiornaContatore() { if(this.lblCounter.InvokeRequired) { this.lblCounter.BeginInvoke((MethodInvoker) delegate() {this.lblCounter.Text = this.index.ToString(); ;}); } else { this.lblCounter.Text = this.index.ToString(); ; } } Invoker ์‚ฌ์šฉ ์ถœ์ฒ˜: https://stackoverflow.com/questions/14890295/update-label-from-another-thread Update label from another thread I use a thread writing in anothe.. 2022. 8. 23.
C# - http ์š”์ฒญ(HttpWebRequest) string url = "https://ipinfo.io/ip"; //ํ…Œ์ŠคํŠธ ์‚ฌ์ดํŠธ string responseText = string.Empty; HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); request.Method = "GET"; using (HttpWebResponse resp = (HttpWebResponse)request.GetResponse()) { HttpStatusCode status = resp.StatusCode; Console.WriteLine(status); // ์ •์ƒ์ด๋ฉด "OK" Stream respStream = resp.GetResponseStream(); using (StreamReader sr = ne.. 2022. 6. 27.
C# - ๊ฐ„๋‹จํ•œ API ์š”์ฒญ & JSON ์ถœ๋ ฅ using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using System.Net; using Newtonsoft.Json.Linq; namespace covidView { public partial class Form1 : Form { private const string URL = "https://api.corona-19.kr/korea/beta/"; private strin.. 2022. 2. 2.
728x90
๋ฐ˜์‘ํ˜•