|
From: James G. <Jam...@Cl...> - 2001-01-12 08:17:05
|
Use something like the following.
#ifdef TST1_EXPORTS
#define TST1_API __declspec(dllexport)
#else
#define TST1_API __declspec(dllimport)
#endif
// This class is exported from the tst1.dll
class TST1_API CTst1 {...};
extern TST1_API int nTst1;
TST1_API int fnTst1(void);
This exports the definition of the class, function or variable so it =
can be
used by a another program.
When you compile the DLL place a #define TST1_EXPORTS before the =
#include of
the .h file, so that it exports the definitions correctly. The users of =
your
DLL will not define it and so will import the definitions in the DLL.
If you use a .def file to specify the ordinal number for the function =
etc.
then when you issue version 2 of the DLL other programs will not have =
to be
recompiled.
If you do not include a .def file then the compiler will give the =
function
an ordinal number and the next version may give it another number. As =
this
number is used to bind the client call to the DLL, if it is different =
it
will fail. By defining the ordinal number yourself you ensure that it =
will
always be the same.
Example from MSVC++
LIBRARY MFC42 ; This is the name of the DLL
EXPORTS
DllGetClassObject @ 1 PRIVATE
DllCanUnloadNow @ 2 PRIVATE
DllRegisterServer @ 3 PRIVATE
DllUnregisterServer @ 4 PRIVATE
; MFC 4.2(final release)
??0_AFX_CHECKLIST_STATE@@QAE@XZ @ 256 NONAME
Unfortunately you also need to find the mangled name of the function to =
put
into the definition file.
This is taken from what I can remember of MSVC++ but I'm sure that it =
is the
same for Dev-C++.
Regards,
James.
-----Original Message-----
From: Jose Manuel Padron Carrillo [mailto:jos...@ya...]
Sent: Friday, January 12, 2001 8:02 AM
To: dev...@li...
Subject: Re: [Dev-C++] Dll export
--- ShadowOz <sha...@da...> escribi=F3: > Hello everybody
>=20
> Here=B4s my question:
>=20
> I=B4m trying to create a simple dll, with function I that want to be
> used by
> other application.
> Q: How can I make those functions acessible to the others
> applications?
>=20
> thx.
>=20
> Ae galera .pt, t=E1 muito frio a=ED? :-)
>=20
>=20
I'm not sure, but you can use the function LoadLibrary() and the call
the function.
At least that is what I use when I want to use InitCommonControls(). I
always load the library before.
Chemanuel=20
http://www.geocities.com/josempadron/
__________________________________________________
Do You Yahoo!?
Yahoo! Photos - Share your holiday photos online!
http://photos.yahoo.com/
_______________________________________________
Dev-cpp-users mailing list
Dev...@li...
http://lists.sourceforge.net/lists/listinfo/dev-cpp-users
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *=20
This electronic message and any attachment is intended to be=20
read by the named addressee(s) only.=20
Any other recipient should be aware that its contents may be=20
legally privileged and/or confidential and that its use,=20
disclosure, copying or distribution may be unlawful.=20
Unless you are a named addressee, please delete this message=20
Whilst C. & J. Clark International Limited has taken steps=20
to prevent the transmission of computer viruses with electronic mail,=20
responsibility for screening incoming messages and the risk of such=20
transmission and its consequences lies with the recipient.=20
C. & J. Clark International Limited=20
Registered in England and Wales=20
Company No. 141015=20
Registered Office: 40 High Street, Street, Somerset BA16 0YA=20
Telephone: +44 (0) 1458 443131=20
Fax: +44 (0) 1458 447547=20
|