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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T03:07:52+00:00 2026-06-14T03:07:52+00:00

in mine project i have a Windows application and a dll. I have wrote

  • 0

in mine project i have a Windows application and a dll. I have wrote dll so:

library MyDLL;

uses
  System.SysUtils,
  System.Classes;

{$R *.res}

function Prova: string; export;
begin
  result := 'prova';
end;

exports Prova;

begin
end.

and in main program i have called routine so:

unit FrmMain;

interface

uses
 // declaration uses // 

function Prova: string; external 'MyDLL.dll';

type    
 // declaration type //

implementation

begin
  ...
  TAdvEdit1.Text := Prova;  // [1] // 
  ...
end;

end.

When i compile all project not is reported error, and status report SUCCESS, but application not start.
If i remove the line [1] then it works correctly. In general, application not start when i call the function Prova.
What i can solve this problem? Thanks very much.

  • 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-14T03:07:53+00:00Added an answer on June 14, 2026 at 3:07 am

    Your program and your DLL have separate memory manager. As a general rule memory allocated from DLL should not be used inside your application (the opposite is also true).
    Where the allocation comes from? In Delphi “string” is managed type i.e. when you assign some text to a string variable (in your case result := ‘prova’), Delphi (behind the scene) allocates memory for that string using DLL’s memory manager. Then, for example, if you assign other text value within your main application, the reallocation uses application’s memory manager which is bad i.e. app’s MM is touching memory that it hasn’t allocated itself.

    To solve this issue you have to include “SimpleShareMem” (Delphi >= 2010 IIRC?) unit as the first unit of your USES clause in the application (.dpr file) AND in the DLL:

    library MyDLL;
    
    uses
      SimpleShareMem, // **MUST BE THE FIRST UNIT**
      System.SysUtils,
      System.Classes;
    ...
    
    
    program YourApp;
    
    uses
      SimpleShareMem, // **MUST BE THE FIRST UNIT**
      // declaration uses // 
    

    An example of this approach can be found in “Start > Programs > Embarcadero RAD Studio > Samples > Delphi > RTL > SimpleShareMem“

    You can also use PCHAR to transfers strings between DLL and the APP.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an application that uses currently two DLL's for external libraries (AjaxControlToolkit is
Developing a project of mine I realize I have a need for some level
The idea behind this small project of mine is to have an user enter
Let's say I have one project with the following POM: <groupId>com.mine</groupId> <artifactId>coreJar</artifactId> <packaging>jar</packaging> <version>0.0.1-SNAPSHOT</version>
I'm using qmake for building a project of mine. I have been trying to
I have implemented the Unity DI in a project of mine, but I have,
I have an automation project having a remote database (MsSql) and multiple windows/web clients.
I have a multi-threaded application, I'm using pthreads with the pthread_mutex_lock function. The only
I'm writing a 3D graphics library as part of a project of mine, and
So I have this small application of mine I'm trying to deploy using visual

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.