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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T14:01:14+00:00 2026-06-18T14:01:14+00:00

I am in front of following problem: My Main programming Language is C++ with

  • 0

I am in front of following problem:

My Main programming Language is C++ with the Qt4 Library, but now I have to write a Pascal Wrapper, which should give the possibility to use the functions of a C DLL in Pascal.
Now I want to make it possible to invoke a method from any Pointer. But I can’t find a Pascal method to invoke a method. I want something like the QMetaObject::invokeMethod method in QT. I got following code:

unit CgPConnect;

//{$mode objfpc}{$H+}
{$mode delphi}

interface

    uses
        Classes, SysUtils, dynlibs;

    type

        Callback = Record
          var callbackObject: Pointer;
          var objectFunction: string;
        end;

        CallbackObject = Record
          var objectName: string;
          var callback: Callback;
        end;

        MutableObject = Object
          var name: string;
          var state: string;
          var properties: array of VariantMap;
          var annotations: array of VariantMap;
        end;



        PConnect = Class
            constructor create(connectorPath: string);
            destructor destroy;

            private
                var hostactionCallbacks: array of CallbackObject;
                var mConnectorPath: string;
                var mConnectorLibrary: TLibHandle;
                function loadConnectorLibrary: Boolean;

            public
                procedure registerCallbackForHostaction(objectName, objectFunction: string; callbackObject: pointer);
                procedure callHostactionCallback(receivedObject :MutableObject);

                var mLibraryLoaded: Boolean;
        end;

    implementation

    constructor PConnect.create(connectorPath: string);
    begin
        mConnectorPath:= connectorPath;
        mLibraryLoaded:= false;
        //Eventuell noch slash hinzufügen
        mLibraryLoaded:= loadConnectorLibrary;
    end;

    destructor PConnect.destroy;
    begin
        UnloadLibrary(mConnectorLibrary);
    end;

    procedure PConnect.registerCallbackForHostaction(objectName, objectFunction: string; callbackObject: pointer);
    var c: Callback;
    var callbackCount: integer;
    begin
        if mLibraryLoaded = true then
        begin
            c.callbackObject:= callbackObject;
            c.objectFunction:= objectFunction;
            callbackCount:= Length(hostactionCallbacks)+1;
            SetLength(hostactionCallbacks, callbackCount);
            hostactionCallbacks[callbackCount].objectName:= objectName;
            hostactionCallbacks[callbackCount].callback:= c;
        end;
    end;

    procedure PConnect.callHostactionCallback(receivedObject :MutableObject);
    var receivedObjectName, objectFunction: string;
    var i, count: integer;
    var callbackObject: pointer;
    begin
        if mLibraryLoaded = true then
        begin
            receivedObjectName:= receivedObject.name;
            count:= Length(hostactionCallbacks);
            for i:=0 to count do
            begin
                if hostactionCallbacks[i].objectName = receivedObjectName
                begin
                    objectFunction:= hostactionCallbacks[i].callback.objectFunction;
                    callbackObject:= hostactionCallbacks[i].callback.callbackObject;
                    if callbackObject <> 0 then
                        //INVOKE METHOD (objectFunction) OF OBJECT (callbackObject)
                end;
            end;
        end;
    end;
end.

I would be happy about a fast answer 🙂

  • 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-18T14:01:15+00:00Added an answer on June 18, 2026 at 2:01 pm

    You cannot directly and portably call a C++ method from Pascal. If your callbackfunction is a C++ object, forget it.

    Otherwise fill a TMethod object and cast that to the proper “procedure of object” declaration. Don’t forget the calling convention.

    For more bizarre solutions you might want to have a look at (RemObjects’) Pascalscript.

    P.s. this is the same that you can’t even call a C++ method reliably from another C++ compiler. It is not Pascal vs C++ per se.

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

Sidebar

Related Questions

I have the following problem in a Database using Access 2007 as front end
I have the following problem. Maybe the design isn't that good, but I couldn't
I have following problem: in my layout xml I have relative layout in which
I have the following code in the front end <asp:Content ID=Content1 ContentPlaceHolderID=cphMain runat=server> <script
On my front end, I have following functions: method to encrypt: public static string
We have a Zend application that has these following modules: Users Shop etc... Front
I have a problem whereby I have set the body font-size to 11px, but
I can't figure out how to deal with a following problem. I have a
I've created an app but I have a problem with my JLabels not showing
Have the following problem. In slightly customized version of twentyeleven I can't make display

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.