Tech Support > Microsoft Windows > Development Resources > Win32 DLL project: About Classes & Objects?
Win32 DLL project: About Classes & Objects?
Posted by deostroll on December 17th, 2007


I use devcpp 4.9.9.2. I've never had any experience creating dlls
before. Whenever I start a dll project I have a basic template built
there (in the header file) which goes like:
----dll.h----
#ifndef _DLL_H_
#define _DLL_H_

#if BUILDING_DLL
# define DLLIMPORT __declspec (dllexport)
#else /* Not BUILDING_DLL */
# define DLLIMPORT __declspec (dllimport)
#endif /* Not BUILDING_DLL */


class DLLIMPORT DllClass
{
public:
DllClass();
virtual ~DllClass(void);

private:

};


#endif /* _DLL_H_ */
----

Why do I have a class template there as such? Can I export this class?
Can I use this class in another program that references this dll? If
so how?

And in the cpp file I have the following code:
----dllmain.cpp----
/* Replace "dll.h" with the name of your header */
#include "dll.h"
#include <windows.h>

DllClass:llClass()
{

}


DllClass::~DllClass ()
{

}


BOOL APIENTRY DllMain (HINSTANCE hInst /* Library instance handle.
*/ ,
DWORD reason /* Reason this function is
being called. */ ,
LPVOID reserved /* Not used. */ )
{
switch (reason)
{
case DLL_PROCESS_ATTACH:
break;

case DLL_PROCESS_DETACH:
break;

case DLL_THREAD_ATTACH:
break;

case DLL_THREAD_DETACH:
break;
}

/* Returns TRUE on success, FALSE on failure */
return TRUE;
}
----

What is the role of DllMain()? How to use those switches?

--deostroll

Posted by alfred on December 19th, 2007


deostroll wrote:

It is already exported by __declspec (dllexport)
See Msdn for everything about dlls

Posted by deostroll on December 19th, 2007


On Dec 19, 1:08 pm, alfred <alf...@opm.com> wrote:
How do I use the class as such in my program?
-deostroll


Similar Posts