例程代码如下:
function IEncodeString(inText: string): string;
var
tmp, inBuffer: array [0 .. CNormalBufLen - 1] of Char;
{$IFDEF VER230}
inSize: LongWord;
{$ELSE}
inSize: Integer;
{$ENDIF}
vCompress: Pointer;
begin
Result := '';
if inText = '' then
exit;
inSize := Length(inText);
Move(PChar(inText)^, inBuffer, inSize);
try
CompressBuf(@inBuffer[0], inSize, vCompress, inSize);
PByte(vCompress)^ := inSize;
Move(vCompress^, inBuffer, inSize);
OutputDebugString(PChar(format('0x%s', [IntToHex(PInteger(vCompress)^, 8)])));
inBuffer[inSize] := #0;
FreeMem(vCompress);
except
raise;
end;
Encode6BitBuf(@inBuffer[0], @tmp[0], inSize, CNormalBufLen);
Result := StrPas(tmp);
end;function IDeCodeString(inText: string): string;
var
tmp: array [0 .. CNormalBufLen - 1] of Char;
inSize: Integer;
vCompress: Pointer;
begin
inSize := Decode6BitBuf(PChar(inText), @tmp[0], Length(inText), CNormalBufLen);
try
tmp[0] := Char($78);
DecompressBuf(@tmp[0], inSize, 0, vCompress, inSize);
Move(vCompress^, tmp[0], inSize);
tmp[inSize] := #0;
FreeMem(vCompress);
except
raise;
end;
Result := StrPas(tmp);
end;例程调用代码如下:
IDeCodeString(sMsg, edcNone);
IDeCodeString(sMsg, edcZip);
==================================================
明显的过多传递函数,能不能在不删除传递函数的同时修改源码?
function IEncodeString(inText: string): string;
var
tmp, inBuffer: array [0 .. CNormalBufLen - 1] of Char;
{$IFDEF VER230}
inSize: LongWord;
{$ELSE}
inSize: Integer;
{$ENDIF}
vCompress: Pointer;
begin
Result := '';
if inText = '' then
exit;
inSize := Length(inText);
Move(PChar(inText)^, inBuffer, inSize);
try
CompressBuf(@inBuffer[0], inSize, vCompress, inSize);
PByte(vCompress)^ := inSize;
Move(vCompress^, inBuffer, inSize);
OutputDebugString(PChar(format('0x%s', [IntToHex(PInteger(vCompress)^, 8)])));
inBuffer[inSize] := #0;
FreeMem(vCompress);
except
raise;
end;
Encode6BitBuf(@inBuffer[0], @tmp[0], inSize, CNormalBufLen);
Result := StrPas(tmp);
end;function IDeCodeString(inText: string): string;
var
tmp: array [0 .. CNormalBufLen - 1] of Char;
inSize: Integer;
vCompress: Pointer;
begin
inSize := Decode6BitBuf(PChar(inText), @tmp[0], Length(inText), CNormalBufLen);
try
tmp[0] := Char($78);
DecompressBuf(@tmp[0], inSize, 0, vCompress, inSize);
Move(vCompress^, tmp[0], inSize);
tmp[inSize] := #0;
FreeMem(vCompress);
except
raise;
end;
Result := StrPas(tmp);
end;例程调用代码如下:
IDeCodeString(sMsg, edcNone);
IDeCodeString(sMsg, edcZip);
==================================================
明显的过多传递函数,能不能在不删除传递函数的同时修改源码?
function IEncodeString(inText: string; x:integer): string;
或者是不作任何修改,调用时就只有一个参数
IDeCodeString(sMsg);
估计例程因笔误等原因搞错了,所谓的第二个参数是个注释,大致原来应该是这样子:
IEncodeString(sMsg){edcNone};
IDeCodeString(sMsg){edcZip};
IEncodeString(sMsg){edcZip};
IDeCodeString(sMsg){edcNone};