格式化 ShellExecute 返回的错误值

DWORD ExcuteCmd(HWND hParent, LPCTSTR szOperate, LPCTSTR lpszPathFolderFile, LPCTSTR lpszParam=NULL, LPCTSTR lpszDir=NULL, int nCmd=SW_SHOWNORMAL) { DWORD hRet = (DWORD)ShellExecute(hParent, szOperate, lpszPathFolderFile, lpszParam, lpszDir, nCmd); if(hRet > 32) { } else { CString szMsg = _T(""); #define CASE_ERR(x, y) case((x)): szMsg = _T(y); break; switch(hRet) { CASE_ERR( 0, "The operating system is out of memory or resources.") CASE_ERR( ERROR_BAD_FORMAT, "The .exe file is invalid (non-Win32? .exe or error in .exe image).") CASE_ERR( SE_ERR_ACCESSDENIED, "The operating system denied access to the specified file.") CASE_ERR( SE_ERR_ASSOCINCOMPLETE, "The file name association is incomplete or invalid.") CASE_ERR( SE_ERR_DDEBUSY, "The DDE transaction could not be completed because other DDE transactions were being processed.") CASE_ERR( SE_ERR_DDEFAIL, "The DDE transaction failed.") CASE_ERR( SE_ERR_DDETIMEOUT, "The DDE transaction could not be completed because the request timed out.") CASE_ERR( SE_ERR_DLLNOTFOUND, "The specified dynamic-link library was not found.") CASE_ERR( SE_ERR_FNF, "The specified file was not found.") CASE_ERR( SE_ERR_NOASSOC, "There is no application associated with the given file name extension.") CASE_ERR( SE_ERR_OOM, "There was not enough memory to complete the operation.") CASE_ERR( SE_ERR_PNF, "The specified path was not found.") CASE_ERR( SE_ERR_SHARE, "A sharing violation occurred.") default: szMsg.Format( _T("Unknow error %ld"), hRet ); } AfxMessageBox(szMsg); } return hRet; }

你可能感兴趣的:(File,null,application,System,library,transactions)