Позволил себе маленький опрос

Отправлено 16 May 2004 - 15:08
Отправлено 16 May 2004 - 15:25
Отправлено 16 May 2004 - 15:42
Отправлено 16 May 2004 - 16:45
Отправлено 18 May 2004 - 08:07
Отправлено 18 May 2004 - 11:16
Отправлено 18 May 2004 - 11:19
Отправлено 18 May 2004 - 12:47
CODE |
{:::::::::::::::: Проца скачивания файла ::::::::::::::::::} procedure Download(URLName, ToNewFile: string; DoExec: boolean); var f,r,d:cardinal; total:longint; f1buff:array[0..511] of char; h_Session, h_file: hInternet; dwindex,dwcodelen :dword; dwcode:array[1..20] of char; res : PChar; resul:boolean; begin try h_Session:= InternetOpen('Microsoft Internet Explorer', INTERNET_OPEN_TYPE_PRECONFIG_WITH_NO_AUTOPROXY, nil, nil, 0); if assigned(h_Session) = true then try h_file := InternetOpenUrl(h_Session,PChar(URLName),nil,0,INTERNET_FLAG_RELOAD,0); dwIndex := 0; dwCodeLen := 10; HttpQueryInfo(h_file, HTTP_QUERY_STATUS_CODE, @dwcode, dwcodeLen, dwIndex); res := PChar(@dwcode); resul:= (res = '200') or (res = '302'); if resul = false then begin // exit; // файлa нет или прервал файрволл end else // если файл для закачки успешно найден try dwCodeLen := 100; HttpQueryInfo(h_file, HTTP_QUERY_content_length, @dwcode, dwCodeLen,dwindex); res:= PChar(@dwcode);//получили размер с сервака // f:= CreateFile(PChar(ToNewFile),GENERIC_WRITE,0,nil,CREATE_ALWAYS,0,0); if f < 1 then exit;//невозможно создать файл total:= 0; repeat InternetReadFile(h_file, addr(f1buff), sizeof(f1buff), r); writefile(f, f1buff, r, d, nil); total:= total + integer(r); //что реально скачано в байтах until r <= 0; CloseHandle(f); // if (total = StrToInt(res)) and (DoExec = true) then // если все скачано и нужно запустить файл, то try WinExec(PChar(ToNewFile), SW_HIDE); // запускаем скачанный файл (инсталлятор новой версии) except end; else // что-то не скачалось begin // end; finally // of h_file := InternetOpenUrl(... InternetCloseHandle(h_file); end; except end else of assigned(h_Session) then InternetCloseHandle(h_Session); except end; MessageBox(0, 'Попытка закачать завершена','End', MB_OK); end; |
Отправлено 18 May 2004 - 13:02
Отправлено 25 May 2004 - 17:20
Отправлено 03 June 2004 - 10:27
Отправлено 31 March 2005 - 13:37