?? genfunc.pas
字號:
WideCharToMultiByte(950, 0, pUniCodeChar, -1, pBIG5Char, Len, nil, nil);
Result := string(pBIG5Char);
FreeMem(pBIG5Char);
FreeMem(pGBCHTChar);
FreeMem(pUniCodeChar);
end;
function AnsiToUnicode(Ansi: string): string;
var
s: string;
i: integer;
j, k: string[2];
a: array[1..1000] of char;
begin
s := '';
StringToWideChar(Ansi, @(a[1]), 500);
i := 1;
while ((a[i] <> #0) or (a[i + 1] <> #0)) do begin
j := IntToHex(Integer(a[i]), 2);
k := IntToHex(Integer(a[i + 1]), 2);
s := s + k + j;
i := i + 2;
end;
Result := s;
end;
function ReadHex(AString: string): integer;
begin
Result := StrToInt('$' + AString)
end;
function UnicodeToAnsi(Unicode: string): string;
var
s: string;
i: integer;
j, k: string[2];
begin
i := 1;
s := '';
while i < Length(Unicode) + 1 do begin
j := Copy(Unicode, i + 2, 2);
k := Copy(Unicode, i, 2);
i := i + 4;
s := s + Char(ReadHex(j)) + Char(ReadHex(k));
end;
if s <> '' then
s := WideCharToString(PWideChar(s + #0#0#0#0))
else
s := '';
Result := s;
end;
function UnicodeEncode(Str: string; CodePage: integer): WideString;
var
Len: integer;
begin
Len := Length(Str) + 1;
SetLength(Result, Len);
Len := MultiByteToWideChar(CodePage, 0, PChar(Str), -1, PWideChar(Result), Len);
SetLength(Result, Len - 1); //end is #0
end;
function UnicodeDecode(Str: WideString; CodePage: integer): string;
var
Len: integer;
begin
Len := Length(Str) * 2 + 1; //one for #0
SetLength(Result, Len);
Len := WideCharToMultiByte(CodePage, 0, PWideChar(Str), -1, PChar(Result), Len, nil, nil);
SetLength(Result, Len - 1);
end;
function Gb2Big5(Str: string): string;
begin
SetLength(Result, Length(Str));
LCMapString(GetUserDefaultLCID, LCMAP_TRADITIONAL_CHINESE,
PChar(Str), Length(Str),
PChar(Result), Length(Result));
Result := UnicodeDecode(UnicodeEncode(Result, 936), 950);
// Result:=UnicodeEncode(Result,936);
end;
function Gb2Big5A(Str: string): string;
begin
SetLength(Result, Length(Str));
LCMapString(GetUserDefaultLCID, LCMAP_TRADITIONAL_CHINESE,
PChar(Str), Length(Str),
PChar(Result), Length(Result));
// Result := UnicodeDecode(UnicodeEncode(Result, 936), 950);
Result:=UnicodeEncode(Result,936);
end;
function Big52Gb(Str: string): string;
begin
Str := UnicodeDecode(UnicodeEncode(Str, 950), 936);
SetLength(Result, Length(Str));
LCMapString(GetUserDefaultLCID, LCMAP_SIMPLIFIED_CHINESE,
PChar(Str), Length(Str),
PChar(Result), Length(Result));
end;
function Big52GbA(Str: string): string;
begin
Str := UnicodeDecode(Str, 936);
SetLength(Result, Length(Str));
LCMapString(GetUserDefaultLCID, LCMAP_SIMPLIFIED_CHINESE,
PChar(Str), Length(Str),
PChar(Result), Length(Result));
// Result:=UnicodeEncode(Result,950);
end;
function GBUnicodeToBig5Unicode(Str:string):string;
var
sTemp:string;
begin
sTemp := Str;
stemp := IntToHex(StrToInt(sTemp),4);
stemp := UnicodeToAnsi(stemp);
stemp := UnicodeDecode(stemp,936);
// stemp := GBToBIG5(stemp);
// stemp := UnicodeToAnsi(stemp);
stemp := GBToBIG5(stemp);
// stemp := AnsiToUnicode(stemp);
// stemp := IntToStr(ReadHex(stemp));
stemp := UnicodeEncode(stemp,950);
stemp := AnsiToUnicode(stemp);
// stemp := UnicodeDecode(stemp,10002);
stemp := IntToStr(ReadHex(stemp));
Result := sTemp;
end;
function Big5UnicodeToGBUnicode(Str:string):string;
var
sTemp:string;
begin
sTemp := Str;
stemp := IntToHex(StrToInt(sTemp),4);
stemp := UnicodeToAnsi(stemp);
stemp := UnicodeDecode(stemp,950);
// stemp := GBToBIG5(stemp);
// stemp := UnicodeToAnsi(stemp);
stemp := BIG5ToGB(stemp);
// stemp := AnsiToUnicode(stemp);
// stemp := IntToStr(ReadHex(stemp));
stemp := UnicodeEncode(stemp,936);
stemp := AnsiToUnicode(stemp);
// stemp := UnicodeDecode(stemp,10002);
stemp := IntToStr(ReadHex(stemp));
Result := sTemp;
end;
function GBStrToBig5Unicode(Str:string):string;
var
sTemp:string;
sResult:string;
i,iLen:Integer;
begin
sTemp := Str;
// stemp := IntToHex(StrToInt(sTemp),4);
// stemp := UnicodeToAnsi(stemp);
// stemp := UnicodeDecode(stemp,936);
// stemp := GBToBIG5(stemp);
// stemp := UnicodeToAnsi(stemp);
stemp := GBToBIG5(stemp);
// stemp := AnsiToUnicode(stemp);
// stemp := IntToStr(ReadHex(stemp));
stemp := UnicodeEncode(stemp,950);
stemp := AnsiToUnicode(stemp);
// stemp := UnicodeDecode(stemp,10002);
sResult := '#';
iLen:= Length(sTemp) div 4;
for i := 0 to iLen-1 do
begin
sResult := sResult + IntToStr(ReadHex(Copy(stemp,i*4+1,4)))+'#';
end;
sResult := Copy(sResult,1,Length(sResult)-1);
// stemp := IntToStr(ReadHex(stemp));
Result := sResult;
end;
function Encryptstr(const s: string; skey: string): string;
var
i, j: integer;
hexS, hexskey, midS, tmpstr: string;
a, b, c: byte;
begin
hexS := myStrtoHex(s);
hexskey := myStrtoHex(skey);
midS := hexS;
for i := 1 to (length(hexskey) div 2) do
begin
if i <> 1 then midS := tmpstr;
tmpstr := '';
for j := 1 to (length(midS) div 2) do
begin
a := strtoint('$' + midS[2 * j - 1] + midS[2 * j]);
b := strtoint('$' + hexskey[2 * i - 1] + hexskey[2 * i]);
c := a xor b;
tmpstr := tmpstr + myStrtoHex(chr(c));
end;
end;
result := tmpstr;
end;
function GetNetCardSN: string;
{=========================================================================
Returns adapter card address.
=========================================================================}
var
NCB: TNCB; // Netbios control block //NetBios控制塊
ADAPTER: TADAPTERSTATUS; // Netbios adapter status//取網卡狀態
LANAENUM: TLANAENUM; // Netbios lana
intIdx: Integer; // Temporary work value//臨時變量
cRC: Char; // Netbios return code//NetBios返回值
strTemp: string; // Temporary string//臨時變量
begin
// Initialize
Result := '';
try
// Zero control blocl
ZeroMemory(@NCB, SizeOf(NCB));
// Issue enum command
NCB.ncb_command := Chr(NCBENUM);
cRC := NetBios(@NCB);
// Reissue enum command
NCB.ncb_buffer := @LANAENUM;
NCB.ncb_length := SizeOf(LANAENUM);
cRC := NetBios(@NCB);
if Ord(cRC) <> 0 then
exit;
// Reset adapter
ZeroMemory(@NCB, SizeOf(NCB));
NCB.ncb_command := Chr(NCBRESET);
NCB.ncb_lana_num := LANAENUM.lana[0];
cRC := NetBios(@NCB);
if Ord(cRC) <> 0 then
exit;
// Get adapter address
ZeroMemory(@NCB, SizeOf(NCB));
NCB.ncb_command := Chr(NCBASTAT);
NCB.ncb_lana_num := LANAENUM.lana[0];
StrPCopy(NCB.ncb_callname, '*');
NCB.ncb_buffer := @ADAPTER;
NCB.ncb_length := SizeOf(ADAPTER);
cRC := NetBios(@NCB);
// Convert it to string
strTemp := '';
for intIdx := 0 to 5 do
strTemp := strTemp + inttohex(Byte(ADAPTER.adapter_address[intIdx]), 2);
Result := strTemp;
finally
end;
end;
function myStrtoHex(s: string): string;
var
tmpstr: string;
i: integer;
begin
tmpstr := '';
for i := 1 to length(s) do
begin
tmpstr := tmpstr + inttoHex(ord(s[i]), 2);
end;
result := tmpstr;
end;
initialization
//{$IFDEF ISBASEACCESS}
// genInfo.IsBaseAccess := True;
//{$ELSE}
// genInfo.IsBaseAccess := False;
//{$ENDIF ISBASEACCESS}
{$IFDEF ISDEMO}
genInfo.IsDemo := True;
{$ELSE}
genInfo.IsDemo := False;
{$ENDIF ISDEMO}
{$IFDEF ISHASDOG}
genInfo.IsHasDog := True;
{$ELSE}
genInfo.IsHasDog := False;
{$ENDIF ISHASDOG}
{$IFDEF ISMEPG4}
genInfo.DataName := 'Songbase.dat';
genInfo.Password := 'lfhyx201314';
{$ELSE}
genInfo.DataName := 'Song.dat';
genInfo.Password := 'lx200602';
{$ENDIF ISMEPG4}
genInfo.FieldName := 'A' + FormatDateTime('d', Date);
genInfo.PreFieldName := 'A' + FormatDateTime('d', Date - 1);
end.
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -