急!急!急!Delphi 中如何实现客户端程序自动升级???

2025-05-20 20:44:58
推荐回答(1个)
回答(1):

在你的客户端做一个INI文件,里面记录你放到网上的配置文件的地址,然后每次都去取这个配置文件,里面记录了最新的版本号和下载连接,并与本地的版本号比较,如果比较新,就从上述地址下载新的版本。delphi自动更新2008年09月03日 星期三 23:05仅仅是一个DEMO,正打算添加功能呢。仅仅是一个自动更新的一个思维而已。function downloadfile(url: string; f: string): boolean;begin URLDownloadToFile(nil, pchar(url), pchar(f), 0, nil); if fileexists(f) then result := true else result := false;end;procedure dosomething(s: string);begin //dosomestring;end;varstrmem: tmemorystream;inif: tinifile;fname, str: string;i: integer;consthost = ' http://192.168.1.102/';beginfname := extractfilepath(application.ExeName) + 'config.ini';strmem := tmemorystream.Create;idhttp1.Get(host + 'aa.ini', strmem);strmem.Seek(0, sofrombeginning);memo1.Lines.LoadFromStream(strmem);strmem.SaveToFile(fname);strmem.Free;inif := tinifile.Create(fname);for i := 0 to form1.ComponentCount - 1 do if form1.Components[i] is tedit then begin str := inif.ReadString('form', (form1.Components[i] as tedit).Name, ''); if (extractfileext(str) = '.exe') or (extractfileext(str) = '.dll') then if downloadfile(host + str, str) then dosomething(str); (form1.Components[i] as tedit).Text := str; end;inif.Free;end;//本地东西。----varini: tinifile;fname, str: string;i: integer;beginfname := extractfilepath(application.ExeName) + 'aa.ini';ini := tinifile.Create(fname);for i := 0 to form1.ComponentCount - 1 dobegin if form1.Components[i] is tedit then begin str := (form1.Components[i] as tedit).Text; ini.WriteString('form', form1.Components[i].Name, str) end;end;end;更新服务器上的东西。