enumDeviceDrivers 函式 (psapi.h)

擷取系統中每個設備驅動器的載入位址。

語法

BOOL EnumDeviceDrivers(
  [out] LPVOID  *lpImageBase,
  [in]  DWORD   cb,
  [out] LPDWORD lpcbNeeded
);

參數

[out] lpImageBase

陣列,接收設備驅動器的載入位址清單。

[in] cb

lpImageBase 陣列的大小,以位元組為單位。 如果陣列不夠大,無法儲存載入位址, l其needed 參數會收到陣列的必要大小。

[out] lpcbNeeded

在 lpImageBase 陣列中傳回的位元組數目。

傳回值

如果函式成功,則傳回非零的值。

如果此函式失敗,則傳回值為零。 若要取得擴充的錯誤資訊,請呼叫 GetLastError

備註

若要判斷 呼叫 EnumDeviceDrivers 所列舉多少設備驅動器,請將 landroidNeeded 參數中產生的值除以 sizeof(LPVOID)

從 Windows 7 和 Windows Server 2008 R2 開始,Psapi.h 會建立 PSAPI 函式的版本號碼。 PSAPI 版本號碼會影響用來呼叫函式的名稱,以及程式必須載入的連結庫。

如果PSAPI_VERSION為 2 或更新版本,此函式會定義為 Psapi.h 中的 K32EnumDeviceDrivers ,並在 Kernel32.lib 和 Kernel32.dll 中導出。 如果PSAPI_VERSION為 1,此函式會定義為 Psapi.h 中的 EnumDeviceDrivers ,並在 Psapi.lib 中匯出,並 Psapi.dll 為呼叫 K32EnumDeviceDrivers 的包裝函式。

必須在舊版 Windows 和 Windows 7 和更新版本上執行的程式應該一律將此函式呼叫為 EnumDeviceDrivers。 若要確保符號的正確解析度,請將 Psapi.lib 新增至 TARGETLIBS 宏,並使用 –DPSAPI_VERSION=1 編譯程式。 若要使用運行時間動態連結,請載入 Psapi.dll。

從 Windows 11 版本 24H2 開始,EnumDeviceDrivers 會要求 SeDebugPrivilege 傳回有效的 ImageBase 值。 如果呼叫端未啟用此許可權,但傳回的 lpImageBase 陣列將包含所有 NULL 的位址,函式仍會成功。

範例

如需範例,請參閱 列舉系統中的所有設備驅動器

規格需求

   
最低支援的用戶端 Windows XP [僅限傳統型應用程式]
最低支援的伺服器 Windows Server 2003 [僅限桌面應用程式]
目標平台 Windows
標頭 psapi.h
程式庫 Windows 7 和 Windows Server 2008 R2 上的 Kernel32.lib;如果 Windows 7 和 Windows Server 2008 R2 上的 PSAPI_VERSION=1) ,Psapi.lib (;Windows Server 2008、Windows Vista、Windows Server 2003 和 Windows XP 上的 Psapi.lib
Dll Windows 7 和 Windows Server 2008 R2 上的 Kernel32.dll;如果 windows 7 和 Windows Server 2008 R2 上的 PSAPI_VERSION=1) ,則為 Psapi.dll (;Windows Server 2008、Windows Vista、Windows Server 2003 和 Windows XP 上的 Psapi.dll

另請參閱

設備驅動器資訊

GetDeviceDriverBaseName

GetDeviceDriverFileName

PSAPI 函式