Thank you in advance
Hans
i. use implicit exporting of resources ...:
/* exported function */
__declspec( dllexport ) void func();
/* exported data */
__declspec( dllexport ) int i;
These can the be referenced with GetProcAddress(hDll, "func") and
GetProcAddress(hDll, "i"), respectively.
ii. explicit exporting of resources:
In the c/cpp file:
void func();
int i;
Create a .def file that looks something like this:
; Somefile.def : Declares the module parameters for the DLL.
LIBRARY "SomeLibrary"
DESCRIPTION 'SomeLibrary Windows Dynamic Link Library'
EXPORTS
func @1
i @2
The @n defines the ordinal with which the resource will be exported. This
need not be explicitly defined, but if it is not, one should use the
resource name in conjunction with GetProcAddress.
Microsoft discourages the use of ordinals (I believe I came across that
statement in MSDN, but I could be wrong - happens quite often <g>).
Hope this helps.
Regards,
Joshua Emele
"Hans hansen" <ha...@eicon.com> wrote in message
news:u7FyO7ioAHA.1740@tkmsftngp05...
> This may sound stupid to some of you but , i can't not
> find any step by step guide to how to do it.
1) - Why don't you use MSDN :
http://msdn.microsoft.com/library/devprods/vs6/visualc/vccore/_core_overview.3a_.creating_a_win32_dll.htm
2) - Very basic sample for an hello world =>
*** DLL (Hello.c)
#define WIN32_LEAN_AND_MEAN
#include "windows.h"
#define HELLO_API __declspec(dllexport)
BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved )
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
} return TRUE;
}
HELLO_API void Hello(void)
{
MessageBox(NULL, "Hello !", "Information", MB_OK | MB_ICONEXCLAMATION);
}
*** Eventual DEF file
LIBRARY "Hello"
EXPORTS
Hello
*** Simple C program calling it dynamically :
#define WIN32_LEAN_AND_MEAN
#include "windows.h"
typedef VOID (WINAPI*HELLOPROC)(void);
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
HINSTANCE hDLL;
hDLL = LoadLibrary("Hello.dll");
if (hDLL != NULL)
{
HELLOPROC pHello = (HELLOPROC)GetProcAddress(hDLL,"Hello");
pHello();
FreeLibrary(hDLL);
}
return 0;
}