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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T05:47:56+00:00 2026-06-13T05:47:56+00:00

Is it possible to put some classes into a DLL? I have several custom

  • 0

Is it possible to put some classes into a DLL?

I have several custom classes in a project I am working on and would like to have them put in a DLL and then accessed in the main application when needed, plus if they are in a DLL I can reuse these classes in other projects if I need to.

I found this link: http://www.delphipages.com/forum/showthread.php?t=84394 which discusses accessing classes in a DLL and it mentions delegating to a class-type property but I could not find any further information on this in the Delphi help or online.

Is there any reason I should not put classes in a DLL, and if it is ok is there a better way of doing it then in the example from the link above?

Thanks

  • 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-13T05:47:58+00:00Added an answer on June 13, 2026 at 5:47 am

    It is not possible to get a Class/Instance from a DLL.
    Instead of the class you can hand over an interface to the class.
    Below you find a simple example

    // The Interface-Deklaration for Main and DLL
    unit StringFunctions_IntfU;
    
    interface
    
    type
      IStringFunctions = interface
        ['{240B567B-E619-48E4-8CDA-F6A722F44A71}']
        function CopyStr( const AStr : WideString; Index, Count : Integer ) : WideString;
      end;
    
    implementation
    
    end.
    

    The simple DLL

    library StringFunctions;
    
    uses
      StringFunctions_IntfU; // use Interface-Deklaration
    
    {$R *.res}
    
    type
      TStringFunctions = class( TInterfacedObject, IStringFunctions )
      protected
        function CopyStr( const AStr : WideString; Index : Integer; Count : Integer ) : WideString;
      end;
    
      { TStringFunctions }
    
    function TStringFunctions.CopyStr( const AStr : WideString; Index, Count : Integer ) : WideString;
    begin
      Result := Copy( AStr, Index, Count );
    end;
    
    function GetStringFunctions : IStringFunctions; stdcall; export;
    begin
      Result := TStringFunctions.Create;
    end;
    
    exports
      GetStringFunctions;
    
    begin
    end.
    

    And now the simple Main Program

    uses
      StringFunctions_IntfU;  // use Interface-Deklaration
    
    // Static link to external function
    function GetStringFunctions : IStringFunctions; stdcall; external 'StringFunctions.dll' name 'GetStringFunctions';
    
    procedure TMainView.Button1Click( Sender : TObject );
    begin
      Label1.Caption := GetStringFunctions.CopyStr( Edit1.Text, 1, 5 );
    end;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi guy it's possible put in the application Badge some letter? Something like ON
I have several android constructs like custom dialog boxes, drag-and-drop implementations, and other standard
I have some POCO classes which can generally divided into two groups, for example:
I would like to put some code in module that throws an error if
I am working on a lab and need some assistance if possible. I have
Would it be possible to put install THG on a shared drive and let
Is it possible to put a macro in a macro in c++? Something like:
In C++/CLI it is not possible to put pointers to native C++ classes in
Possible Duplicate: How many Python classes should I put in one file? Coming from
i have 2 classes. class1 gets some information through the net. when one of

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.