萬盛學電腦網

您现在的位置: 萬盛學電腦網 >> 電腦基礎知識 >  >> 電腦基本常識

Windows 系統錯誤代碼對照表 (0-50) 完整版:十六進位/十進位/錯誤訊息/中文說明

Windows System Error Codes (0-50) 完整對照

以下為 Windows 系統 API (GetLastError、FormatMessage、HRESULT 低 16 位) 常見錯誤代碼對照,適用於程式開發除錯、系統日誌分析、腳本錯誤處理、驅動開發等場景。
來源:Microsoft Docs System Error Codes,持續更新中。

十進位十六進位符號常數 (WinError.h)英文描述中文說明
00x00000000ERROR_SUCCESSThe operation completed successfully.作業成功完成。
10x00000001ERROR_INVALID_FUNCTIONIncorrect function.不正確的函數。
20x00000002ERROR_FILE_NOT_FOUNDThe system cannot find the file specified.系統找不到指定的檔案。
30x00000003ERROR_PATH_NOT_FOUNDThe system cannot find the path specified.系統找不到指定的路徑。
40x00000004ERROR_TOO_MANY_OPEN_FILESThe system cannot open the file.系統無法開啟檔案 (開啟檔案過多)。
50x00000005ERROR_ACCESS_DENIEDAccess is denied.拒絕存取 (權限不足)。
60x00000006ERROR_INVALID_HANDLEThe handle is invalid.無效的控制代碼/句柄。
70x00000007ERROR_ARENA_TRASHEDThe storage control blocks were destroyed.儲存體控制區塊已損毀 (堆積區損壞)。
80x00000008ERROR_NOT_ENOUGH_MEMORYNot enough storage is available to process this command.儲存體空間不足,無法處理此指令 (記憶體不足)。
90x00000009ERROR_INVALID_BLOCKThe storage control block address is invalid.儲存體控制區塊位址無效。
100x0000000AERROR_BAD_ENVIRONMENTThe environment is incorrect.環境不正確 (環境變數區塊損壞)。
110x0000000BERROR_BAD_FORMATAn attempt was made to load a program with an incorrect format.嘗試載入格式錯誤的程式 (如 32位載入 64位、PE 損壞)。
120x0000000CERROR_INVALID_ACCESSThe access code is invalid.存取碼錯誤。
130x0000000DERROR_INVALID_DATAThe data is invalid.資料錯誤 (CRC/校驗失敗)。
140x0000000EERROR_OUTOFMEMORYNot enough storage is available to complete this operation.儲存體空間不夠,無法完成此作業 (虛擬記憶體耗盡)。
150x0000000FERROR_INVALID_DRIVEThe system cannot find the drive specified.系統找不到指定的磁碟機。
160x00000010ERROR_CURRENT_DIRECTORYThe directory cannot be removed.無法移除目錄 (當前目錄無法刪除)。
170x00000011ERROR_NOT_SAME_DEVICEThe system cannot move the file to a different disk drive.系統無法將檔案移至不同的磁碟機 (跨磁碟移動需複製後刪除)。
180x00000012ERROR_NO_MORE_FILESThere are no more files.沒有更多檔案 (列舉結束)。
190x00000013ERROR_WRITE_PROTECTThe media is write protected.媒體為寫保護狀態 (SD 卡鎖、USB 寫保護、光碟)。
200x00000014ERROR_BAD_UNITThe system cannot find the device specified.系統找不到指定的裝置。
210x00000015ERROR_NOT_READYThe device is not ready.裝置尚未就緒 (光碟機無碟、USB 未就緒)。
220x00000016ERROR_BAD_COMMANDThe device does not recognize the command.裝置無法識別指令 (IOCTL/裝置驅動錯誤)。
230x00000017ERROR_CRCData error (cyclic redundancy check).資料錯誤 (循環冗餘檢查 CRC 失敗),資料損毀/傳輸錯誤/壞軌。
240x00000018ERROR_BAD_LENGTHThe program issued a command but the command length was incorrect.程式發出指令但指令長度錯誤。
250x00000019ERROR_SEEKThe drive cannot locate a specific area or track on the disk.磁碟機在磁碟上找不到指定的扇區或磁道 (尋找失敗)。
260x0000001AERROR_NOT_DOS_DISKThe specified disk or diskette cannot be accessed.指定的磁碟或磁片無法存取 (非 DOS 格式/檔案系統損毀)。
270x0000001BERROR_SECTOR_NOT_FOUNDThe drive cannot find the sector requested.磁碟機找不到要求的扇區 (硬碟壞軌/定位錯誤)。
280x0000001CERROR_OUT_OF_PAPERThe printer is out of paper.印表機沒有紙。
290x0000001DERROR_WRITE_FAULTThe system cannot write to the specified device.系統無法將資料寫入指定的裝置 (寫入失敗/壞軌/權限/離線)。
300x0000001EERROR_READ_FAULTThe system cannot read from the specified device.系統無法從指定裝置讀取資料 (讀取失敗/壞軌/權限/離線)。
310x0000001FERROR_GEN_FAILUREA device attached to the system is not functioning.連接到系統的某個裝置無法運作 (通用裝置故障)。
320x00000020ERROR_SHARING_VIOLATIONThe process cannot access the file because it is being used by another process.檔案被另一進程使用中無法存取 (共用違規/檔案鎖定)。
330x00000021ERROR_LOCK_VIOLATIONA part of the file is locked.檔案的一部份被鎖定 (區域鎖定衝突)。
340x00000022ERROR_WRONG_DISKThe wrong diskette is in the drive.磁碟機中的磁片不正確 (換錯磁片/磁碟機標籤錯誤)。
360x00000024ERROR_SHARING_BUFFER_EXCEEDEDToo many files opened for sharing.開啟的共用檔案數量過多 (超過 SMB/伺服器限制)。
380x00000026ERROR_HANDLE_EOFReached the end of the file.到達檔案結尾 (EOF)。
390x00000027ERROR_DISK_FULLThe disk is full.磁碟已滿 (磁碟空間不足)。
500x00000032ERROR_NOT_SUPPORTEDThe request is not supported.不支援此網路要求/功能 (網路重導向器/檔案系統不支援操作)。

延伸:常見錯誤代碼範圍分類

  • 0-499:系統核心錯誤 (WinError.h 定義)。
  • 1000-1299:RPC (遠端程序呼叫) 錯誤。
  • 1300-1999:安全性/存取控制/Token/登入/權限錯誤。
  • 2000-2999:網路/重導向器/瀏覽服務錯誤。
  • 3000-3999:列印/列印佇列錯誤。
  • 4000-4999:服務控制管理員 (SCM) 錯誤。
  • 5000-5999:遠端桌面/終端機服務錯誤。
  • 6000-6999:Windows Update/安裝服務錯誤。
  • 7000-7999:Windows Installer (MSI) 錯誤。
  • 8000-8999:WinHTTP/WinINet/網路 API 錯誤。
  • 9000-9999:備份/還原/VSS 錯誤。
  • 10000-10999:群組原則/註冊表擴充錯誤。
  • 12000-12999:WinINet/Internet Explorer 錯誤 (INET_E_*)。
  • 13000-13999:側邊執行/並行組件/Manifest 錯誤。
  • 14000-14999:交易式檔案系統 (TxF) 錯誤。
  • 15000-15999:用戶體驗虛擬化 (UE-V) 錯誤。

查詢工具與指令

  • 命令列:net helpmsg <錯誤碼> (如 net helpmsg 5 →「拒絕存取」)。
  • PowerShell:[System.ComponentModel.Win32Exception]<錯誤碼>.Message。
  • Visual Studio / Windows SDK:Error Lookup 工具 (Tools > Error Lookup) 或 err.exe (舊版 SDK)。
  • 線上查詢:Microsoft Learn - System Error Codes、WinError.h 完整定義。
  • 事件檢視器:事件屬性 >「詳細資料」>「EventData」中的 ErrorCode / Status 多為此代碼或 HRESULT (0x8007xxxx = Win32 錯誤碼 + 0x80070000)。

開發者常用錯誤處理模式

// C/C++
DWORD err = GetLastError();
if (err != ERROR_SUCCESS) {
    LPWSTR msg = nullptr;
    FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
                   NULL, err, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPWSTR)&msg, 0, NULL);
    // 使用 msg...
    LocalFree(msg);
}

// C# / .NET
try { ... }
catch (System.ComponentModel.Win32Exception ex) {
    Console.WriteLine($"Error {ex.NativeErrorCode}: {ex.Message}");
}
// 或 P/Invoke GetLastError()

// PowerShell
$err = [System.ComponentModel.Win32Exception]::new(5)
$err.Message  # "Access is denied"
copyright © 萬盛學電腦網 all rights reserved