妖帅
- UID
- 14654
- 精华
- 6
- 积分
- 4092
- 威望
- 0 度
- 性别
- 男
|
阁楼
大 中
小 发表于 2018-6-16 17:50 显示全部帖子
台服客戶端同步官方升級程序源碼
實現了這個功能就可以脫離大宇遊戲領航員3.0來進行客戶端更新(客戶端更新功能直接置入到登陸器) 妖城在线论坛( p' I4 X: p: L! m1 I5 @7 i5 o9 O
魔力私服,最新魔力私服,魔力宝贝私服,魔力宝贝私服技术,魔力宝贝私服,私服架设技术,妖城,FLASH,电影,黑客,网络,网吧,破解,入侵,注册表5 x2 D0 z8 r3 D& M/ U6 o- G- J9 R% `
代碼寫的粗糙還請大家不要見怪 魔力私服,最新魔力私服,魔力宝贝私服,魔力宝贝私服技术,魔力宝贝私服,私服架设技术,妖城,FLASH,电影,黑客,网络,网吧,破解,入侵,注册表+ r# F" [9 M! t: k3 s( c( W
程序通過下載Script_CRC.ini 然後讀取客戶端當前Script.ini的CRC值和最新版本比較 如果不一樣就更新Script.ini
2 ~3 P3 M$ g: x9 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.
妖城在线论坛1 y, k( \2 z5 i
" J; j4 r" m0 N' n7 T8 l! V& q魔力私服,最新魔力私服,魔力宝贝私服,魔力宝贝私服技术,魔力宝贝私服,私服架设技术,妖城,FLASH,电影,黑客,网络,网吧,破解,入侵,注册表
' x! O6 L* H0 k: H- K$ i
; r8 q/ j. K; X4 Q# I" A
4 v" Y* p7 g* J; j$ e6 l: N4 k魔力私服,最新魔力私服,魔力宝贝私服,魔力宝贝私服技术,魔力宝贝私服,私服架设技术,妖城,FLASH,电影,黑客,网络,网吧,破解,入侵,注册表
9 n1 F; U7 y( }: E% cbbs.mocwww.com
|