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

  • SEARCH
  • Home
  • 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 6099165
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T13:14:30+00:00 2026-05-23T13:14:30+00:00

My DLL might send more than one result/return value to exe in one shoot.

  • 0

My DLL might send more than one result/return value to exe in one shoot. I still don’t understand how to make the callback function so DLL can communicate with host app.

Here’s the scenario :

App :

type
  TCheckFile = function(const Filename, var Info, Status: string): Boolean; stdcall;

var
  CheckFile: TCheckFile;
  DLLHandle: THandle;

Procedure Test;
var
Info,Status : string;
begin
....
// load the DLL 
DLLHandle := LoadLibrary('test.dll');
    if DLLHandle <> 0 then
    begin
      @CheckFile := GetProcAddress(DLLHandle, 'CheckFile');
      if Assigned(CheckFile) then
        beep
      else
        exit;
    end;

// use the function from DLL
if Assigned(CheckFile) then
  begin
    if CheckFile(Filename, Info, Status) then
    begin
    AddtoListView(Filename, Info, Status);
    end;
  end;
...
end;

DLL:

function CheckFile(const Filename, var Info,Status: string): Boolean; stdcall;
  var
    Info, Status: string;
  begin   
    if IsTheRightFile(Filename, Info,Status) then
    begin
      result := true;
      exit;
    end
    else
    begin
      if IsZipFile then
      begin
        // call function to extract the file
        ExtractZip(Filaname);
        // check all extracted file
        for i := 0 to ExtractedFileList.count do
        begin
          IsTheRightFile(ExtractedFile, Info, Status) then
          // how to send the Filename, Info and Status to exe ?? // << edited
          // SendIpcMessage('checkengine', pchar('◦test'), length('◦test') * SizeOf(char)); error!
          // "AddtoListView(Filename, Info);" ???
        end;
      end;
    end;
  end;

Actually I still get an error from code above. So in my case, I need your help to explain and determine what is the correct way to send data from DLL to appp.

  • 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-23T13:14:30+00:00Added an answer on May 23, 2026 at 1:14 pm

    You are on the right lines but the most obvious problem that I can see is the use of string variables. These are heap allocated and since you have two separate memory managers you will be allocating on one heap (in the DLL) and then freeing on a different heap (in the app).

    There are a few options. One options would be to share memory managers but I don’t recommend this for a variety of reasons. Without going into them you state in a comment that you want non Delphi applications to be able to use your DLL which would preclude the use of a shared memory manager.

    Another option would be to force the calling app to allocate the memory for the string and then let your DLL copy into that memory. This works fine but is somewhat labour intensive.

    Instead I would use a string type which can be allocated in one module but freed in a different module. The COM BSTR is such a type and in Delphi terms this is WideString. Change the code to use WideString for any exported functions.


    I would also simplify the importing/exporting process and use implicit dynamic linking.

    DLL

    function CheckFile(
      const Filename: WideString; 
      var Info, Status: WideString
    ): Boolean; stdcall;
    

    App

    function CheckFile(
      const Filename: WideString; 
      var Info, Status: WideString
    ): Boolean; stdcall; external 'test.dll';
    
    procedure Test(const FileName: string);
    var
      Info, Status: WideString;
    begin
      if CheckFile(Filename, Info, Status) then
        AddtoListView(Filename, Info);
    end;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Why might my GetRawData declared function return a correct value when called from my
This might be more of a CYGWIN question than a Nodejs but here goes.
Right, initially ran: c:\regsvr32 Amazing.dll then, (accidentally - I might add) I must have
// dll #include <memory> __declspec(dllexport) std::auto_ptr<int> get(); __declspec(dllexport) std::auto_ptr<int> get() { return std::auto_ptr<int>(new int());
The requirement of the TCP server: receive from each client and send result back
This might be a stupid question but how to update System.Web.Mvc dll which is
I could make a dll for NUnit NUnit test under mono , but when
I have a DLL (Test.dll) which contains some Excel Addin, i don't know which
This DLL is added by default in Visual Studio 2010 projects. What is this
I have a C++ dll (specifically a directshow filter) which is being used in

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.