标题: [讨论] 台服客戶端同步官方升級程序源碼 [打印本页]
作者: 全熟牛排溅血 时间: 2018-6-16 17:50 标题: 台服客戶端同步官方升級程序源碼
實現了這個功能就可以脫離大宇遊戲領航員3.0來進行客戶端更新(客戶端更新功能直接置入到登陸器)魔力私服,最新魔力私服,魔力宝贝私服,魔力宝贝私服技术,魔力宝贝私服,私服架设技术,妖城,FLASH,电影,黑客,网络,网吧,破解,入侵,注册表% J/ o: o: ~# n$ P
. M# }. Y& ^; M/ I: `& f9 `& ~魔力私服,最新魔力宝贝私服技术交流代碼寫的粗糙還請大家不要見怪
/ O9 v+ V, I# `# Q—魔力私服,魔力宝贝私服技术,DELPHI编程,魔力寶貝, 魔力宝贝, 크로스게이트,クロスゲート程序通過下載Script_CRC.ini 然後讀取客戶端當前Script.ini的CRC值和最新版本比較 如果不一樣就更新Script.ini妖城在线论坛, w) ?. M: c) B# J/ }1 c& I' V5 e
然後讀取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.
bbs.mocwww.com- q9 Q$ a' O: F/ B
$ ~" ~' b5 `3 w: s* D: Vbbs.mocwww.com
0 y) b' o4 y) j7 A—魔力私服,魔力宝贝私服技术,DELPHI编程,魔力寶貝, 魔力宝贝, 크로스게이트,クロスゲート
3 y" d5 f) K. s# @, Y" N魔力私服,最新魔力私服,魔力宝贝私服,魔力宝贝私服技术,魔力宝贝私服,私服架设技术,妖城,FLASH,电影,黑客,网络,网吧,破解,入侵,注册表
魔力私服,最新魔力宝贝私服技术交流! G ?% e: N% a2 K) x9 p
$ [/ a4 C, |/ Z$ J魔力私服,最新魔力私服,魔力宝贝私服,魔力宝贝私服技术,魔力宝贝私服,私服架设技术,妖城,FLASH,电影,黑客,网络,网吧,破解,入侵,注册表
图片附件: beforeupdate.jpg (2018-6-16 17:50, 202.07 KB) / 该附件被下载次数 147
http://bbs.mocwww.com/attachment.php?aid=18738
图片附件: after.jpg (2018-6-16 17:50, 143.27 KB) / 该附件被下载次数 131
http://bbs.mocwww.com/attachment.php?aid=18739
图片附件: dl.jpg (2018-6-16 17:50, 116.45 KB) / 该附件被下载次数 249
http://bbs.mocwww.com/attachment.php?aid=18740
图片附件: stop.jpg (2018-6-16 17:50, 300.78 KB) / 该附件被下载次数 136
http://bbs.mocwww.com/attachment.php?aid=18741
作者: 全熟牛排溅血 时间: 2018-6-16 17:54
如果已經是官方版的台服客戶端運行無作用 文本打開Script.ini隨意填入幾個字保存來改變文件CRC值 再重新嘗試應該就可以了
附件: Update.rar (2018-6-16 17:54, 1.81 MB) / 该附件被下载次数 348
http://bbs.mocwww.com/attachment.php?aid=18742
作者: Maldiniymx 时间: 2018-6-17 08:19
好东西,终于不用领航员了!
作者: 全熟牛排溅血 时间: 2018-6-20 12:44
也可以用來製作私服的自動客戶端更新程序 把需要下載的單文件放在服務器上 客戶端自己下載寫入到客戶端
作者: a512119595 时间: 2018-6-20 13:55
支持牛排大大的~
作者: 315587701 时间: 2018-6-21 09:03
牛排大大还在奋斗
作者: rolser 时间: 2018-6-21 13:05
好东西啊@!!!!!!!!!!!!!!!!!!
作者: 风dē菋噵 时间: 2018-6-21 17:58
要顶这才啊
欢迎光临 妖城在线论坛 (http://bbs.mocwww.com/) |
Powered by Discuz! 6.0.0 |