LoadLibrary失敗,GetLastError 返回127錯誤

該原因一般是由於DLL或其依賴的DLL使用了高版本的API,而在低系統中運行時,找不到該函數所引發的錯誤。

比如:該函數:InterlockedExchange64,

看MSDN:

Client Requires Windows Vista.
Server Requires Windows Server 2008 or Windows Server 2003.
Header

Declared in Winbase.h; include Windows.h.

它最少需要 VISTA的支持。如果DLL或其依賴的DLL使用了該API,當在低於VISTA版本的系統上運行時,如XP,2000等,使用LoadLibrary就會失敗,GetLastError就會返回127的錯誤碼。

使用Dependents 進行查看時,如果是在低版本下查找,應該會看到顯示紅色的標註。

當然,在XP與WIN7兩個系統下測試該函數運行情況更佳,直接就能看出來至少是不是API支不支持。

原文地址:https://www.cnblogs.com/lin1270/p/3637066.html