본문 바로가기

분류 전체보기275

Network Interface Status Event .Net에서 네트워크 인터페이스의 상태를 이벤트로 전달 받을 수 있는 핸들러가 존재한다. https://learn.microsoft.com/en-us/dotnet/api/system.net.networkinformation.networkchange?source=recommendations&view=net-7.0 NetworkChange Class (System.Net.NetworkInformation) Allows applications to receive notification when the Internet Protocol (IP) address of a network interface, also called a network card or adapter, changes. learn.microsoft.. 2023. 5. 24.
C#에서 네트워크 드라이브(Network Drive) 연결 방법 C#에서 네트워크 드라이브를 이용하기 위해서는 "mrp.dll"을 Import 해서 사용을 해야 한다. [DllImport("mpr.dll", CharSet = CharSet.Auto)] public static extern int WNetUseConnection( IntPtr hwndOwner, [MarshalAs(UnmanagedType.Struct)] ref NETRESOURCE lpNetResource, string lpPassword, string lpUserID, uint dwFlags, StringBuilder lpAccessName, ref int lpBufferSize, out uint lpResult); [DllImport("mpr.dll", CharSet = CharSet.Auto)].. 2023. 5. 24.
HEX CString to BYTE array MFC Unicode CString을 BYTE 배열로 리턴하는 함수 예제 HEX string은 "0xab 0x01 0x02 0x03 0xfa 0xFF"와 같이 Space로 구분되어 있을 경우 /// 유니코드 CString /// strData = _T("0xab 0x01 0x02 0x03 0xfa 0xFF"); /// rt[] = { 253, 1, 2, 3, 250, 255 }; byte* etUsbTestDlg::StringToHex(CString strData) { CString strValue; int i = 0; // substring index to extract TCHAR chSep = ' '; byte rt[1024] = { 0, }; while (AfxExtractSubString(strV.. 2023. 5. 8.
Team Foundation Server 버전 제어" 경고 메시지 제거 방법 MSVS 프록젝트 실행할 때 "Team Foundation Server 버전 제어" 경고 메시지 제거 방법 Team Foundation Server 버전 제어 열려는 솔루션은 Azure DevOps Server http://192.168.11.40:8080/tfs/general%20applications의 소스 제어에 바인딩되어 있습니다. 이 서버에 연결하여 소스 제어 통합을 사용하도록 설정하시겠습니까? 위와 같이 경고 메시지가 표시되는 프로젝트가 존재한다. Team Foundation Server를 설정한 프로젝트인데 나는 SVN을 사용하기 때문에 이 경고 메시지를 삭제하고 싶다. 이때 Solution 파일을 열어 보면 아래와 같은 Tag가 존재하다. GlobalSection(TeamFoundation.. 2023. 4. 20.
C# UI Thread 에러 발생할 경우 C#에서 UI Thread 오류가 발생할 경우 아래와 같이 하나의 UI가 끝날 때까지 DoEvents() 함수를 호출하고 일정 시간이 지난 후에 UI 변경을 하도록 처리한다. for (int i = 0; i < 10; i++) { System.Windows.Forms.Application.DoEvents(); System.Threading.Thread.Sleep(1); } Tree의 Popup 메뉴로 창을 띄우는 코드를 하는데 Tree가 선택되어 Expand 되는 도중에 ShowDialog가 호출되어 UI Thread 오류가 발생했다. 그래서 Expand가 끝나는 시간까지 DoEvents 함수를 호출하게 한 후에 ShowDialog가 호출되니 오류가 발생하지 않았다. 2023. 2. 13.
WinForm안에 있는 WFP 창에서 owner를 지정하는 방법 WFP에서 Owner를 지정할 아래와 같이 사용할 수 있다. Owner = Application.Current.MainWindow; 그런데 WinForm안에 WPF를 이용할 때 WPF의 Dialog Owner를 기존과 같은 방식으로하면 Current가 null 에러가 발생한다. WinForm에서부터 Window Handle을 넘겨 받아 사용할 수도 있지만 아래와 같이 Process에서 Handle을 받아서 처리를 할 수도 있다. WPFTestView dlg = new WPFTestView(); System.IntPtr iMainHandle = System.Diagnostics.Process.GetCurrentProcess().MainWindowHandle; System.Windows.Interop.Win.. 2023. 2. 8.
C# split 사용 방법 https://learn.microsoft.com/ko-kr/dotnet/csharp/how-to/parse-strings-using-split String.Split을 사용하여 문자열 나누기(C# 가이드) Split 메서드는 구분 기호 세트에서 분리된 문자열 배열을 반환합니다. 문자열에서 부분 문자열을 추출하는 간편한 방법입니다. learn.microsoft.com char[] delimiterChars = { ' ', ',', '.', ':', '\t' }; string text = "one\ttwo three:four,five six seven"; System.Console.WriteLine($"Original text: '{text}'"); string[] words = text.Split(del.. 2023. 1. 19.
CODESYS Simulator password 초기화 방법 CODESYS를 설치하면 아래와 같은 Simulator 폴더가 존재한다. C:\ProgramData\CODESYS\CODESYSControlWinV3x64 폴더안에 모든 파일을 삭제하면 password가 초기화 되어 다시 처음부터 입력하는 창이 표시된다. 폴더를 삭제하기 위해서는 Stop PLC를 메뉴를 눌러 시뮬레이터가 멈춘 한 후에 삭제가 가능하다. 삭제 후 실행을 하면 아래와 같이 새로 password를 입력하는 창을 확인할 수 있다. 2022. 12. 27.
MFC jsoncpp 설치 jsoncpp 를 library 로 만들지 않고 source 와 header 파일을 프로젝트에 포함해서 사용 가능합니다. 1. jsoncpp download download link : https://github.com/open-source-parsers/jsoncpp 2. python를 설치하고, 다운받은 json 폴더의 amalgamate.py 파일 실행합니다. 생성된 dist 폴더를 확인합니다. 3. dist 폴더 이동해서 생성된 파일을 확인합니다. jsoncpp.cpp , json.h, json-forwards.h 파일을 프로젝트에 추가해서 함께 빌드합니다. 2022. 11. 28.
LIST