我用Delphi7新建一DLL程序,在DLL中使用WIDESTRING作为接收参数使用时一切正常,当时使用PCHAR字符串接收时只能获取传入字符串的第一位,不知道为什么?请高手明示
{当X为PCHAR时,传入的字符串为'12345678901'时,X的值为1
当X为WIDESTRING时一切正常
但是用PCHAR做返回类型时又一切正常}
Function SendCode(x:wideString):pChar;stdcall;
var
  sckt: TSocketConnection;
  code:string;
begin
  try
    sckt := TSocketConnection.Create(nil);
    try
      sckt.Host := '127.0.0.1';
      sckt.ServerName := 'testSuccess.rmdServer';
      sckt.ServerGUID := '{1241D849-206E-4DE1-937F-FC854472C532}';
      sckt.Port := 211;
      sckt.Connected := true;
      code := sckt.AppServer.sendCode(wideString(x));      Result := pchar(code);
    except
      sckt.Connected := false;
    end;
  finally
    sckt.Free;
  end
end;