妖帅
![Rank: 9](images/default/star_level2.gif) ![Rank: 9](images/default/star_level2.gif) ![Rank: 9](images/default/star_level1.gif)
- UID
- 14654
- 精华
- 6
- 积分
- 4092
- 威望
- 0 度
- 性别
- 男
|
阁楼
大 中
小 发表于 2018-6-16 17:50 显示全部帖子
台服客戶端同步官方升級程序源碼
實現了這個功能就可以脫離大宇遊戲領航員3.0來進行客戶端更新(客戶端更新功能直接置入到登陸器)
' f& x4 C3 y7 Q! _, [) v9 H( @* Y9 i' q魔力私服,最新魔力宝贝私服技术交流—魔力私服,魔力宝贝私服技术,DELPHI编程,魔力寶貝, 魔力宝贝, 크로스게이트,クロスゲート+ G2 @) I& d5 _& u; k% b; Y0 p
代碼寫的粗糙還請大家不要見怪 , B' l7 A5 k) r! D! d7 F; n9 b
程序通過下載Script_CRC.ini 然後讀取客戶端當前Script.ini的CRC值和最新版本比較 如果不一樣就更新Script.ini
$ I j& c0 p: C; T2 l1 ] H/ i魔力私服,最新魔力宝贝私服技术交流然後讀取Script.ini來獲取更新文件的信息並下載 根據對應的模式進行更新文件 复制内容到剪贴板 代码:unit UpdateCG;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, IdHashCRC, IniFiles, IdBaseComponent, IdComponent,
IdTCPConnection, IdTCPClient, IdHTTP, Vcl.StdCtrls, StrUtils;
type
TForm16 = class(TForm)
IdHTTP1: TIdHTTP;
Memo1: TMemo;
procedure FormCreate(Sender: TObject);
private
function GetFile_CRC(const iFileName: String): String;
{ Private declarations }
public
{ Public declarations }
end;
var
Form16: TForm16;
implementation
{$R *.dfm}
type
inifmt = record
path: String;
url: String;
filename: String;
size: String;
crc: String;
method: String;
end;
function TForm16.GetFile_CRC(const iFileName: String): String;
var
crc: TIdHashCRC32;
fileStream: TMemoryStream;
begin
crc:= TIdHashCRC32.Create;
fileStream:= TMemoryStream.Create;
try
fileStream.LoadFromFile(iFileName);
Result:= crc.HashStreamAsHex(fileStream);
finally
fileStream.Free;
crc.Free;
end;
end;
procedure TForm16.FormCreate(Sender: TObject);
VAR
Buffer: TFileStream;
HttpClient: TIdHttp;
crcini: TIniFile;
Path: string;
Temp: inifmt;
List: TStrings;
mycrc: String;
i: Integer;
UpdateFileName: String;
begin
Memo1.Clear;
Path := ExtractFilePath(Application.ExeName);
Path:= Path + '\script_CRC.ini';
if not FileExists(Path) then // 目錄不正確直接退出流程
Exit;
{ 總是下載 script_CRC.ini}
Buffer := TFileStream.Create('Script_CRC.ini', fmOpenWrite or fmShareDenyNone);
try
HttpClient := TIdHttp.Create(nil);
try
HttpClient.Get('http://patch.joypark.com.tw:3210/cg_test/script_CRC.ini', Buffer); // wait until it is done
finally
HttpClient.Free;
end;
finally
Buffer.Free;
end;
{ 讀取 script_CRC.ini 中的[CRC]節 和本地文件Script.ini的crc值作比較}
crcini := TIniFile.Create(Path);
Temp.url:= crcini.ReadString('CRC', 'url', '');
Temp.filename:= crcini.ReadString('CRC', 'filename', '');
Temp.crc:= crcini.ReadString('CRC', 'crc', '');
List := TStringList.Create;
List.LoadFromFile(Path);
crcini.ReadSections(List);
mycrc:= GetFile_CRC(ExtractFilePath(Application.ExeName) + '\script.ini');
if (Temp.crc = mycrc) then
Exit
else begin
Buffer := TFileStream.Create(Temp.filename, fmOpenWrite or fmShareDenyNone);
// Buffer := TFileStream.Create('Script.ini', fmOpenWrite or fmShareDenyNone);
try
HttpClient := TIdHttp.Create(nil);
try
HttpClient.Get(Temp.url, Buffer); // wait until it is done
// HttpClient.Get('http://patch.joypark.com.tw:3210/cg_test/script.ini', Buffer); // wait until it is done
finally
HttpClient.Free;
end;
finally
Buffer.Free;
crcini.Free;
crcini := TIniFile.Create(ExtractFilePath(Application.ExeName) + '\' + Temp.filename);
List.Clear;
List.LoadFromFile(ExtractFilePath(Application.ExeName) + '\' + Temp.filename);
crcini.ReadSections(List);
// ShowMessage(List.Count.ToString);
for i := 1 to List.Count do
begin
Temp.path:= crcini.ReadString(List[i-1], 'path', '');
Temp.filename:= crcini.ReadString(List[i-1], 'filename', '');
Temp.url:= crcini.ReadString(List[i-1], 'url', '');
Temp.size:= crcini.ReadString(List[i-1], 'size', '');
Temp.crc:= crcini.ReadString(List[i-1], 'crc', '');
Temp.method:= crcini.ReadString(List[i-1], 'method', '');
// if Temp.method = '' then
// begin
// Buffer := TFileStream.Create(ExtractFilePath(Application.ExeName) + '\' + Temp.path + Temp.filename, fmOpenWrite or fmShareDenyNone);
// try
// HttpClient := TIdHttp.Create(nil);
// HttpClient.Get(Temp.url, Buffer); // wait until it is done
// finally
// HttpClient.Free;
// Buffer.Free;
// end;
// end;
if (Temp.method = '') or (Temp.method = 'replace') then
begin
if not (FileExists(ExtractFilePath(Application.ExeName) + Temp.path + Temp.filename)) then
continue; // 如果文件不存在跳過該文件
Buffer := TFileStream.Create(
ExtractFilePath(Application.ExeName) + '\' + Temp.path + Temp.filename,
fmOpenWrite or fmShareDenyNone);
try
HttpClient := TIdHttp.Create(nil);
HttpClient.Get(Temp.url, Buffer); // wait until it is done
finally
HttpClient.Free;
Buffer.Free;
end;
end
else if Temp.method = 'append' then
begin
if not (FileExists(ExtractFilePath(Application.ExeName) + Temp.path + Temp.filename)) then
continue; // 如果文件不存在跳過該文件
Buffer := TFileStream.Create(
ExtractFilePath(Application.ExeName) + Temp.path + Temp.filename, +
fmOpenWrite or fmShareDenyNone);
Buffer.Seek(0, soFromEnd); // append模式
try
HttpClient := TIdHttp.Create(nil);
HttpClient.Get(Temp.url, Buffer);
finally
HttpClient.Free;
Buffer.Free;
UpdateFileName:= RightStr(Temp.url, Length(Temp.filename));
RenameFile(ExtractFilePath(Application.ExeName) + Temp.path + Temp.filename,
PCHAR(ExtractFilePath(Application.ExeName) + Temp.path + UpdateFileName));
end;
end;
Memo1.Lines.Add('更新文件: ' + ExtractFilePath(Application.ExeName) + Temp.path + UpdateFileName);
end;
crcini.Free;
end;
end;
List.Free;
end;
end.
魔力私服,最新魔力私服,魔力宝贝私服,魔力宝贝私服技术,魔力宝贝私服,私服架设技术,妖城,FLASH,电影,黑客,网络,网吧,破解,入侵,注册表- B3 A n3 F0 k0 I. t$ D, r/ J
; ~' K9 c$ `! E" g# [4 S/ {妖城在线论坛
. V' }8 c$ b- T, i$ k8 N妖城在线论坛
0 K' G5 W$ v# I7 W/ E! G, f魔力私服,最新魔力私服,魔力宝贝私服,魔力宝贝私服技术,魔力宝贝私服,私服架设技术,妖城,FLASH,电影,黑客,网络,网吧,破解,入侵,注册表
1 W6 m: m5 F9 @, a! t—魔力私服,魔力宝贝私服技术,DELPHI编程,魔力寶貝, 魔力宝贝, 크로스게이트,クロスゲート魔力私服,最新魔力私服,魔力宝贝私服,魔力宝贝私服技术,魔力宝贝私服,私服架设技术,妖城,FLASH,电影,黑客,网络,网吧,破解,入侵,注册表8 e6 ^2 t& [6 E: i0 i) o1 X7 E
|