its been about three days now since ive been trying to link my dll to my executable but everything i try wont work. i have tried placing the lib file in the linker. i get error 1>new3.obj : error LNK2019: unresolved external symbol _dllLoadBitmap referenced in function _WndProc@16.
i have tried to load the library using loadlibrary. loadlibrary seems to work but then when i call getprocadress to get the adress of the function it returns null!!. my assignment is almost due and i seriously need help on this. heres my dll source code and header file
/--------------------------------------- LoadImage header file (c) Donald Dago, 17/08/2010 Mr Sinclair ----------------------------------------/
include
include
include
define EXPORT _declspec (dllexport)
typedef unsigned char *BITMAPFILE;
typedef struct { char *filename; BITMAPFILEHEADER bitFileHeader; BITMAPINFOHEADER bitInfoHeader;
}IMAGE,*PIMAGE;
EXPORT BITMAPFILE WINAPI dllLoadBitmap(HWND hwnd,PIMAGE iprpImage);
/--------------------------------------- Date finished ----------------------------------------/
/--------------------------------------- LoadImage source file (c) Donald Dago, 17/08/2010 Mr Sinclair ----------------------------------------/
include "dllHeader.h"
int WINAPI DllMain(HINSTANCE hInstance, DWORD fdwReason, PVOID pvReserved) { return TRUE; }
EXPORT BITMAPFILE WINAPI dllLoadBitmap(HWND hwnd,PIMAGE iprpImage) { FILE *flPointer = NULL; BITMAPFILE bitmapImage = NULL; int imagebit = 0; BITMAPFILE tempBitmapImage;
//open filename in read binary mode if(!(flPointer = fopen(iprpImage->filename,"rb"))) return NULL;
/////////////////////////////////////////////////// //Read bitfileheader from bitmap // //to check if image is a bitmap or its // //not curropt // ////////////////////////////////////////////////// fread(&iprpImage->bitFileHeader,sizeof(iprpImage->bitFileHeader),1,flPointer); if((WORD)iprpImage->bitFileHeader.bfType != 0x4D42) return NULL;
fread(&iprpImage->bitInfoHeader,sizeof(iprpImage->bitInfoHeader),1,flPointer);
fseek(flPointer,iprpImage->bitFileHeader.bfOffBits,SEEK_SET); //return file pointer offset bitInfoHeader.biBitCount
//allocate heap memory to store bitmap file bitmapImage = (BITMAPFILE)malloc(iprpImage->bitInfoHeader.biSizeImage);
if(!(bitmapImage)) { free(bitmapImage); fclose(flPointer); return NULL; }
fread(bitmapImage,sizeof(iprpImage->bitInfoHeader.biSizeImage),1,flPointer);
if(bitmapImage == NULL) { fclose(flPointer); return NULL; }
////////////////////////////////////////////////////// //swap the r and b values to get // //RGB as bitmap is BGR // //////////////////////////////////////////////////////
for(imagebit = 0; imagebit < iprpImage->bitInfoHeader.biSizeImage; imagebit += 3) { tempBitmapImage = bitmapImage[imagebit]; bitmapImage[imagebit] = bitmapImage[imagebit + 2]; bitmapImage[imagebit] = tempBitmapImage; } fclose(flPointer);
return bitmapImage;
}
/-------------------------------------- Date started: 17/08/2010 Date finished: -------------------------------------/