interface
type
TGetRemoteVersionThread =
class(TThread)
private
procedure UpdateMenuCaption;
protected
procedure Execute;
override;
public
Fv, Rv:
string;
//FileVersion, RemoteVersion
end;
type
TForm1 =
class(TForm)
.
.
.
implementation
function LoadURL(
URL:
String):
String;
var IOpen, IURL: HINTERNET;
Read: Cardinal; Msg:
array[0..4096]
of Char;
begin Result := '
';
IOpen := InternetOpen('
GetIP', INTERNET_OPEN_TYPE_PRECONFIG, '
', '
', INTERNET_FLAG_NEED_FILE);
if IOpen <>
nil then try
IURL := InternetOpenUrl(IOpen, PAnsiChar(
URL),
nil, 0, INTERNET_FLAG_NO_UI
or INTERNET_FLAG_PRAGMA_NOCACHE
or INTERNET_FLAG_RELOAD, 0);
if IURL <>
nil then try
repeat
FillChar(Msg, SizeOf(Msg), 0);
if InternetReadFile(IURL, @Msg[0], Pred(SizeOf(Msg)),
Read)
then Result := Result + Msg
else Break;
until Read = 0;
finally InternetCloseHandle(IURL);
end;
finally InternetCloseHandle(IOpen);
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
var Thread: TGetRemoteVersionThread;
begin
Thread := TGetRemoteVersionThread.Create(True);
Thread.FreeOnTerminate := True;
Thread.Resume;
.
.
.
end;
procedure TGetRemoteVersionThread.UpdateMenuCaption;
begin
with Form1.Menu03
do
if Rv = Fv
then Caption := '
You allready have'
else
Caption := '
Update and install';
Caption := Caption + '
the latest version V' + Rv;
end;
procedure TGetRemoteVersionThread.Execute;
begin
try
if InternetGetConnectedState(
nil, 0)
then begin
Rv := LoadURL(BaseURL + '
Launcher.ver');
Fv := GetFileVersion(ParamStr(0));
Synchronize(UpdateMenuCaption);
end;
except end;
end;