Главная страница
Top.Mail.Ru    Яндекс.Метрика
Текущий архив: 2006.04.23;
Скачать: CL | DM;

Вниз

Nebolshoi vopros   Найти похожие ветки 

 
yura32 ©   (2006-04-07 02:47) [0]

mne nado zagruzit file tipa TXT v memo .
vrode dostata4no zdelat load from file .
a kak mojno zagruzit file esli on na HTTP servere
i pri etom sohranit poryadok strok.


 
TMemo   (2006-04-09 03:30) [1]

Вот так:

unit Unit1;

interface

uses
 Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
 StdCtrls;

type
 TForm1 = class(TForm)
   Memo1: TMemo;
   Button1: TButton;
   procedure Button1Click(Sender: TObject);
 private
   { Private declarations }
 public
   { Public declarations }
 end;

var  Form1: TForm1;

implementation {$R *.DFM}

uses Wininet;

function GetInetFile(const fileURL, FileName: String): boolean;
const BufferSize = 1024;
var
 hSession, hURL: HInternet;
 Buffer: array[1..BufferSize] of Byte;
 BufferLen: DWORD;
 chType    : array[1..20] of Char;
 cLength   : DWord;
 cIndex    : DWord;
 f_loc:file;
 sAppName: string;
begin
Result:=False;
sAppName := ExtractFileName(Application.ExeName);
hSession := InternetOpen(PChar(sAppName),INTERNET_OPEN_TYPE_PRECONFIG,nil, nil, 0);
try
 hURL := InternetOpenURL(hSession,PChar(fileURL),nil,0,0,0);
 try
  AssignFile(f_loc, FileName);
  Rewrite(f_loc,1);
  repeat
   InternetReadFile(hURL, @Buffer,SizeOf(Buffer), BufferLen);BlockWrite(f_loc, Buffer, BufferLen);
   cLength := 250;
   cIndex := 0;
   HTTPQueryInfo(hURL,HTTP_QUERY_CONTENT_LENGTH,@chType,cLength,cIndex);
    Application.ProcessMessages();
  until BufferLen = 0;
  CloseFile(f_loc);
  Result:=True;
 finally
  InternetCloseHandle(hURL)
 end
finally
 InternetCloseHandle(hSession)
end
end;

procedure TForm1.Button1Click(Sender: TObject);
var FileOnNet, LocalFileName: string;
begin
FileOnNet:="http://127.0.0.1/index.htm";
LocalFileName:=ExtractFilePath(Application.ExeName)+"temp.txt";
if GetInetFile(FileOnNet,LocalFileName)=True then
 Memo1.Lines.LoadFromFile(LocalFileName);
end;

end.

(Только у браузера нужно отключить автономный режим, если он включён)



Страницы: 1 вся ветка

Текущий архив: 2006.04.23;
Скачать: CL | DM;

Наверх




Память: 0.47 MB
Время: 0.035 c
15-1143910426
ArtemESC
2006-04-01 20:53
2006.04.23
Установка видеорежима..


6-1136712267
n0p
2006-01-08 12:24
2006.04.23
Отключение Nagle в Indy 10


6-1136898146
Wiz@rd
2006-01-10 16:02
2006.04.23
шЫрина канала...


2-1144670546
std
2006-04-10 16:02
2006.04.23
AdoDataSet


1-1142835437
Гость101
2006-03-20 09:17
2006.04.23
Изменить шрифт