🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #10246

Re: Creating multiple instances a class exported from a dynamically loaded DLL ?

#10246
From: Lib
Date: Fri, 07 May 2004 15:27
62 lines
2342 bytes
See also
 http://www.garretfoster.com/projects/plugins/plugins.pdf

<Tian> wrote in message news:408fb46a$1@newsgroups.borland.com...
> In my application how can I create MULTIPLE instances of a class exported
> from a DYNAMICALLY loaded (not adding the MyDLL.lib to the project) DLL ?
>
>
> // MyDLL.h
> ============
> #ifdef __dll__
>    #define IMPEXP __declspec(dllexport)
> #else
>    #define IMPEXP __declspec(dllimport)
> #endif  // #ifdef __dll__
>
> class IMPEXP __stdcall TMyClass
> {
> public:
>   TMyClass();
>   ~TMyClass();
>   void AMemberFunction(int a, int b);
> };
>
> // MyDLL.cpp
> ===========
> #define __dll__
> #include "MyDLL.h"
>
> #pragma argsused
> int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void*
> lpReserved)
> {
>         return 1;
> }
>
> TMyClass::TMyClass() { }
> TMyClass::~TMyClass() { }
> void TMyClass::AMemberFunction(int a, int b) { /*Do something*/}
>
>
> // MyApplication.cpp
> ==================
> #include <MyDLL.h>
>
> void __fastcall TForm1::Button1Click(TObject *Sender)
> {
>      TMyClass *A;
>      TMyClass *B;
>      TMyClass *C;
>      HINSTANCE DLLHnd = NULL;
>      DLLHnd = LoadLibrary("MyDLL.dll");
>      if (DLLHnd != NULL) {
>         What to do now?
>         How to create multiple instances A,B,C of TMyClass ?
>      }
>
>   FreeLibrary(DLLHnd);
>   DLLHnd = NULL;
> }
>
>
Technical Details
Message-ID: <409baad1$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!controlnews3.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <408fb46a$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,16595e758f137c2d
X-Google-Attributes: gid10cc67,public
From: <Lib>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <408fb46a$1@newsgroups.borland.com>
Subject: Re: Creating multiple instances a class exported from a dynamically loaded DLL ?
Date: Sat, 8 May 2004 01:27:11 +1000
Lines: 64
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1409
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409
NNTP-Posting-Host: 211.30.68.31
Message-ID: <409baad1$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1083943633 211.30.68.31 (7 May 2004 08:27:13 -0700)
Path: arc1-ca.pugleaf.net!controlnews3.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail