I have problem with UNICODE usage. The following is the scenarion. Its a bit lengthy but I have tried to put the question as clearly as possible.
I have a main application which allows me to load any DLL at runtime and call any exported function from the loaded DLL. The following thing should be noted.
1. Main application is build in non-UNICODE mode
2. The DLL that I am loading (the one giving the problem) is an MFC extension DLL and build in UNICODE mode. It has its own dialog resource and an exported funtion void TestFunc(void) coded as follows
//Get the current resource handle
HINSTANCE hInstOld = AfxGetResourceHandle();
//Set it to the extension DLL's resource handle
//Test dialog : the resource is in the ext DLL
//Restore the old resource handle
Now the problem:
1. I load the extension DLL in my application - Works Fine.
2. I call the exported funtion TestFunc - Fails.
The application crashes at this point. I have noted that AfxGetReourceHandle() & AfxGetCurrentInstance() fails which leads to the final crash.
But when my extension DLL is built in non-UNICODE mode, everything works fine !
What could be the problem ? Can't I mix unicode & non-unicode app & DLL like this ?
Thanks for your time