🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

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

#10230
From: Lib
Date: Thu, 06 May 2004 13:38
62 lines
2381 bytes
The following link may be the closesest (not exact) answer to the question
http://community.borland.com/article/print/0,1772,20165,00.html

<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: <409a3fdb$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!controlnews3.google.com!news1.google.com!news.glorb.com!npeer.de.kpn-eurorings.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: Thu, 6 May 2004 23:38:35 +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: <409a3fdb$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1083850715 211.30.68.31 (6 May 2004 06:38:35 -0700)
Path: arc1-ca.pugleaf.net!controlnews3.google.com!news1.google.com!news.glorb.com!npeer.de.kpn-eurorings.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail