妖帅
- UID
- 14654
- 精华
- 6
- 积分
- 4092
- 威望
- 0 度
- 性别
- 男
|
阁楼
大 中
小 发表于 2018-6-16 17:50 只看该作者
台服客戶端同步官方升級程序源碼
實現了這個功能就可以脫離大宇遊戲領航員3.0來進行客戶端更新(客戶端更新功能直接置入到登陸器) 妖城在线论坛. U7 Q, p/ G1 W( y( y5 F4 H. z
魔力私服,最新魔力宝贝私服技术交流, v G& l' Y6 p7 |% G
代碼寫的粗糙還請大家不要見怪 —魔力私服,魔力宝贝私服技术,DELPHI编程,魔力寶貝, 魔力宝贝, 크로스게이트,クロスゲート' C& x3 [) S3 W5 v
程序通過下載Script_CRC.ini 然後讀取客戶端當前Script.ini的CRC值和最新版本比較 如果不一樣就更新Script.ini
% A B' q7 _0 d4 B9 J2 |魔力私服,最新魔力私服,魔力宝贝私服,魔力宝贝私服技术,魔力宝贝私服,私服架设技术,妖城,FLASH,电影,黑客,网络,网吧,破解,入侵,注册表然後讀取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.
1 U: o# t" d) E3 V; w- b妖城在线论坛妖城在线论坛% U! v: b7 B! I7 c( i
—魔力私服,魔力宝贝私服技术,DELPHI编程,魔力寶貝, 魔力宝贝, 크로스게이트,クロスゲート9 X! u2 D+ E: ~/ M4 U
魔力私服,最新魔力私服,魔力宝贝私服,魔力宝贝私服技术,魔力宝贝私服,私服架设技术,妖城,FLASH,电影,黑客,网络,网吧,破解,入侵,注册表% X, t# {4 _$ U( ?. b" s$ I
魔力私服,最新魔力宝贝私服技术交流$ H) l% y( t1 o" G% p+ a
9 h* O! l c" U% c- C! i妖城在线论坛
|