To jest moj kod do ladowania DLL, korzystalem z zrodelm internerowych do tego. Rowniez kiedys ladowalem inna DLL w ten sam sposob:
#include <cstdlib>
#include <iostream>
#include <windows.h>
#include "EasyBMP.h"
#include "bmp1.h"
using namespace std;
typedef float***(*fun)(char *);
typedef int (*fun1)(char *,float ***,int , int ,int ,int );
int main(int argc, char *argv[]) {
char *file="example1.bmp", *file1="example7.bmp";
float ***array;
HMODULE hModule = LoadLibrary("bmp1.dll");
if(hModule == NULL) return 0;
fun hFun =(fun)GetProcAddress(hModule, "GetArrayFromBMP");
if (hFun == NULL) return 0;
array=GetArrayFromBMP(file);
fun1 hFun1 =(fun1)GetProcAddress(hModule,"GetArrayToBMP");
if (hFun1 == NULL) return 0;
GetArrayToBMP(file1,array,100,100,8,1);
FreeLibrary(hModule);
//system("PAUSE");
return EXIT_SUCCESS;
}
Zakladam,ze problem lezy w tworzeniu DLL. Tak wyglada moj header do DLL ( w pliku cpp sa zdefiniowane funkcje ).
#ifndef DLL_H
#define DLL_H
#if BUILDING_DLL
- define BMP1 __declspec (dllexport)
#else /* Not BUILDING_DLL */
- define BMP1 __declspec (dllimport)
#endif /* Not BUILDING_DLL */
extern "C" __declspec(dllexport)float ***GetArrayFromBMP(char *fileName);
extern "C" __declspec(dllexport)int GetArrayToBMP(char *fileName,float ***array,int width, int height,int bitDepth,int depth);
class BMP1 DllClass
{
public:
DllClass();
virtual ~DllClass(void);
private:
};
#endif /* DLL_H */