Article View: borland.public.cppbuilder.nativeapi
Article #10413Creating multiple instances a class exported from a dynamically loaded DLL ?
From: Tian
Date: Wed, 28 Apr 2004 13:40
Date: Wed, 28 Apr 2004 13:40
56 lines
2068 bytes
2068 bytes
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:
<408fb46a$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!news.glorb.com!npeer.de.kpn-eurorings.net!feed.news.schlund.de!schlund.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10cc67,16595e758f137c2d,start X-Google-Attributes: gid10cc67,public X-Google-ArrivalTime: 2004-04-28 07:10:19 PST From: <Tian> Newsgroups: borland.public.cppbuilder.nativeapi Subject: Creating multiple instances a class exported from a dynamically loaded DLL ? Date: Wed, 28 Apr 2004 23:40:54 +1000 Lines: 58 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: <408fb46a$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1083159658 211.30.68.31 (28 Apr 2004 06:40:58 -0700) Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!news.glorb.com!npeer.de.kpn-eurorings.net!feed.news.schlund.de!schlund.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail