Вид окна модуля
рабочий пример установки параметров ProxyServer-а
function SetSystemProxy(host: string; port: string): boolean;
const
INTERNET_PER_CONN_FLAGS = 1;
PROXY_TYPE_PROXY = $00000002;
INTERNET_PER_CONN_PROXY_BYPASS = 3;
INTERNET_PER_CONN_PROXY_SERVER = 2;
INTERNET_OPTION_PER_CONNECTION_OPTION = 75;
PROXY_TYPE_DIRECT = $00000001;
type
INTERNET_PER_CONN_OPTION = record
dwOption: DWORD;
Value: record
case Integer of
1: (dwValue: DWORD);
2: (pszValue: PChar); {Unicode/ANSI}
3: (ftValue: TFileTime);
end;
end;
LPINTERNET_PER_CONN_OPTION = ^INTERNET_PER_CONN_OPTION;
INTERNET_PER_CONN_OPTION_List = record
dwSize: DWORD;
pszConnection: LPTSTR;
dwOptionCount: DWORD;
dwOptionError: DWORD;
intOptions: LPINTERNET_PER_CONN_OPTION;
end;
LPINTERNET_PER_CONN_OPTION_List = ^INTERNET_PER_CONN_OPTION_List;
var list: INTERNET_PER_CONN_OPTION_LIST;
dwBufSize: DWORD;
hInternet: Pointer;
Options: array[1..3] of INTERNET_PER_CONN_OPTION;
begin
Result := False;
dwBufSize := SizeOf(list);
list.dwSize := SizeOf(list);
list.pszConnection := nil;
list.dwOptionCount := High(Options);
Options[1].dwOption := INTERNET_PER_CONN_FLAGS;
Options[2].dwOption := INTERNET_PER_CONN_PROXY_SERVER;
if (host='') or (port='') then
begin
Options[1].Value.dwValue := PROXY_TYPE_DIRECT;
Options[2].Value.pszValue := PChar('');
end else
begin
Options[1].Value.dwValue := PROXY_TYPE_PROXY;
Options[2].Value.pszValue := PChar(host+':'+port);
end;
Options[3].dwOption := INTERNET_PER_CONN_PROXY_BYPASS;
Options[3].Value.pszValue := PChar('');
list.intOptions := @Options;
hInternet := InternetOpen(PChar(''), INTERNET_OPEN_TYPE_DIRECT, nil, nil, 0);
if hInternet <> nil then
try
Result := InternetSetOption(nil, INTERNET_OPTION_PER_CONNECTION_OPTION, @list, dwBufSize);
Result := Result and InternetSetOption(nil, INTERNET_OPTION_REFRESH, nil, 0);
finally
InternetCloseHandle(hInternet)
end;
end;
// пример работы
procedure TProxyForm.Button1Click(Sender: TObject);
var b:boolean;
begin
if self.CheckBox1.Checked then
b := SetSystemProxy(self.Edit1.Text,self.Edit2.text) // устанавливаем настройки прокси
else b := SetSystemProxy('',''); // прокси выключен
if b then begin
Showmessage('Новый прокси установлен ');
tag:=5;
close;
end;
end;
по материалам сайта
http://www.webdelphi.ru/2010/04/samyj-prostoj-sposob-uznat-skorost-zagruzki-fajla-iz-seti-synapse-v-delphi/