Salut tlm,

Je fais une application qui a besoin de données qui sont sur internet, ces données changent toutefois à tous les minutes environ.

j'ai donc utilise la fonction suivante pour télécharger le code source de la page puis pour l'insérer dans mon programme.

Le problème, c'est que même si les donnés sur la page internet change, les données qui sont transférées sur mon ordinateur son tjrs les même. Si toutefois je redémarre mon application, et bien les données sont à jour.

Quelqu'un aurait une idée?

MERCI

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
unit Princ;
 
interface
 
uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, Wininet, StdCtrls, DdeMan;
 
type
  TForm1 = class(TForm)
    ButtonRefresh: TButton;
    Memo1: TMemo;
    DdeServerConv1: TDdeServerConv;
    DdeServerItem1: TDdeServerItem;
    Edit1: TEdit;
    procedure ButtonRefreshClick(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure Memo1Change(Sender: TObject);
  private
    { Déclarations privées }
  public
    { Déclarations publiques }
  end;
 
var
  Form1: TForm1;
 
implementation
 
{$R *.dfm}
 
 
function GetInetFile
(const fileURL, FileName: String): boolean;
const BufferSize = 1024;
var
  hSession, hURL: HInternet;
  Buffer: array[1..BufferSize] of Byte;
  BufferLen: DWORD;
  f: 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, FileName);
   Rewrite(f,1);
   repeat
    InternetReadFile(hURL, @Buffer,
                     SizeOf(Buffer), BufferLen);
    BlockWrite(f, Buffer, BufferLen)
   until BufferLen = 0;
   CloseFile(f);
   Result:=True;
  finally
   InternetCloseHandle(hURL)
  end
 finally
  InternetCloseHandle(hSession)
 end
end;
 
 
procedure TForm1.ButtonRefreshClick(Sender: TObject);
var FileOnNet, LocalFileName: string;
F2 : File;
SomeTxtFile : TextFile;
buffer : string;
 
begin
 
If FileExists('C:\Documents and Settings\Benoit Landry\Bureau\AirTracking'
 +'\Datas\Flight_ASH7166.txt') then begin
AssignFile(F2,'C:\Documents and Settings\Benoit Landry\Bureau\AirTracking'
 +'\Datas\Flight_ASH7166.txt');
Erase(F2);
end;
 
 FileOnNet:=
  'http://flightaware.com/live/flight/ASH7166/'+
  'history/20070113/0330Z/KAVP/KORD/tracklog';
 LocalFileName:='C:\Documents and Settings\Benoit Landry\Bureau\AirTracking'
 +'\Datas\Flight_ASH7166.txt';
 
 if GetInetFile(FileOnNet,LocalFileName)=True then
  ShowMessage('Download successful')
 else
  ShowMessage('Error in file download');
 
  AssignFile(SomeTxtFile, 'C:\Documents and Settings\Benoit Landry\Bureau'
  +'\AirTracking\Datas\Flight_ASH7166.txt') ;
  Reset(SomeTxtFile) ;
  while not EOF(SomeTxtFile) do
  begin
   ReadLn(SomeTxtFile, buffer) ;
   Memo1.Lines.add(buffer) ;
  end;
  CloseFile(SomeTxtFile) ;
end;
 
 
end.