Re: exporting classes in a DLL



The class declaration header file should look something like this :-

#ifdef EXPORTSCLASS
#define EXPORTCLASS_API __declspec(dllexport)
#else
#define EXPORTCLASS_API __declspec(dllimport)
#endif

class EXPORTCLASS_API CMyClass
{
public:
//...
};

When you use this in the DLL project, define EXPORTSCLASS, but refrain from
doing so in the EXE project where you call this dll.

--
Regards,
Nish [VC++ MVP]
http://www.voidnish.com
http://blog.voidnish.com


"Alfonso Morra" <sweet-science@xxxxxxxxxxxx> wrote in message
news:dbij8j$km8$1@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
>
>
> Rodrigo Corral [MVP] wrote:
>
>> // in your header...
>>
>> class __declspec(dllexport) CDllTest
>> {
>> public:
>> CDllTest(){}
>> ~CDllTest(){}
>>
>> public:
>> void SayHello();
>> };
>>
>> // in your cpp...
>>
>> void CDllTest::SayHello()
>> {
>> printf(_T("Hello World!!"));
>> }
>>
>> Another option: if you create a new dll project using VS it will create
>> an example dummy exported class.
>>
>>
>
> Thanks - but that's on the exporting side of things. I wanted to know how
> to use the exported classes in a seperate project that imports the classes
> and uses them. The code you gave above, only shows how to export the
> classes (which I already know how to do).
>
> mtia
>


.