我在安装过程中使用此代码加载文件,WinHttpRequest.5.1 是适用于 Windows 11 的良好 API 还是此 API 对 Internet Explorer 有一些依赖项?
function DownloadFile(const AURL: string; var AResponse: string): Boolean;
var
WinHttpRequest: Variant;
begin
Result := True;
try
WinHttpRequest := CreateOleObject('WinHttp.WinHttpRequest.5.1');
WinHttpRequest.Open('GET', AURL, False);
WinHttpRequest.Send;
AResponse := WinHttpRequest.ResponseText;
except
Result := False;
AResponse := GetExceptionMessage;
end;
end;
最佳答案
摘自文档https://learn.microsoft.com/en-us/windows/win32/winhttp/winhttp-versions :
WinHTTP Versions
01/07/2021
Users of Microsoft Windows HTTP Services (WinHTTP) should use the latest version of the technology, version 5.1. Version 5.0 is no longer supported.
Version 5.1
WinHTTP 5.1 offers improvements over version 5.0; for more information about new features, see What's New in WinHTTP 5.1.
With version 5.1, WinHTTP is an operating-system component of the following operating systems:
- Windows 2000, Service Pack 3 and later (except Datacenter Server)
- Windows XP with Service Pack 1 (SP1) and later Windows Server 2003 with Service Pack 1 (SP1) and later
...
鉴于它说“Windows 2000...及更高版本”,显然这是一个可以在 Win11 中可靠使用的组件。而且和IE无关。 (*)
(*) 听起来像是根据this page IE 曾经可能是较旧的 5.0 版本的依赖项:“可再发行:Windows XP 和 Windows 2000 上的 WinHTTP 5.0 和 Internet Explorer 5.01 或更高版本。”
关于windows - WinHttpRequest.5.1 是适用于 Windows 11 的良好 API 还是需要 Iexplorer?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70016852/