#keywords C++,메시지,윈도우,장치 {{{#!gcode ... ON_MESSAGE(WM_DEVICECHANGE, &CTestDlg::OnMyDeviceChange) ... char DriveLetterFromMask(int mask) { int count = 0; while (mask > 1) { mask >>= 1; count++; } return "ABCDEFGHIJKLMNOPQRSTUVWXYZ"[count]; } LRESULT CTestDlg::OnMyDeviceChange(WPARAM wParam, LPARAM lParam) { if ( DBT_DEVICEARRIVAL == wParam || DBT_DEVICEREMOVECOMPLETE == wParam ) { PDEV_BROADCAST_HDR pHdr = (PDEV_BROADCAST_HDR)lParam; PDEV_BROADCAST_DEVICEINTERFACE pDevInf; PDEV_BROADCAST_HANDLE pDevHnd; PDEV_BROADCAST_OEM pDevOem; PDEV_BROADCAST_PORT pDevPort; PDEV_BROADCAST_VOLUME pDevVolume; switch( pHdr->dbch_devicetype ) { case DBT_DEVTYP_DEVICEINTERFACE: pDevInf = (PDEV_BROADCAST_DEVICEINTERFACE)pHdr; //UpdateDevice(pDevInf, wParam); break; case DBT_DEVTYP_HANDLE: pDevHnd = (PDEV_BROADCAST_HANDLE)pHdr; break; case DBT_DEVTYP_OEM: pDevOem = (PDEV_BROADCAST_OEM)pHdr; break; case DBT_DEVTYP_PORT: pDevPort = (PDEV_BROADCAST_PORT)pHdr; break; case DBT_DEVTYP_VOLUME: pDevVolume = (PDEV_BROADCAST_VOLUME)pHdr; CString str; str.Format(_T("%C:"), DriveLetterFromMask(pDevVolume->dbcv_unitmask)); if (wParam == DBT_DEVICEARRIVAL) { OutputDebugString(_T("새 장치 감지")); OutputDebugString(str.GetBuffer(0)); } break; } } #endif return 0; } }}} ---- {{{ 새 장치 감지 F: }}}