求一自动升级程序的源码,升级exe程序和指定文件下的文件 求一自动升级程序的源码,升级exe程序和指定文件下的文件 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 盒子上有一个现成的源码下载地址:http://www.2ccc.com/article.asp?articleid=5111 我看到了,是d2007的呀,我是delphi7的呀 Procedure FileCopy( Const sourcefilename, targetfilename: String );Var S, T: TFileStream;Begin S := TFileStream.Create( sourcefilename, fmOpenRead ); try T := TFileStream.Create( targetfilename, fmOpenWrite or fmCreate ); try T.CopyFrom(S, S.Size ) ; finally T.Free; end; finally S.Free; end;End;procedure TUpDateForm.UpdateLoad;var ado:TADOquery; myinifile:TInifile; filename:string; sfile,s,upd:string; i,j:integer; T:TextFile;begin Filename:=ExtractFilePath(Paramstr(0))+'mini.ini'; myinifile:=Tinifile.Create(filename); upd:=myinifile.ReadString('update','updatenumber',''); ado:=TAdoquery.Create(nil); ado.Connection:=Linkdata(Application.Handle); ado.close; ado.SQL.Clear; ado.SQL.Add('select * from QAUpdate where QAUpdateint=2'); ado.Open; if Ado.RecordCount=0 then begin Application.MessageBox('没有找到更新的路径!','提示信息',MB_YESNO); exit; end else begin s:=ado.FieldByName('QAUpdateName').AsString; ado.Close; ado.SQL.Clear; ado.SQL.Add('select * from QAUpdate where QAUpdateint=0 and QAUpdateNumber>:QAUpdateNumber'); ado.Parameters.ParamByName('QAUpdateNumber').Value:=strtoFloat(upd); ado.Open; if ado.RecordCount=0 then begin Application.MessageBox('没有更新!','提示信息',MB_YESNO); exit; end else begin i:=Ado.RecordCount; j:=0; Gauge1.MinValue:=0; Gauge1.MaxValue:=Ado.RecordCount; Gauge1.Progress:=0; Memo1.Clear; Memo1.Lines.Add('------------------------------更新开始-----------------------------------'); AssignFile(T,ExtractFilePath(Paramstr(0))+'Update.log'); Append(T); writeln(T,'------------------------------更新开始-----------------------------------'+#13); try ado.First; repeat j:=j+1; sfile:=ado.FieldByName('QAUpdateName').AsString; filecopy(s+sfile,pChar(ExtractFilePath(Paramstr(0)))+sfile); Memo1.Lines.Add('一共有'+inttostr(i)+'个文件要更新,第'+inttostr(j)+'个文件更新完毕。'); Memo1.Lines.Add('文件名为:'+ado.FieldByName('QAUpdatere').AsString); Memo1.Lines.Add('更新时间为: '+datetimetostr(Now())); Gauge1.Progress:=Gauge1.Progress+1; writeln(T,'一共有'+inttostr(i)+'个文件要更新,第'+inttostr(j)+'个文件更新完毕。'+'文件名为:'+ado.FieldByName('QAUpdatere').AsString+'更新时间为: '+datetimetostr(Now())+#13); ado.Next; until ado.Eof ; Memo1.Lines.Add('------------------------------更新结束-----------------------------------'); writeln(T,'------------------------------更新结束-----------------------------------'+#13); closefile(T); ado.Close; ado.SQL.Clear; ado.SQL.Add('select max(QAUpdateNumber) as tt from QAUpdate where QAUpdateint=0'); ado.Open; upd:=ado.FieldByName('tt').AsString; myinifile.WriteString('update','updatenumber',upd); //application.MessageBox('升级成功!','提示信息',48); except on e:exception do begin application.MessageBox(pchar('无法保存文件,可能是您开启了病毒防火墙!'+#13+#13+e.Message),'错误信息',16); end; end; end; // memo1.lines.savetofile(pChar(ExtractFilePath(Paramstr(0))+'update.log'));{能保存信息,但只能覆盖原有的信息} ado.close; end; Linkdata(Application.Handle).Free;end; 软件销售问题 delphi 四舍五入的问题 ODAC的小问题 程序中使用的类似XP风格(alpha,带阴影)的图标怎么样才能去掉难看的白边? 普通窗体如何实现层叠功能 开发一个汽车修理长的客户程序,主要是录入,统计,打印,查询等功能,一般价格是多少? 散分,5分钟后结帖,看看人气 一条sql语句的问题 用mediaplyaer开发了一个多媒体应用,客户端没有mediaplyaer的情况下怎样打包? 正则匹配(\s|''|\))中的任意一个,但是如果是AB')CD就会把')匹配在一起 未说明的标识符 请教高手
下载地址:http://www.2ccc.com/article.asp?articleid=5111
Var
S, T: TFileStream;
Begin
S := TFileStream.Create( sourcefilename, fmOpenRead ); try
T := TFileStream.Create( targetfilename,
fmOpenWrite or fmCreate );
try
T.CopyFrom(S, S.Size ) ;
finally
T.Free;
end;
finally
S.Free;
end;
End;
procedure TUpDateForm.UpdateLoad;
var
ado:TADOquery;
myinifile:TInifile;
filename:string;
sfile,s,upd:string;
i,j:integer;
T:TextFile;
begin
Filename:=ExtractFilePath(Paramstr(0))+'mini.ini';
myinifile:=Tinifile.Create(filename);
upd:=myinifile.ReadString('update','updatenumber','');
ado:=TAdoquery.Create(nil);
ado.Connection:=Linkdata(Application.Handle);
ado.close;
ado.SQL.Clear;
ado.SQL.Add('select * from QAUpdate where QAUpdateint=2');
ado.Open;
if Ado.RecordCount=0 then
begin
Application.MessageBox('没有找到更新的路径!','提示信息',MB_YESNO);
exit;
end
else
begin
s:=ado.FieldByName('QAUpdateName').AsString;
ado.Close;
ado.SQL.Clear;
ado.SQL.Add('select * from QAUpdate where QAUpdateint=0 and QAUpdateNumber>:QAUpdateNumber');
ado.Parameters.ParamByName('QAUpdateNumber').Value:=strtoFloat(upd);
ado.Open;
if ado.RecordCount=0 then
begin
Application.MessageBox('没有更新!','提示信息',MB_YESNO);
exit;
end
else
begin
i:=Ado.RecordCount;
j:=0;
Gauge1.MinValue:=0;
Gauge1.MaxValue:=Ado.RecordCount;
Gauge1.Progress:=0; Memo1.Clear;
Memo1.Lines.Add('------------------------------更新开始-----------------------------------');
AssignFile(T,ExtractFilePath(Paramstr(0))+'Update.log');
Append(T);
writeln(T,'------------------------------更新开始-----------------------------------'+#13);
try
ado.First;
repeat
j:=j+1;
sfile:=ado.FieldByName('QAUpdateName').AsString;
filecopy(s+sfile,pChar(ExtractFilePath(Paramstr(0)))+sfile);
Memo1.Lines.Add('一共有'+inttostr(i)+'个文件要更新,第'+inttostr(j)+'个文件更新完毕。');
Memo1.Lines.Add('文件名为:'+ado.FieldByName('QAUpdatere').AsString);
Memo1.Lines.Add('更新时间为: '+datetimetostr(Now()));
Gauge1.Progress:=Gauge1.Progress+1;
writeln(T,'一共有'+inttostr(i)+'个文件要更新,第'+inttostr(j)+'个文件更新完毕。'+'文件名为:'+ado.FieldByName('QAUpdatere').AsString+'更新时间为: '+datetimetostr(Now())+#13);
ado.Next;
until ado.Eof ;
Memo1.Lines.Add('------------------------------更新结束-----------------------------------');
writeln(T,'------------------------------更新结束-----------------------------------'+#13);
closefile(T);
ado.Close;
ado.SQL.Clear;
ado.SQL.Add('select max(QAUpdateNumber) as tt from QAUpdate where QAUpdateint=0');
ado.Open;
upd:=ado.FieldByName('tt').AsString;
myinifile.WriteString('update','updatenumber',upd);
//application.MessageBox('升级成功!','提示信息',48);
except on e:exception do
begin
application.MessageBox(pchar('无法保存文件,可能是您开启了病毒防火墙!'+#13+#13+e.Message),'错误信息',16);
end;
end;
end;
// memo1.lines.savetofile(pChar(ExtractFilePath(Paramstr(0))+'update.log'));{能保存信息,但只能覆盖原有的信息}
ado.close;
end;
Linkdata(Application.Handle).Free;
end;