这是我写的DLL,里面有两函数:library qw;uses
  SysUtils,
  Classes;{$R *.res}
//第一个函数:汉字转换成首位拼音码函数。function GetPY2( hzchar:string):Char;
begin
  case WORD(hzchar[1]) shl 8 + WORD(hzchar[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..$D1B8 : result := 'x';
    $D1B9..$D4D0 : result := 'y';
    $D4D1..$D7F9 : result := 'z';
  else
    result :=Char(0);
  end;
end;function LmyPy(S:string):pchar;stdcall;
var
  cstr,hz,py,py1:string;
  hstr:array[1..23] of string;
  i,j,k:integer;
const
  zm:array[1..23] of char='abcdefghjklmnopqrstwxyz';
begin
cstr:='0123456789abcdefghijklmnopqrstuvwxyz';
cstr:=cstr+'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
cstr:=cstr+'!.#$%()*+-,/[\|^~`@{}_';
hstr[1]:='锕 ';
hstr[2]:='茇 ';
hstr[3]:='嚓 ';
hstr[4]:='耷 ';
hstr[5]:='噩 ';
hstr[6]:='垡 ';
hstr[7]:='尬 ';
hstr[8]:='虾 ';
hstr[9]:='亟 ';
hstr[10]:='咔 ';
hstr[11]:='剌 ';
hstr[12]:='唛 ';
hstr[13]:='捺 ';
hstr[14]:='讴 ';
hstr[15]:='杷 ';
hstr[16]:='俟 ';
hstr[17]:='苒 ';
hstr[18]:='仨 ';
hstr[19]:='獭 ';
hstr[20]:='婉 ';
hstr[21]:='兮 ';
hstr[22]:='揠 ';
hstr[23]:='咂 ';py:='';
j:=1;
i:=Length(s);
while (j<=i) Do
begin
if Pos(s[j],cstr)>0 then
   begin
      py:=py+s[j];
      j:=j+1;
   end
else
begin
  hz:=s[j]+s[j+1];
  py1:=getpy2(hz);
  if py1<>char(0) then
  begin
  py:=py+py1;
  end
  else
  for k:=1 to 23 do
  begin
      if Pos(hz,hstr[k])>0 then
      begin
       py:=py+zm[k];
       break;
      end;
      if k=23 then py:=py+'!';
  end;
  j:=j+2;
end;
end;
  Result:=Pchar(UpperCase(py));
end;exports
LmyPy;begin
end.
然后在程序中调用:unit Unit1;interfaceuses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;type
  TForm1 = class(TForm)
    Edit1: TEdit;
    Edit2: TEdit;
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;var
  Form1: TForm1;implementationfunction LmyPy(S:string):pchar;stdcall;external 'qw.dll';
function SfzZh(ID:string):Pchar;stdcall;external 'qw.dll';{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
begin
Edit2.Text:=LmyPy(Edit1.Text);
end;end.
//第二个函数:身份证转换函数function SfzZh(ID:string):Pchar;stdcall;
const
  W:array [1..18] of integer = (7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2,1);
  A:array [0..10] of char = ('1','0','x','9','8','7','6','5','4','3','2');
var
  i, j, S: integer;
  NewID:string;
begin
   if (Length(ID)<>15)and(length(ID)<>17)and(length(ID)<>18) then
      result:= 'ERROR'
   else begin
    NewID:=ID;
    Insert('19', NewID, 7);
    S:= 0;
    try
      for i:=1 to 17 do begin
        j:= StrToInt(NewID[i]) * W[i];
        S:= S + j;
      end;
    except
      result:= '';
      exit;
    end;
    S:= S mod 11;
    insert(uppercase(A[S]),NewID,18);
    Result:=Pchar(NewID);
    end;
end;
当运行第一个函数时,在Edit1中输入1、2、4、5...个汉字都能转换成汉字的首位拼音码,就是不能输入3个汉字,输入3个汉字返回的是空串。运行第二个函数时,输入15位的身份证号码,应该返回18位的新身份证号码,但返回的是16位号码。哪位高手能帮助解决一下(我要在VFP中调用这两个函数,不想用ShareMem单元)。