STL string_split() DarkKaiser, 2007년 7월 16일2023년 9월 4일 inline void string_split(const std::string& c_st_parent, const std::string& c_st_sep, std::vector<std* pvec_st_child) { string::size_type base = 0; string::size_type end = 0; string::size_type sep_len = c_st_sep.length(); pvec_st_child-clear(); /* pvec_st_child-reserve(16); 적당한 크기로 공간을 예약해 주면 좋겠죠 : ) */ while ( (end = c_st_parent.find_first_of(c_st_sep, base)) = 0) { pvec_st_child-push_back(c_st_parent.substr(base, end Continue Reading
USB장치 연결/연결해제 이벤트 처리하기 DarkKaiser, 2007년 7월 16일2023년 9월 4일 USB 장치가 연결되거나 해제 됐을 때는 이벤트를 처리하는 방법을 여기 저기 찾아 보다가 대충 적어봅니다. 1. 메시지 맵 등록 메시지 맵에 이벤트를 함수와 연결 시킨다. BEGIN_MESSAGE_MAP(CDlg, CDialog) ON_MESSAGE(WM_DEVICECHANGE, fnDeviceChange) END_MESSAGE_MAP() 2. 이벤트를 받을 장치를 등록한다. 장치 등록은 RegisterForDeviceNotifications()함수를 이용한다 void CDlg::RegisterForDeviceNotifications() { DEV_BROADCAST_DEVICEINTERFACE DevBroadcastDeviceInterface; HDEVNOTIFY DeviceNotificationHandle; DevBroadcastDeviceInterface.dbcc_size = sizeof(DevBroadcastDeviceInterface); DevBroadcastDeviceInterface.dbcc_devicetype Continue Reading
시스템 에러메시지 출력하기 DarkKaiser, 2007년 7월 16일2023년 9월 4일 시스템에서 발생한 에러 코드 번호를 그에 해당하는 에러 메시지로 변환하여 출력하는 소스 코드이다. void ShowErrorMsg() { LPVOID lpvMessage; /* retrieve a message from the system message table */ FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR)&lpvMessage, 0, NULL); /* display the message in a message box */ MessageBox(hwndMain, lpvMessage, "Parent Message", MB_ICONEXCLAMATION|MB_OK); Continue Reading
상속과 합성 DarkKaiser, 2007년 7월 16일2023년 8월 30일 ‘Gof의 디자인 패턴’에서는 “Favor object composition over class inheritance”라고 말한다. 이를 해석하면 “객체 합성이 클래스 상속보다 더 나은 방법이다”라는 의미이다. 객체지향 시스템에서 기능의 재사용을 위한 가장 대표적인 두 가지 방법이 상속과 합성이다. 디자인 패턴에서는 상속을 통한 재사용을 ‘white-box reuse’라고 하고 합성을 통한 재사용을 ‘black-box reuse’라고 한다. 먼저, 상속에 대해 살펴보자. Continue Reading
VS6.0/VS2003 레이아웃 레지스트리 DarkKaiser, 2007년 7월 16일2023년 9월 5일 아래의 레지스트리 등록 파일을 다운로드 받아 실행하면 됩니다. VC60_Layout.reg VC++.NET_Layout.reg Continue Reading