📄 humunit.pas
字号:
unit HumUnit;
interface
uses
Windows, Messages, SysUtils, Classes;
type
PhumHead = ^Thumhead;
THumHead = packed record
Ver: array[0..103] of char;
Count: Integer;
UnKown: array[0..7] of char;
UpTime: TDateTime;
UnKownBool: LongBool;
end;
type
PHum = ^THum;
THum = packed record
LoginTime: TDateTime;
Name1Long: ShortInt;
name1: array[0..14] of char;
name2Long: ShortInt;
name2: array[0..13] of char;
IDlong: ShortInt;
Id: array[0..9] of char;
Enable: Boolean;
UnKownBool: Boolean;
DeleteTime: TDateTime;
Count: Byte;
UnKown: array[0..10] of char;
end;
type
THuMan = class
private
FS: TFileStream;
Fhead: PhumHead;
public
NameList: TStringList;
HumList: TList;
IDList: TStringList;
tmpList: TList;
constructor Create(HumFile: string);
destructor Destroy; override;
procedure Read;
procedure AppendWrite;
procedure PosRead(var Buffer; Position: Integer; Count: Integer);
procedure PosWrite(var Buffer; Position: Integer; Count: Integer);
function ByteToHex(Buf: array of Byte): string;
property FileHead: PhumHead read Fhead write Fhead;
property FileStream: TFileStream read FS;
end;
implementation
constructor Thuman.Create(HumFile: string);
begin
NameList := TStringList.Create;
IDList := TStringList.Create;
HumList := TList.Create;
FS := TFileStream.Create(HumFile, fmCreate and fmOpenReadWrite or fmShareDenyNone);
New(Fhead);
FS.Read(Fhead^, SizeOf(ThumHead));
end;
destructor Thuman.Destroy;
begin
FS.Free;
end;
function Thuman.ByteToHex(Buf: array of Byte): string;
var
Len, i: integer;
Str: string;
begin
Str := '';
Len := Length(Buf) - 1;
for i := 0 to Len do
begin
Str := Str + ' ' + IntToHex(Buf[i], 2);
end;
Result := Str;
end;
procedure Thuman.PosRead(var Buffer; Position: Integer; Count: Integer);
begin
FS.Position := Position;
FS.Read(Buffer, Count);
end;
procedure Thuman.PosWrite(var Buffer; Position: Integer; Count: Integer);
begin
FS.Position := Position;
FS.Write(Buffer, Count);
end;
procedure Thuman.Read;
var
Hum: Phum;
Index: Integer;
begin
while FS.Position < FS.Size do
begin
New(Hum);
FS.Read(Hum^, SizeOf(THum));
// Index := NameList.IndexOf(Hum.name1);
// if Index > -1 then Continue;
NameList.Add(Hum.name1);
HumList.Add(Tobject(Hum));
IdList.Add(Hum.Id);
end;
end;
procedure Thuman.AppendWrite;
var
Hum: PHum;
Nothing : Integer;
AllCount : Integer;
begin
AllCount := HumList.Count + tmpList.Count;
PosWrite(AllCount, 104, SizeOf(Integer));
FS.Seek(0, soFromEnd);
FS.Write(Nothing,SizeOF(Integer));
while tmpList.Count > 0 do
begin
Hum := Phum(tmpList[0]);
FS.Write(Hum^, SizeOF(Thum));
tmpList.Delete(0);
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -