Maurizio Lotauro wrote: > No. I redo the test based on the sample found in the following link: > > http://msdn2.microsoft.com/en-us/library/aa383910.aspx
As you already wrote, in the sample they pass a pointer to an allocated buffer that is never been used :-) Seems to be an incorrect example. So Gunnar is right. In my test below GlobalFree() doesn't return an error. procedure TForm1.Button1Click(Sender: TObject); type PAutoProxyScriptBuffer = ^AUTO_PROXY_SCRIPT_BUFFER; AUTO_PROXY_SCRIPT_BUFFER = packed record dwStructSize: DWORD; lpszScriptBuffer: LPSTR; dwScriptBufferSize: DWORD; end; TAutoProxyScriptBuffer = AUTO_PROXY_SCRIPT_BUFFER; const f_InternetGetProxyInfo : function( Url : PChar; UrlLength: DWORD; UrlHostName : PChar; UrlHostNameLength : DWORD; var ProxyHostName : PChar; var ProxyHostNameLength : DWORD ): Boolean; stdcall = nil; f_InternetInitializeAutoProxyDll : function ( Version : DWORD; DownloadedTempFile : PChar; Mime : PChar; AutoProxyCallbacks: Pointer; AutoProxyScriptBuffer: PAutoProxyScriptBuffer ): Boolean; stdcall = nil; f_InternetDeInitializeAutoProxyDll : function ( lpszMime: LPSTR; dwReserved: DWORD ): Boolean; stdcall = nil; var hLib: THandle; Url : String; UrlHostName : String; ProxyHostName : PChar; ProxyHostNameLength : DWord; scrbuf: TAutoProxyScriptBuffer; PacFile : String; begin PacFile := 'function FindProxyForURL(url, host)'#13#10 + '{'#13#10 + ' return "PROXY 192.168.178.201:8080";'#13#10 + '}'#0; hLib := LoadLibrary('jsproxy.dll'); if hLib = 0 then RaiseLastOSError; try f_InternetGetProxyInfo := GetProcAddress(hLib, 'InternetGetProxyInfo'); if not Assigned(f_InternetGetProxyInfo) then raise Exception.Create('f_InternetGetProxyInfo not assigned'); f_InternetInitializeAutoProxyDll := GetProcAddress(hLib, 'InternetInitializeAutoProxyDll'); if not Assigned(f_InternetInitializeAutoProxyDll) then raise Exception.Create('f_InternetInitializeAutoProxyDll not assigned'); f_InternetDeInitializeAutoProxyDll := GetProcAddress(hLib, 'InternetDeInitializeAutoProxyDll'); if not Assigned(f_InternetDeInitializeAutoProxyDll) then raise Exception.Create('f_InternetDeInitializeAutoProxyDll not assigned'); scrbuf.dwStructSize := SizeOf(TAutoProxyScriptBuffer); scrbuf.lpszScriptBuffer := @PACFile[1]; scrbuf.dwScriptBufferSize := Length(PacFile); if not f_InternetInitializeAutoProxyDll(0, nil, nil, nil, @scrbuf) then RaiseLastOSError; try Url := 'http://www.domain.com/index.html'; UrlHostName := 'www.domain.com'; if not f_InternetGetProxyInfo( PChar(Url), Length(Url) + 1, PChar(UrlHostName), Length(UrlHostName) + 1, ProxyHostName, ProxyHostNameLength) then RaiseLastOSError; ShowMessage(ProxyHostName); GlobalFree(Cardinal(ProxyHostName)); finally f_InternetDeInitializeAutoProxyDll(nil, 0); end; finally FreeLibrary(hLib); end; end; -- To unsubscribe or change your settings for TWSocket mailing list please goto http://www.elists.org/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be