Note that there are some explanatory texts on larger screens.

plurals
  1. POUsing C++ DLL in D10
    text
    copied!<p>I use a C++ DLL in my app.</p> <pre><code>type Tcl_bla = function(filename: PChar): Integer; cdecl; var cl_bla: Tcl_bla; function CallLibraryProc(Proc: String): Pointer; begin Result := GetProcAddress(Handle, PChar(Proc)); if not Assigned(Result) then Loaded := False; if not Loaded then MessageBox(0, PChar('Error =&gt; ' + Proc), 'Alert', MB_OK or MB_TOPMOST); end; ... Handle := SafeLoadLibrary( PChar(CurrentPath + Dll), SEM_FAILCRITICALERRORS or SEM_NOGPFAULTERRORBOX or SEM_NOOPENFILEERRORBOX ); if (Handle &lt; HINSTANCE_ERROR) then raise Exception.Create( Dll + ' library can not be loaded or not found.' + SysErrorMessage(GetLastError) ); if Handle &lt;&gt; 0 then begin // blabla cl_bla := CallLibraryProc('cl_bla'); end; ... FreeLibrary(Handle); </code></pre> <p>The codes aboves works fine with D6. I'm trying to port my code so it can run in Delphi with Unicode support but I have a trouble.</p> <p>I've read the documentation from Embarcadero about GetProcAddress </p> <pre><code>procedure CallLibraryProc(const LibraryName, ProcName: string); var Handle: THandle; RegisterProc: function: HResult stdcall; begin Handle := LoadOleControlLibrary(LibraryName, True); @RegisterProc := GetProcAddress(Handle, PAnsiChar(AnsiString(ProcName))); end; </code></pre> <p>I can't try this because I don't know how to declare LoadOleControlLibrary!</p> <p>My CallLibraryProc can load the DLL but somehow cl_bla works incorrectly.</p> <p>I think the problem with my code because of GetProcAddress's parameter or.. maybe my ported header is wrong.</p>
 

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