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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T02:52:16+00:00 2026-05-14T02:52:16+00:00

I followed an excellent article by Rudy Velthuis about using C++ classes in DLL’s.

  • 0

I followed an excellent article by Rudy Velthuis about using C++ classes in DLL’s. Everything was golden, except that I need access to some classes that do not have corresponding factories in the C++ DLL. How can I construct an instance of a class in the DLL? The classes in question are defined as

class __declspec(dllexport) exampleClass
{
public:
  void foo();
};

Now without a factory, I have no clear way of instantiating the class, but I know it can be done, as I have seen SWIG scripts (.i files) that make these classes available to Python. If Python&SWIG can do it, then I presume/hope there is some way to make it happen in Delphi too.

Now I don’t know much about SWIG, but it seems like it generates some sort of map for C++ mangled names? Is that anywhere near right? Looking at the exports from the DLL, I suppose I could access functions & constructor/destructor by index or the mangled name directly, but that would be nasty; and would it even work? Even if I can call the constructor, how can I do the equivalent of “new CClass();” in Delphi?

  • 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-14T02:52:16+00:00Added an answer on May 14, 2026 at 2:52 am

    The correct way to do it is to write a wrapper DLL that exposes a factory for the class you need.

    I am not sure hiw SWIG works, but anything that relies on reverse-engineering the name mangling seems a dubious approach.

    Besides a C++ object should be created only in C++ code. You ought to leave the object creation semantics to the C++ runtime.

    There is a reason why COM exists. Precisely to make this cross language object metaphor work neatly.

    I’ve written scores of COM objects that are called from Delphi, python and C#

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

Sidebar

Related Questions

I'm using java 6 annotation processing api. I have followed the following excellent tutorial
Followed this question about delayed_job and monit Its working on my development machine. But
I followed this tutorial: https://github.com/EllisLab/CodeIgniter/wiki/PDF-generation-using-dompdf However, I can't seem to set the path right.
So followed all the basic tutorials. Am using Zend 1.8 but i keep getting
I followed the directions in this post: how can we integrate jquery autocomplete using
Though I've followed the excellent Protocol Buffer documentation and tutorials for C++ and Python,
I followed the excellent post by Nadia here jQuery override default validation error message
i followed this excellent as3 preloader tutorial, and below is the code i have
I followed this code project tutorial for using SharpGL with WPF to create a
This is in reference to this (excellent) answer . He states that the best

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.