Quote:
Originally Posted by
avirat
... Also created one MFC application which uses above created dll and give call to the exported function. Code is as below.
Code:
GetModuleFileName(NULL, szModulePath, MAX_PATH);
GetShortPathName(szModulePath, szModulePath, MAX_PATH);
_tcscat(szModulePath, _T("ADll.dll"));
hAsaeDll = LoadLibrary (szModulePath);
pfnShowAsaeDlg = (PFN_SHOWASAEDLG)GetProcAddress(hAsaeDll, "ShowAsaeDlg");
pfnShowAsaeDlg();
This simple code does not works. DoModal returns -1.
1. While using Windows APIs you must always check their return value:
What does LoadLibrary return?
What does GetProcAddress return?
2. Why do you call GetShortPathName API? Why do you need to convert the full path name of your exe to short (MS DOS) format? :confused:
3. Did you try to debug your code to see the results of all of these APIs and _tcscat calls? :rolleyes: