본문 바로가기
반응형
[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.
System.Runtime.InteropServices.COMException (0x80040154): 클래스가 등록되지 않았습니다. (예외가 발생한 HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)) "System.Runtime.InteropServices.COMException (0x80040154): 클래스가 등록되지 않았습니다. (예외가 발생한 HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG))" 위와 같은 에러가 발생할 때 저같은 경우는 ActiveX Control 을 C# 프로젝트에 삽입하고 실행할 때 Runtime 에러가 발생해서 확인해보니 일반적으로 C#의 경우 빌드 플랫폼이 AnyCPU 로 되어 있습니다. 이것을 x86 또는 ActiveX 가 제작된 플랫폼으로 변경을 해야 됩니다. 이렇게 문제 해결 완료 ~^^ 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#] EventHandler 이벤트 핸들러 만들기 기본적으로 위와 같은 프로세스를 거치도록 되어 있음. OPEN API 에서 종목별 REAL 현재가가 업데이트 될 때 이것을 DB 화 하고 각 차트에 이 DB 를 사용해서 업데이트 하라고 하기 위해 이벤트를 전달 하기 위해 사용함 이벤트가 발생하는 클래스에 외부로 부터 이벤트 핸들러 함수를 받을 수 있도록 예를들어 이런 함수들을 만든다. public delegate void price_update_handler(RealPriceEventArgs e); public event price_update_handler m_price_update_handler; public void SetPriceEventHandler(ref price_update_handler priceHandler) { if (priceHan.. 2022. 9. 21.
[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.
반응형