Simple online upgrade implementation method

zhaozj2021-02-08  217

Author: Xuchang You used antivirus software in general, are aware, when you start the program, often ask, the Internet has a new version, you are prompted to upgrade the like, and now more and more software support online upgrade, if you also want to achieve this function? This article is how to upgrade online, telling how to download the upgrade version through HTTP detection, and download the upgrade.

Implementation: 1. The website provides upgrade information. 2. Use HTTP to download upgrade information from the website. 3, determine if it is upgraded, upgrade the program

Below we define upgrade information: [File name 1] datetime = time [file name 2] datetime = time saving html file, such as defining an update.htm [program1.exe] datetime = 2003-07-06 [programe1.hlp ] datetime = 2003-07-06

Here is just simple to determine the time of the file, if time is small, you want to download the new version to upgrade it. Of course, we have to do it, which is unreasonable, here is just a simple introduction. Write a FUCTION, determine if there is a new version to upgrade

function ExistNewFile: boolean; var i, iFileHandle: integer; FileDateTime: TDateTime; AppIni: TiniFile; g_path: string; url: string; files: TStrings; begin result: = false; url: = 'http: //yousoft.hi. com.cn/Update.htm '; // To upgrade server g_path: = extractFilePath (Application.exename); // Upgrade path if copy (g_path, length (g_path), 1) <>' / 'Then G_Path : = g_path '/'; if Copy (URL, Length (URL), 1) <> '/' THEN URL: = URL '/';

// Download Upgrade Information Document Try httpfiles.inputfilemode: = true; httpfiles.outputfilemode: = false; httpfiles.reportlevel: = status_baSic; httpfiles.body: = g_path 'update / update.ini'; // Save to programs Update directory httpfiles.get (URL); ExcePt Result: = false; // 'gets the upgrade information error! No need to continue exit; end; "Try Files: = TSTRINGLIST.CREATE; / / What files? Appini: = tinifile.create (g_path '/ update / update.ini'); appini.readsections (files); for i: = 0 to files.count-1 do trynesshandle: = fileOpen (g_path files [i], fmShareDenyNone); FileDateTime: = FileDateToDateTime (FileGetDate (iFileHandle)); // file acquisition time FileClose (iFileHandle); // if you want to download the file if FileDateTime

转载请注明原文地址:https://www.9cbs.com/read-2699.html

New Post(0)