Blog Stats
  • Posts - 45
  • Articles - 0
  • Comments - 15
  • Trackbacks - 20

 

Dynamic DLL loading

I worked on the redesign of one of my components this week. The redesign was caused because of added functionality. We ran into a problem where we needed to choose the chain of dlls to load at runtime. To give a quick overview here is what we ended up doing.

typedef long (_stdcall *getBlockSize)(long Size);

HINSTANCE LoadMe=NULL;
LoadMe = LoadLibrary("..\\bin\\MY.dll");
if (LoadMe != 0){
getBlockSize pBlkSize = NULL;
pBlkSize = (getBlockSize)GetProcAddress(LoadMe, "getBlockSize");
DWORD error = GetLastError();
if(pBlkSize == NULL){
error = GetLastError();
rtnstatus = DLL_ERROR;
}else{
lKeySize = (*pBlkSize)(strlen(czKey));
}


Hope this helps me someday :p

Feedback

No comments posted yet.


Post a comment





 

 

 

Copyright © Rishi Pande