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 7991227
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T13:13:59+00:00 2026-06-04T13:13:59+00:00

In a Delphi program I’m using a DLL to control an external executable. The

  • 0

In a Delphi program I’m using a DLL to control an external executable.
The DLL is written in Visual C++.
In C++ the code to use DLL is:

// defining pointer's type to a function compatible with 'launcher' function:
typedef int (WINAPI* PFI_HD_ST_N)(HDC, LPCSTR, int);
…
…
HINSTANCE m_hiDLLCTRL;  // handle to DLL instance
PFI_HD_ST_N pfStart;    // pointer to function that starts external program

// initialization
m_hiDLLCTRL = NULL;
pfStart = NULL;

// links DLL dynamically
m_hiDLLCTRL = LoadLibrary(“ExtProgCTRL.dll”);

// if DLL has been loaded
If (m_hiDLLCTRL)
    // I get the address to funcion that launches ExtProg
    pfStart = ( PFI_HD_ST_N) GetProcAddress( m_hiDLLCTRL, “ExtProgStart” );
// launches external program
If ( pfStart )
    // hWnd is handle to window where I want do draw 
    pfStart -> ( GetDC ( hWnd ), “C:\\Programs\\ExtProg”, 1 ); 

I have an equivalent code in Delphi:

private
    DLLHandle: THandle;
    XInt: function: Integer: cdecl;

...
implementation
...
...
DLLHandle := LoadLibrary('ExtProgCTRL.dll');
if DLLHandle <> 0 then
begin
    @XInt := GetProcAddress(DLLHandle, ''ExtProgStart);
    if @XInt <> nil then
    begin
        MessageDlg('Function ExtProgStart loaded !', mtError, mbOKCancel, 0);
        ...
        ...
    end;
end;

It seems to work correctly, but I’m not able to find the Delphi code for the last instruction, to launch external program…

pfStart -> ( GetDC ( hWnd ), “C:\\Programs\\ExtProg”, 1 );

what in Delphi ?

I have changed:

private
    DLLHandle: THandle;
    XInt: function(DC: HDC; Text: PAnsiChar; SomeInt: Integer); Integer: cdecl;

...
implementation
...
retval: Integer;

DLLHandle := LoadLibrary('ExtProgCTRL.dll');
if DLLHandle <> 0 then
begin
    @XInt := GetProcAddress(DLLHandle, ''ExtProgStart);
    if @XInt <> nil then
    begin
        MessageDlg('Function ExtProgStart loaded !', mtError, mbOKCancel, 0);
       retval := XInt(GetDC(hWnd), 'C:\Programs\ExtProg', 1);
    end;
end;

but now I have on last instruction : retval := XInt… the following error:
DCC Error : ‘(‘ expected but ‘)’ found (parenthesis after hWnd)

  • 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-06-04T13:14:00+00:00Added an answer on June 4, 2026 at 1:14 pm

    You need to declare XInt like this:

    XInt: function(DC: HDC; Text: PAnsiChar; SomeInt: Integer): Integer; stdcall;
    
    1. You need to declare a parameter list that matches the definition in the C++ code.
    2. I don’t know meaningful names for the parameters but I’m sure you can supply them.
    3. The C++ code specifies the WINAPI calling convention which matches stdcall in Delphi.

    And then you can call it like this:

    retval := XInt(GetDC(hWnd), 'C:\Programs\ExtProg', 1);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've written a Delphi DLL that communicates with a third party program via COM.
Consider the following example (I am using Delphi XE): program Test; {$APPTYPE CONSOLE} type
I was looking into using some .NET code from within a Delphi program, I
I'm using a C dll in a Delphi XE2 program without problem. One of
I have a program written in Delphi XE that plays a WAV file using
I am writing a program using Delphi 2006 and storing data in XML files
Two Delphi programs need to load foo.dll, which contains some code that injects a
How can I use MS Access as a back-end database for a Delphi program?
I am trying to use a C++ dll from a native program. I am
Is there parser code or a parser component for Delphi or a program that

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.