DLLs

I am programming a C++ game with Dev-C++. I am using DLLs. I easily made a DLL, but I can't include it in my main .exe file. How can I do this.

DLL1.dll code

dllmain.cpp:

/* Replace "dll.h" with the name of your header */
#include "dll.h"
#include
#include

DLL1::DLL1()
{

}


DLL1::~DLL1 ()
{

}


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;
}
char* DLL1(char* DLLIN /*Dynamic Linked Library Identification Number*/)
{
return "No program installed. Please install/reinstall.";
}

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 DLL1
{
public:
DLL1();
virtual ~DLL1(void);

private:

};


#endif /* _DLL_H_ */

Any help appriciated,
Theron

Comments

  • When you compile a dll, the compiler creates a *.lib and *.dll file. You normally will link the applicaiton program with the *.lib, just like any other dll that is installed with your compiler. You have to create your own *.h file that will expost the exported functions to your application program.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion