DELPHI肯定能實現這些功能,不是太難
解决方案 »
- dephi2007,买了套正版,请问可否一套正版软件,可以安装多台机器。排除法律问题。
- 请教关于DLL的两个问题:能否建立一个有Form的DLL,代码直接显示
- 关于Delphi的帮助
- 取出每一种model的code最小的记录的sql语句?
- 最近匹配查问题?????????!!!!!!!
- 我靠,“芙蓉姐姐”是我高中三年的同学,没想到现在红的发紫了
- RAW SOCKET能否发送ARP请求?可以收发数据链路层的PACKET?
- 寻找图文混排控件请帮忙(在Delphi里用)
- Xp下 Webbrowser 静音
- 请教有关多层分布的问题
- 关于DELPHI的问题,我很急,请各位大虾帮帮我!谢谢!!!
- 招聘:单片机程序员(兼职)
email地址:[email protected]
其实没有必要报警的,你在数据显示中用不同的颜色(比如:红色)显示出来就是了。
MY EMAIL:[email protected]
请问你是哪里人,不知道我们没有机会合作呢!!
在 Application.OnIdle中或者用个定时器判断是否要报警
如果要用户不运行程序也能报警,那就要写成服务或者通过计划任务(at命令)调用。
2、关于自动升级,如果程序写成ActiveX通过web发布的话,浏览器能根据版本号自动下载升级。
unit update_f;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, TFlatGroupBoxUnit, TFlatButtonUnit, StdCtrls,
TFlatSpeedButtonUnit, TFlatEditUnit, TFlatMemoUnit, Psock, NMHttp,ShellAPI;type
TSimpleVersion=record
dwProductVersionMS: DWORD;
dwProductVersionLS: DWORD;
end;
TUpdate=record { Structure of update information }
Name:String[63];
Version:TSimpleVersion;
Date:TDate;
URL1:ShortString;
URL2:ShortString;
Update_Info:String;
end;
Tupdate_v = class(TForm)
FlatGroupBox2: TFlatGroupBox;
FlatGroupBox3: TFlatGroupBox;
FlatButton1: TFlatButton;
FlatButton2: TFlatButton;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
FlatMemo2: TFlatMemo;
FlatEdit1: TFlatEdit;
FlatSpeedButton1: TFlatSpeedButton;
NMHTTP1: TNMHTTP;
Label6: TLabel;
Label7: TLabel;
FlatMemo1: TFlatMemo;
Label8: TLabel;
Label9: TLabel;
Label10: TLabel;
FlatSpeedButton2: TFlatSpeedButton;
FlatEdit2: TFlatEdit;
procedure FlatButton2Click(Sender: TObject);
procedure NMHTTP1Connect(Sender: TObject);
procedure NMHTTP1ConnectionFailed(Sender: TObject);
procedure NMHTTP1Disconnect(Sender: TObject);
procedure NMHTTP1HostResolved(Sender: TComponent);
procedure NMHTTP1Status(Sender: TComponent; Status: String);
procedure FlatButton1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FlatSpeedButton1Click(Sender: TObject);
procedure FlatSpeedButton2Click(Sender: TObject);
private
{ Private declarations }
Update_New, Update_Ori: TUpdate;
function AnalyseUpdate(Body: String; var Update: TUpdate): Boolean;
procedure DisplaySuggestion(b: Boolean);
public
{ Public declarations }
end;var
update_v: Tupdate_v;implementation
const update_text='http://127.0.0.1/update.txt';
{$R *.dfm}//取得当前使用版本的信息
function GetBuildInfo(FName:string):TSimpleVersion;
var
VerInfoSize: DWORD;
VerInfo: Pointer;
VerValueSize: DWORD;
VerValue: PVSFixedFileInfo;
Dummy: DWORD;
begin
VerInfoSize := GetFileVersionInfoSize(PChar(FName), Dummy);
GetMem(VerInfo, VerInfoSize);
GetFileVersionInfo(PChar(ParamStr(0)), 0, VerInfoSize, VerInfo);
VerQueryValue(VerInfo, '\', Pointer(VerValue), VerValueSize);
with VerValue^ do
begin
Result.dwProductVersionMS := dwFileVersionMS;
Result.dwProductVersionLS := dwFileVersionLS;
end;
FreeMem(VerInfo, VerInfoSize);
end;function SeparateVerStr(s:String):TSimpleVersion;
const
Separator = '.';
var
p:WORD;
v1,v2,v3,v4:WORD;
begin
if Length(s)=0 then Exit; p:=pos(Separator, s);
v1:=StrToInt(copy(s,1,p-1));
Delete(s,1,p);
p:=Pos(Separator,s);
v2:=StrToInt(copy(s,1,p-1));
Delete(s,1,p);
p:=Pos(Separator,s);
v3:=StrToInt(copy(s,1,p-1));
Delete(s,1,p);
v4:=StrToInt(s);
Result.dwProductVersionMS:=v1*$10000+v2;
Result.dwProductVersionLS:=v3*$10000+v4;
end;function Tupdate_v.AnalyseUpdate(Body:String;var Update:TUpdate):Boolean;
var
TmpStr,Ver:String;
function CenterStr(Src:String;Before,After:String):String;
var
Pos1,Pos2:WORD;
begin
Pos1:=Pos(Before,Src)+Length(Before);
Pos2:=Pos(After,Src);
Result:=Copy(Src,Pos1,Pos2-Pos1);
end;
begin
TmpStr:=CenterStr(Body,Format('[%s]',[LowerCase(Update_Ori.Name)]),Format('[/%s]',[LowerCase(Update_Ori.Name)]));
if TmpStr='' then Result:=False
else
begin
Ver:=CenterStr(TmpStr,'<ver>','</ver>');
Update.Version:=SeparateVerStr(Ver);
Update.Date:=StrToDate(CenterStr(TmpStr,'<date>','</date>'));
Update.URL1:=CenterStr(TmpStr,'<url1>','</url1>');
Update.URL2:=CenterStr(TmpStr,'<url2>','</url2>');
Update.Update_Info:=CenterStr(TmpStr,'<info>','</info>');
Result:=True;
FlatMemo1.Lines.Add('最新版本:'+Ver);
FlatMemo1.Lines.Add('发布日期:'+DateToStr(Update.Date));
FlatMemo1.Lines.Add('下载地址1:'+Update.URL1);
FlatMemo1.Lines.Add('下载地址2:'+Update.URL2);
end;
end;{ Compare tow versions whether need update, True stand for need }
function VersionCheck(OriVer,NewVer:TSimpleVersion):Boolean;
begin
if (OriVer.dwProductVersionMS=NewVer.dwProductVersionMS) then
Result:=OriVer.dwProductVersionLS<NewVer.dwProductVersionLS
else Result:=OriVer.dwProductVersionMS<NewVer.dwProductVersionMS;
end;procedure Tupdate_v.DisplaySuggestion(b:Boolean);
begin
FlatMemo1.Lines.Add('');
FlatMemo1.Lines.Add('青苔提示:');
if b then
begin
if VersionCheck(Update_Ori.Version,Update_New.Version) then
FlatMemo1.Lines.Add('找到一个更新的版本')
else
FlatMemo1.Lines.Add('对不起,青苔还未发布更新版本');
end else
begin
FlatMemo1.Lines.Add('查找版本更新情况失败,');
FlatMemo1.Lines.Add('请检查该版本是否正常,');
FlatMemo1.Lines.Add('或系统是否连上了Internet。');
end;
end;procedure Tupdate_v.FlatButton2Click(Sender: TObject);
begin
Close;
end;procedure Tupdate_v.NMHTTP1Connect(Sender: TObject);
begin
FlatMemo1.Lines.Add('已连接……');
end;procedure Tupdate_v.NMHTTP1ConnectionFailed(Sender: TObject);
begin
FlatMemo1.Lines.Add('连接失败!');
end;procedure Tupdate_v.NMHTTP1Disconnect(Sender: TObject);
begin
FlatMemo1.Lines.Add('断线中……');
end;procedure Tupdate_v.NMHTTP1HostResolved(Sender: TComponent);
begin
FlatMemo1.Lines.Add('正在解析地址……');
end;procedure Tupdate_v.NMHTTP1Status(Sender: TComponent; Status: String);
begin
FlatMemo1.Lines.Add(Status);
If NMHTTP1.ReplyNumber = 404 then
FlatMemo1.Lines.Add('更新文档没找到……');
end;procedure Tupdate_v.FlatButton1Click(Sender: TObject);
begin
FlatMemo1.Clear;
FlatMemo1.Lines.Add('系统消息:');
FlatMemo1.Lines.Add('开始查看更新信息……');
NMHTTP1.InputFileMode := FALSE;
NMHTTP1.OutputFileMode := FALSE;
NMHTTP1.ReportLevel := Status_Basic;
try
NMHTTP1.Get(update_text);
FlatMemo1.Lines.Add('');
FlatMemo1.Lines.Add('开始分析……');
if AnalyseUpdate(NMHTTP1.Body,Update_New) then
begin
Label6.Caption:=Format('%d.%d.%d.%d',[
Update_New.Version.dwProductVersionMS shr 16,
Update_New.Version.dwProductVersionMS and $FFFF,
Update_New.Version.dwProductVersionLS shr 16,
Update_New.Version.dwProductVersionLS and $FFFF
]);
FlatEdit1.Text:=Update_New.URL1;
FlatEdit2.Text:=Update_New.URL2;
Label7.Caption:=DateToStr(Update_New.Date);
FlatMemo2.Lines.Add(Update_New.Update_Info);
FlatMemo1.Lines.Add('已经分析成功!');
DisplaySuggestion(True);
end else
begin
FlatMemo1.Lines.Add('不能找到更新信息!');
FlatMemo1.Lines.Add('分析失败!');
DisplaySuggestion(False);
end;
except
DisplaySuggestion(False);
Application.MessageBox('程序更新失败!','提示',MB_OK);
end;
end;procedure Tupdate_v.FormCreate(Sender: TObject);
begin
Update_Ori.Name:='mosstools';
Update_Ori.Version:=GetBuildInfo(ParamStr(0));
Label8.Caption:=Format('%d.%d.%d.%d',[
Update_Ori.Version.dwProductVersionMS shr 16,
Update_Ori.Version.dwProductVersionMS and $FFFF,
Update_Ori.Version.dwProductVersionLS shr 16,
Update_Ori.Version.dwProductVersionLS and $FFFF
]);
end;procedure Tupdate_v.FlatSpeedButton1Click(Sender: TObject);
begin
if FlatEdit1.Text<>'' then
ShellExecute(Handle,nil,PChar(FlatEdit1.Text),nil,nil,SW_SHOWNORMAL);
end;procedure Tupdate_v.FlatSpeedButton2Click(Sender: TObject);
begin
if FlatEdit2.Text<>'' then
ShellExecute(Handle,nil,PChar(FlatEdit2.Text),nil,nil,SW_SHOWNORMAL);
end;end.
×××××××××
; update.txt File Format
; First Application Update Information
[MossTools]
<ver>2.0.0.389</ver>
<url1>http://delphibox.com/softm/3_update.zip</url1>
<url2>http://delphibox.com/softm/3_update.zip</url2>
<date>2002-4-26</date>
<info>最新消息:天时地利!</info>
[/MossTools]; Another Application Update Information
[MossCi]
<ver>2.11.0.0</ver>
<url>http://delphibox.com/softm/3_exelock.zip</url>
<date>2002-2-25</date>
[/MossCi][pedump]
<ver>1.91.0.0</ver>
<url>http://delphibox.com/softm/3_pedump.zip</url>
<date>2002-2-25</date>
[/pedump]