如果你不想去我把代码给你
unit uGetpy;
interface
uses
windows,registry,sysutils,dialogs,forms;
function GetPY(HZ
char)
char; stdcall;
function GetPYHead(HZ
char)
char; stdcall;
implementation
const
chinacode:array [0..25,0..1] of integer =((1601,1636),
(1637,1832),(1833,2077),(2078,2273),(2274,2301),(2302,2432),
(2433,2593),(2594,2786),(9999,0000),(2787,3105),(3106,3211),
(3212,3471),(3472,3634),(3635,3722),(3723,3729),(3730,3857),
(3858,4026),(4027,4085),(4086,4389),(4390,4557),(9999,0000),
(9999,0000),(4558,4683),(4684,4924),(4925,5248),(5249,5589));
function GetPY(HZ
char)
char; stdcall;
var
c1,len1,c2 :integer;
ir:word;
FResult,hzs:string;
begin
hzs:=strpas(hz);
FResult:='';
c1:=1;
c2:=0;
len1:=length(HZ);
while (c1<len1) do
begin
if (ord(HZ[c1])>=160) and (ord(HZ[c1+1])>=160) then
begin
ir:=(ord(HZ[c1])-160)*100 +ord(HZ[c1+1])-160;
while (c2<=26) do
begin
if (ir>=chinacode[c2,0]) and (ir<=chinacode[c2,1]) then
begin
FResult:=FResult+chr(c2+ord('a'));
break;
end;
c2:=c2+1;
end; // while
end;
c1:=c1+2;
end; // while
result:=pchar(FResult);
end;
function GetPYHead(HZ
char)
char; stdcall;
var
i:integer;
r,hzs:string;
begin
hzs:=strpas(hz);
r:='';
for I:=0 to length(hz) do
begin
case word(hz[i*2+1]) shl 8 +word(hz[(i+1)*2]) of
$b0a1..$b0c4: result:='a';
$b0c5..$b2c0: result:='b';
$b2c1..$b4ed: result:='c';
$b4ee..$b6e9: result:='d';
$b6ea..$b7a1: result:='e';
$b7a2..$b8c0: result:='f';
$b8c1..$b9fd: result:='g';
$b9fe..$bbf6: result:='h';
$bbf7..$bfa5: result:='j';
$bfa6..$c0ab: result:='k';
$c0ac..$c2e7: result:='l';
$c2e8..$c4c2: result:='m';
$c4c3..$c5b5: result:='n';
$c5b6..$c5bd: result:='o';
$c5be..$c6d9: result:='p';
$c6da..$c8ba: result:='q';
$c8bb..$c8f5: result:='r';
$c8f6..$cbf9: result:='s';
$cbfa..$cdd9: result:='t';
$cdda..$cef3: result:='w';
$cef4..$d188: result:='x';
$d1b9..$d4d0: result:='y';
$d4d1..$d7f9: result:='z';
else
result:=char(0);
end;
r:=r+result;
end;//
result:=pchar(r);
end;
end.