function StrToHex(SourceStr: WideString): WideString;
var
hexstr: string;
i : integer;
begin
result := '';
hexstr := '';
for i := 1 to Length(SourceStr) do
hexstr := hexstr + IntToHex(Word(SourceStr), 2);
//hexstr := hexstr + AnsiUpperCase(IntToStr(Ord(SourceStr)));
//hexstr := hexstr + AnsiUpperCase(Byte(SourceStr));
Result := hexstr;
end;
//十六进制转Ascii码
function HexToStr(SourceStr: WideString): WideString;
var str:string;
text:string;
BX:string;
begin
//BX:=copy(cmd,length(cmd),1);
//delete(cmd,length(cmd),1);
while length(SourceStr)<>0 do
begin
str:=copy(SourceStr,1,2);
text:=text+chr(ord(strtoint('$' + str)));
delete(SourceStr,1,2);
end;
result:=text;
end;