Code:
typedef void (*FuncNoParams)();
typedef void (*FuncWithParams)(int value);
...
...
HMODULE module = LoadLibrary("MyDLL.dll");
if (module)
{
FuncNoParams noParamFunc;
FuncWithParams paramFunc;
noParamFunc = (FuncNoParams)GetProcAddress(module,"FooNoParams");
if (noParamFunc)
{
noParamFunc();
}
paramFunc = (FuncWithParams)GetProcAddress(module,"FooWithParams");
if (paramFunc)
{
paramFunc(0);
}
FreeLibrary(module);
}
...
...
DLL import/export header - MyModule_DLL.h
Code:
#pragma once
#ifdef MYDLL_EXPORTS
#define MYDLL_API __declspec(dllexport)
#else
#define MYDLL_API __declspec(dllimport)
#endif
DLL module header
Code:
#pragma once
#include "MyModule_DLL.h"
#ifdef __cplusplus
extern "C" {
#endif
MYDLL_API void FooNoParams();
MYDLL_API void FooWithParams(int value);
#ifdef __cplusplus
}
#endif
...
DLL implementation
Code:
#include "MyDLL.h"
void FooNoParams()
{
}
void FooWithParams(int value)
{
value;
}
I did not test this code but it should get you extremely close to a working DLL and a client that can load and use it.