Note that there are some explanatory texts on larger screens.

plurals
  1. POUsing C dll in delphi return nothing
    primarykey
    data
    text
    <p>I have been trying to reuse a C dll file in delphi based on this <a href="http://maxdb.sap.com/documentation/sqldbc/SQLDBC_API/SQLDBC__C_8h.html#a252" rel="nofollow noreferrer">documentation</a>. </p> <p>Server was running well, i could access and used the database on local server with java and php.</p> <p>On delphi i used dynamic load and worked well on all functions that return variables but failed on those that return interface.</p> <pre><code>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&gt;=23 then begin @getSDKVersion:=GetProcAddress(libhandle,'getSDKVersion'); @ClientRuntime_GetClientRuntime:= GetProcAddress(libhandle,'ClientRuntime_GetClientRuntime'); end; end; initialization begin initLibrary; end; finalization begin if libhandle&gt;=32 then FreeLibrary(libhandle); end; end. </code></pre> <p>here is the test procedure :</p> <pre><code>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; </code></pre> <p>I've read the similar problems asked by <a href="https://stackoverflow.com/questions/2266417/delphi-calling-a-function-from-a-vc-dll-that-exports-a-interface-class">geskill</a>, <a href="https://stackoverflow.com/questions/6629852/delphi-interface-from-dll">Dan Hacker</a>, <a href="https://stackoverflow.com/questions/8846545/is-it-safe-to-use-interfaces-from-dll">max</a> and <a href="https://stackoverflow.com/questions/4798283/calling-dlls-with-pointers-in-delphi">Ron</a> but it could not solve my problem.</p> <p>Could anyone told me what's wrong here?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload