You still need to tell the compiler which functions to export from the DLL. This can be done in 2 ways, the __dllimport/__dllexport or through a DEF file, I use DEF files always because it lets me define the ordinal numbers of those functions myself, meaning, if I update the DLL by adding new functions, the EXE's need not to be recompiled. A good practice!<br>
<br>
OK, lets write this down.. I think you know how to create a Win32 DLL project, so here are the files to add.<br>
<br>
First of all here's the H file:<br>
//----------------------------------------------------------------------------<br>
// fight.h<br>
#if !defined( INC_FIGHT )<br>
#define INC_FIGHT<br>
<br>
#if defined( __cplusplus )<br>
extern "C" {<br>
#endif // __cplusplus<br>
<br>
int WINAPI hitval(int level, int str, int agi, int opagi);<br>
<br>
#if defined( __cplusplus )<br>
}<br>
#endif // __cplusplus<br>
<br>
#endif // INC_FIGHT<br>
//----------------------------------------------------------------------------<br>
<br>
And the CPP file<br>
//----------------------------------------------------------------------------<br>
// fight.cpp<br>
#include <windows.h><br>
#include "fight.h"<br>
<br>
extern "C"<br>
int WINAPI hitval(int level, int str, int agi, int opagi)<br>
{<br>
// for a test, show values in a message box<br>
char buffer[ 80 ];<br>
wsprintf( buffer,<br>
"level = %d\nstr = %d\nagi = %d\nopagi = %d",<br>
level, str, agi, opagi );<br>
MessageBox( NULL, buffer, "in dll", MB_OK );<br>
<br>
return 10;<br>
}<br>
//----------------------------------------------------------------------------<br>
<br>
And the DEF file<br>
;----------------------------------------------------------------------------<br>
; fight.def<br>
LIBRARY FIGHT.DLL ; should be the same name as the result DLL!<br>
DESCRIPTION 'This is the fight DLL!'<br>
HEAPSIZE 10000<br>
EXPORTS<br>
hitval @100 ; you can add more functions here: function name @101 and so on<br>
;----------------------------------------------------------------------------<br>
<br>
Note that comments in DEF file are ; comment... much like ASM comments.<br>
<br>
That's it, compile/link the lot, you have a DLL and a LIB file. Now create a simple test EXE something like this<br>
// ----------------------------------------------------------------------------<br>
// test.cpp<br>
#include <windows.h><br>
#include "fight.h" // make sure this points to the correct path<br>
<br>
int WINAPI WinMain( HINSTANCE, HINSTANCE, LPSTR, int )<br>
{<br>
int ret = hitval( 1, 2, 3, 4 );<br>
char buffer[ 80 ];<br>
wsprintf( buffer, "returned %d", ret );<br>
MessageBox( NULL, buffer, "in exe", MB_OK );<br>
return 0;<br>
}<br>
//----------------------------------------------------------------------------<br>
<br>
Add fight.lib to this project, make sure fight.dll is somewhere along the path, run.. It should work fine.<br>
<br>
Hope this helps<br>
<br>
: OK, just got done trying it. I pasted what you posted into the header file, and changed it from INC_MYDLL to INC_FIGHT (fight.dll/fight.cpp) and the void function I replaced with "int hitval(int level, int str, int agi, int opagi);". I am still getting "unresolved external referenced from AoY.OBJ". I have added the .lib file to the project, to be linked with the executeable. Any ideas??<br>
: <br>
: -Seph<br>
: <br>
<br>