是一个抢先删除autorun.inf文件的例子,比360快,其实知道这个东西其他的就基本知道了,可以自己查SDK UINT GetDriveFromMask(ULONG unitmask) { char i; for (i = 0; i < 26; ++i) { if (unitmask & 0x1) break; unitmask = unitmask >> 1; } return (i + 'A'); }
LRESULT CHotkeyDlg::DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam) { if(message == WM_DEVICECHANGE) { CString str; DEV_BROADCAST_HDR* dhr = (DEV_BROADCAST_HDR *)lParam; switch(wParam) { case DBT_DEVICEARRIVAL: if(dhr->dbch_devicetype == DBT_DEVTYP_VOLUME) { PDEV_BROADCAST_VOLUME lpdbv = (PDEV_BROADCAST_VOLUME)dhr; str.Format("%c:\\autorun.inf",GetDriveFromMask(lpdbv->dbcv_unitmask)); DeleteFile(str); AfxMessageBox(str); } break; default:break; } } return CDialog::DefWindowProc(message, wParam, lParam); } |