delphi调用tuxedo源码转为C#,无法正常调用
delphi代码:
var
Form1: TForm1;
vstr:string;
LIntRecv: integer; //tp执行情况
sendChaine, getChaine: pChar;
sendLentgh: integer;
i:integer;
TmpLg: Longint;
pChServiceName: pChar;
bufferType: string;
strSerName, strParam: string;
strResult: string;
vRetData:string;
implementation
function tpinit(tpinfo: longint): integer; stdcall; external 'c:\tux\wtuxws32.dll' name 'tpinit';
function tpterm: integer; stdcall; external 'c:\tux\wtuxws32.dll' name 'tpterm';
procedure tpfree(ptr: pchar); stdcall; external 'c:\tux\wtuxws32.dll' name 'tpfree';
function tpalloc(types: pChar; subtype: pchar; size: longint): pchar; stdcall; external 'c:\tux\wtuxws32.dll' name 'tpalloc';
function tpcall(svc: pChar; idata: pchar; ilen: longint; odata: pointer; olen: pointer; flags: longint): integer; stdcall;
external 'c:\tux\wtuxws32.dll' name 'tpcall';
function gettperrno(): integer; stdcall; external 'c:\tux\wtuxws32.dll' name 'gettperrno';
function tpstrerror(errno: integer): string; stdcall; external 'c:\tux\wtuxws32.dll' name 'tpstrerror';
function tuxputenv(ptr: pchar): integer; stdcall; external 'c:\tux\wtuxws32.dll' name 'tuxputenv';
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
begin
{***"wtuxws32.dll"TUXEDO的DLL,Delphi调用其函数,本段可以包含在公共的模块里面***}
begin
tuxputenv(pchar('WSNADDR=' + '//100.155.19.55:5120')); //设置中间件服务器地址
try
i:=tpinit(0); // 初始化(必须)
except
Tpterm; //异常结束
end;
strSerName:='SQLSERV_S_DS';
strParam:='select * from res.t_rs_gsmnum_a where svcnum=''AA''' ;
bufferType := 'STRING'; //调用的是STRING格式在CLIENT和SERVER传送数据
pChServiceName := stralloc(80); // 用于存放SERVICE名(不需要修改)
strpcopy(pChServiceName, bufferType); // 类型转化
sendLentgh := 1024 * 1024; //缓冲区大小可修改
//getLength := 0;
sendChaine := tpalloc(pChServiceName, nil, sendLentgh); // 向中间层申请的缓冲区,发送
getChaine := tpalloc(pChServiceName, nil,0); // 向中间层申请的缓冲区,接收
strpcopy(sendChaine, strParam); // 类型转化
strpCopy(pChServiceName, strSerName); // 类型转化
// 参数内容:发送的格式,放回的串类容,0,接收地址,返回的长度,0;
LIntRecv := tpcall(pChServiceName, sendChaine, 0, @getChaine, @tmplg, 0); //函数调用(反馈错误为912)