Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4001886
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T07:57:32+00:00 2026-05-20T07:57:32+00:00

I use a C++ DLL in my app. type Tcl_bla = function(filename: PChar): Integer;

  • 0

I use a C++ DLL in my app.

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 => ' + Proc), 'Alert', MB_OK or MB_TOPMOST);
end;
...    
Handle := SafeLoadLibrary(
  PChar(CurrentPath + Dll),
  SEM_FAILCRITICALERRORS or SEM_NOGPFAULTERRORBOX or SEM_NOOPENFILEERRORBOX
);
if (Handle < HINSTANCE_ERROR) then
  raise Exception.Create(
    Dll + ' library can not be loaded or not found.' + SysErrorMessage(GetLastError)
  );
if Handle <> 0 then
begin
  // blabla  
  cl_bla := CallLibraryProc('cl_bla');
end;
...    
FreeLibrary(Handle);

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.

I’ve read the documentation from Embarcadero about GetProcAddress

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;

I can’t try this because I don’t know how to declare LoadOleControlLibrary!

My CallLibraryProc can load the DLL but somehow cl_bla works incorrectly.

I think the problem with my code because of GetProcAddress’s parameter or.. maybe my ported header is wrong.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T07:57:33+00:00Added an answer on May 20, 2026 at 7:57 am

    I may as well post this this as an answer, because it seems like the answer!

    The code that you say is D6 code will work fine unmodified in D2010, and have the same meaning. There are two GetProcAddress overloads in Windows.pas. One of them converts from Unicode to ANSI. So you can just call GetProcAddress(Handle, PChar(Proc)) just like you always did.

    The magic one looks like this:

    function GetProcAddress(hModule: HMODULE; lpProcName: LPCWSTR): FARPROC;
    begin
      if ULONG_PTR(lpProcName) shr 16 = 0 then // IS_INTRESOURCE
        Result := GetProcAddress(hModule, LPCSTR(lpProcName))
      else
        Result := GetProcAddress(hModule, LPCSTR(AnsiString(lpProcName)));
    end;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to use LabVIEW's Call Library Function Node to access a DLL function,
I'm trying to use a MFC Dll in my C# app. It basically is
I need to use a dll in my asp.net application. How do I load
What is the easiest way to use a DLL file from within Python ?
Is it possible to use a .NET DLL in Delphi 2007 for Win32? I've
Is there a way to use (reference) a DLL written in an unmanaged C++
From some old c++ code im trying to use a com dll, it works
I am trying to use a third party DLL that wants an int** as
I tried to use this on my class library mylib.core.data.dll and got a successful
I want to build a DLL Class Library use COM Interop, with C#, target

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.