Tools
1. DebugView,输出调试信息(不能F5,而是要Ctrl + F5,F5输出到VC的debug窗口)
1 void DbgPrint(char* pFMT, ...) 2 { 3 char szBuf[1024] = {0}; 4 va_list lst; 5 va_start(lst, pFMT); 6 vsprintf(szBuf, pFMT, lst); 7 va_end(lst); 8 9 OutputDebugString(szBuf); 10 }
2. C语言,拼接字符串
1 //使用后要free 2 char* split(char* a, char* b) 3 { 4 char* c = (char*)malloc(strlen(a) + strlen(b) + 1); 5 if (c == NULL) 6 { 7 return NULL; 8 } 9 10 char* tempc = c; 11 while (*a != '\0') 12 { 13 *tempc++ = *a++; 14 } 15 while ((*tempc++ = *b++) != '\0'); 16 17 return c; 18 }
3. 响应 WM_DROPFILES 消息(#define WM_DROPFILES 0x0233)
1)MFC版
1 void CTestDlg::OnDropFiles(HDROP hDropInfo) 2 { 3 char szPath[MAX_PATH] = {0}; 4 5 DragQueryFile(hDropInfo, NULL, szPath, sizeof(szPath) / sizeof(*szPath)); 6 DragFinish(hDropInfo); 7 8 SetDlgItemText(IDC_EDT_PATH, szPath); 9 10 CDialog::OnDropFiles(hDropInfo); 11 }
2)SDK版
1 case WM_DROPFILES: 2 { 3 char szPath[MAX_PATH] = {0}; 4 5 DragQueryFileA((HDROP)wParam, NULL, szPath, sizeof(szPath) / sizeof(*szPath)); 6 DragFinish((HDROP)wParam); 7 8 HWND hEdit = GetDlgItem(hwnd, IDC_EDT_PATH); 9 SetWindowTextA(hEdit, szPath); 10 11 break; 12 }