このドキュメントに基づいて、デルファイでC dllファイルを再利用しようとしています。
サーバーは正常に動作していました。Java と php を使用して、ローカル サーバー上のデータベースにアクセスして使用することができました。
Delphiでは、動的ロードを使用し、変数を返すすべての関数でうまく機能しましたが、インターフェイスを返す関数では失敗しました。
unit for library :
unit SQLDBC_C;
interface
uses windows, classes, sysutils;
type
SQLDBC_IRuntime = interface
end;
var
getSDKVersion : function :Pchar; stdcall;
ClientRuntime_GetClientRuntime: function (errorText:Pchar; errorTextSize:Integer) : SQLDBC_IRuntime; stdcall;
implementation
var
libhandle : THandle;
procedure initLibrary;
begin
libhandle := LoadLibrary('libSQLDBC_C.dll');
if libhandle>=23 then begin
@getSDKVersion:=GetProcAddress(libhandle,'getSDKVersion');
@ClientRuntime_GetClientRuntime:=
GetProcAddress(libhandle,'ClientRuntime_GetClientRuntime');
end;
end;
initialization
begin
initLibrary;
end;
finalization
begin
if libhandle>=32 then
FreeLibrary(libhandle);
end;
end.
テスト手順は次のとおりです。
procedure TForm1.Button1Click(Sender: TObject);
var
err : array [0..200] of char;
rt : SQLDBC_IRuntime;
begin
Memo1.Clear;
FillChar(err, sizeof(err), 0);
Memo1.Lines.Add(getSDKVersion); //this function successed
rt := ClientRuntime_GetClientRuntime(@err,200);
//this function had no return value, (rt always nil) but no error return at err variable
if assigned(rt) then begin
......
end;
end;
geskill、Dan Hacker、max、およびRonによって尋ねられた同様の問題を読みましたが、私の問題を解決できませんでした。
ここで何が悪いのか誰か教えてもらえますか?