Runtime Dynamic linking a Dll for a class defined in dll

Vivek Soni 21 Reputation points
2024-04-15T09:49:59.7233333+00:00

Hi,

I am trying to export a class defined in dll. After following msdn example for exporting a "function" in dll, i compiled and used that code but so far i am clueless about how to export a class defined in dll.

Kindly tell me how we can export a class and use functions inside it by using runtime dynamic linking. If possible guide me to the correct web resource.

thanks...

Vivek

Windows 10
Windows 10
A Microsoft operating system that runs on personal computers and tablets.
10,827 questions
Visual Studio
Visual Studio
A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.
4,711 questions
C++
C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,569 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more

  2. uncle_Kei 0 Reputation points
    2024-04-16T01:29:27.5533333+00:00

    The easiest way to use class member functions exported from the DLL from the EXE side is outlined below.

    (1) Export the class in the DLL and build it.

    Example) ( Test_Class.h ) class EXPORTS_CLASS TEST_CLASS{ void TestFunc(){ ::OutputDebugStringW( L "TEST_CLASS::TestFunc() is call \n")}};
    

    (2)Copy the resulting DLL to the EXE execution environment.

    (3) Refer the completed LIB to the linker of the EXE project.

    (4) In EXE, #include "Test_Class.h", create an instance of TEST_CLASS, and call TestFunc() from that instance.

    (5) Build the EXE.

    Once the above can be done, it is a good idea to start considering how to get the class function of the DLL written in C++ language by GetProcAddress().

    Translated with DeepL.com (free version)

    0 comments No comments