본문 바로가기
반응형
[C#] RestFul API 서버 만들기 예제 1. Visual Studio 2019 로 프로젝트를 생성합니다. 2. 필요에 따른 아래 컴포넌트를 소스 상단에 추가 합니다. using Newtonsoft.Json; using System.Net; using System.Net.Http; using System.IO; 3. 서버 시작을 위한 함수를 선언합니다. // 관리자 컨솔에서 아래 주소를 등록해야 한다. //netsh http add urlacl url=http://+:8686/ user=everyone private void serverInit() { if (httpListener == null) { httpListener = new HttpListener(); httpListener.Prefixes.Add(string.Format("http:.. 2023. 7. 6.
[C#] Excel 생성/읽기 데이터 저장하기 아래 코드 주석 참조 Excel.Application excelApp = null; Excel.Workbook wb = null; Excel.Worksheet ws = null; string path = Path.Combine(Environment.CurrentDirectory.ToString(), "output.xlsx"); try { excelApp = new Excel.Application(); //wb = excelApp.Workbooks.Open(path); // 기존 파일 읽어 올 때 wb = excelApp.Workbooks.Add(); // 신규 생성활 때 ws = wb.Worksheets.get_Item(1) as Excel.Worksheet; // 저장하기 위한 데이터 크기 지정 int.. 2022. 10. 5.
[C#] Kiwoom 로그인 수동 제어 로그인 창을 수동 제어 하기 위해 필요한 함수들. using System.Runtime.InteropServices; using System.Threading; [DllImport("user32.dll")] public static extern IntPtr FindWindow(string lpClassName, string lpWindowName); [DllImport("user32.dll")] public static extern int findWindowEx(int hWnd1, int hWnd2, string lpsz1, string lpsz2); [DllImport("User32.dll")] public static extern int SendMessage(IntPtr hWnd, int uMsg, .. 2022. 9. 13.
[C#] Thread 생성 하기 스레드 생성 코드 샘플 using System.Threading; Thread m_listenThread; //생성자 m_listenThread = new Thread(new ThreadStart(th_Listen)); private void th_Listen() { //스레드 함수 구현 } 2021. 7. 16.
[C#] System.InvalidOperationException 에러 서로 다른 Thread 에서 하나의 UI 객체 접근을 하거나 할 때 발생하는 경우 아래와 같은 invoke 함수를 구현하여 처리 할 수 있음. invoke 함수를 정의 하고 이를 생성한 후 control 의 Invoke 에 전달하여 위와 같은 에러를 회피 할 수 있음. 예) Control 의 Text 속성에 접근할 때 delegate void Ctr_Involk1(Control ctr, string text); public void setText_Control(Control ctr, string txtValue { if (ctr.InvokeRequired) { Ctr_Involk1 CI = new Ctr_Involk1(setText_Control); ctr.Invoke(CI, ctr, txtValue);.. 2021. 7. 16.
반응형