WinHttpGetIEProxyConfigForCurrentUser的文档说:
调用方必须释放lpszProxy,lpszProxyBypass和 WINHTTP_CURRENT_USER_IE_Proxy_CONFIG中的lpszAutoConfigUrl字符串 如果它们为非NULL,则为结构。使用 GlobalFree 释放字符串。
我编写了以下代码(Delphi 10.3.2):
var
VConfig: TWinHttpCurrentUserIEProxyConfig;
begin
FillChar(VConfig,SizeOf(VConfig),0);
if not WinHttpGetIEProxyConfigForCurrentUser(VConfig) then begin
RaiseLastOSError;
end;
...
if VConfig.lpszAutoConfigUrl <> nil then begin
GlobalFree(VConfig.lpszAutoConfigUrl); // <-- Error
end;
并出现错误:
[dcc32错误] E2010不兼容的类型:“ NativeUInt”和“ PWideChar”
问题:
-
我应该将
PWideChar
投射到NativeUInt
吗? -
我可以使用
GlobafFreePtr
代替GlobafFree
(它接受PWideChar
并在我的测试中工作正常)吗?