📄 projectutils.pas
字号:
unit ProjectUtils;
interface
uses
Windows, SysUtils, DateUtils, Forms, Graphics, NhGlobalST, NhPubUtils;
function FontToChatFont(Font: TFont): TChatFontStyle;
procedure ChatFontToFont(const ChatFont: TChatFontStyle; Font: TFont);
function GetExeCardinalVer: Cardinal;
function GetExeStringVer: string;
procedure RunAutoUpgrader(const UpgradeFile, UpgradeUrl: string;
RecvMsgHandle, ExitMsg: Cardinal);
function GetTimeDisplay(Mins: Integer): string;
function GetNowTimeStr: string;
function EncryptStr(const PlainStr: string): string;
function DecryptStr(const EncryptStr: string): string;
procedure TerminateGameProcess(ProcessID: Cardinal);
implementation
uses NhCipher;
const
EncryptKey = 'YOUDONTCRACK';
function FontToChatFont(Font: TFont): TChatFontStyle;
begin
Result.Name := Font.Name;
Result.Color := Font.Color;
Result.Size := Font.Size;
if fsBold in Font.Style then
Result.Bold := 1
else
Result.Bold := 0;
if fsItalic in Font.Style then
Result.Italic := 1
else
Result.Italic := 0;
if fsUnderline in Font.Style then
Result.Underline := 1
else
Result.Underline := 0;
if fsStrikeOut in Font.Style then
Result.Strikeout := 1
else
Result.Strikeout := 0;
end;
procedure ChatFontToFont(const ChatFont: TChatFontStyle; Font: TFont);
begin
Font.Name := ChatFont.Name;
Font.Color := ChatFont.Color;
Font.Size := ChatFont.Size;
Font.Style := [];
if ChatFont.Bold = 1 then
Font.Style := Font.Style + [fsBold];
if ChatFont.Italic = 1 then
Font.Style := Font.Style + [fsItalic];
if ChatFont.Underline = 1 then
Font.Style := Font.Style + [fsUnderline];
if ChatFont.Strikeout = 1 then
Font.Style := Font.Style + [fsStrikeOut];
end;
function GetExeCardinalVer: Cardinal;
begin
Result := GetFileVersion(Application.ExeName);
end;
function GetExeStringVer: string;
var
ExeVer: Cardinal;
begin
ExeVer := GetExeCardinalVer;
Result := IntToStr(ExeVer shr 16) + '.' + IntToStr(ExeVer and $FFFF);
end;
procedure RunAutoUpgrader(const UpgradeFile, UpgradeUrl: string;
RecvMsgHandle, ExitMsg: Cardinal);
var
Params: string;
begin
Params := Format('"%s" "%s" "%s" %d %d %d', [
UpgradeUrl, // 升级脚本文件的URL
GetExeStringVer, // 宿主程序的当前版本号
Application.Title, // 宿主程序的软件名称
RecvMsgHandle, // 宿主程序用来接收消息的窗口句柄
ExitMsg, // 宿主程序收到此消息后应退出程序
GetCurrentProcessID // 宿主程序的进程ID
]);
ExecuteFile(UpgradeFile, Params, '', SW_NORMAL);
end;
function GetTimeDisplay(Mins: Integer): string;
begin
if Mins >= 60 then
Result := Format('%d小时%d分钟', [Mins div 60, Mins mod 60])
else
Result := Format('%d分钟', [Mins])
end;
function GetNowTimeStr: string;
begin
Result := FormatDateTime('hh:mm:ss', Now);
end;
function EncryptStr(const PlainStr: string): string;
begin
SetLength(Result, Length(PlainStr));
EncryptBuffer(TEnc_Blowfish, PlainStr[1], Result[1], Length(PlainStr), EncryptKey);
end;
function DecryptStr(const EncryptStr: string): string;
begin
SetLength(Result, Length(EncryptStr));
DecryptBuffer(TEnc_Blowfish, EncryptStr[1], Result[1], Length(EncryptStr), EncryptKey);
end;
procedure TerminateGameProcess(ProcessID: Cardinal);
begin
Windows.TerminateProcess(OpenProcess(0, False, ProcessID), 0);
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -