CWnd::OnDeviceChange
由於需要做即時偵測 usb 的插拔動作,所以最近用了onDeviceChange這個功能... 但,一直無法進入這個副程式。上網搜尋了一下。發現需要三個步驟才行。 Step 1 .在定義 class 成員中加入 protected: afx_msg BOOL OnDeviceChange( UINT nEventType, DWORD dwData ); Step 2 .在 XXX.cpp 中加入BOOL OnDeviceChange(UINT, DWORD); BOOL CXXXXX::OnDeviceChange( UINT nEventType, DWORD dwData ) { switch(nEventType) { // A device has been inserted and is now available. case DBT_DEVICEARRIVAL: // Check to see if newly connected device has VID and PID // matching HID_Blinky's VID and PID if (GetNumHidDevices(C2CS_VID,C2CS_PID)) { // Update Device Status text m_DeviceStatus = "Connected, Idle"; UpdateWindow = TRUE; } break; // A device has been removed from USB. case DBT_DEVICEREMOVECOMPLETE: // Check that the HID_Blinky device was the removed device if (!GetNumHidDevices(C2CS_VID,C2CS_PID)) { // Call routine that will terminate communication and // dest...