-
October 23rd, 2009, 11:13 AM
#1
AfxLoadLibrary different vc6 to vc9
Just migrating to vc9 from vc6.
I have a bunch of extension dlls that basically act as plugins, which may be added optionally.
We put them in a subfolder under our app; appmain/plugins/appspecific/blah.dll
In vc6, we used AfxLoadLibrary(plugins/appspecific/blah.dll) and it would load them fine.
With vc9 it is failing. It turns out that there is an issue with the dll dependency in these plugins. In vc6, they appear to have loaded with appmain as their "current" folder so they would be able to pick up the dlls in that folder. Now, however, with vc9, they seem to load from the plugins/appspecific folder!
As a test, if I put the plugin in the appmain folder, everything works fine. But it messes up a lot of configuration for people.
Does anyone have any ideas?
Thanks!
-
October 23rd, 2009, 11:21 AM
#2
Re: AfxLoadLibrary different vc6 to vc9
Just generate the full path to where the dll's are located. I assume that the dll's are either in the application directory or in a sub directory below the app directory.
If that's the case, then use GetModuleFileName( NULL, ... ) and strip off the exe name. Then use that path to form the complete path to the dlls that you would like to load.
-
October 23rd, 2009, 11:32 AM
#3
Re: AfxLoadLibrary different vc6 to vc9
Thanks Arjay. Let me just make sure I've got this right:
In appmain folder I have xyz.dll
In appmain\plugins folder I have abc.dll
So I'm using AfxLoadLibrary("appmain\\plugins\\abc.dll") to load my plugin. It requires xyz.dll. In vc6 it worked but in vc9 it did not work.
So you're saying if I use the complete path AfxLoadLibrary("c:\\program files\\appmain\\plugins\\abc.dll) it will be able to find the xyz.dll in the appmain folder?
-
October 23rd, 2009, 12:41 PM
#4
Re: AfxLoadLibrary different vc6 to vc9
I misunderstood the dependency issue. In general, I prefer to provide explicit paths to loadlibrary to avoid any confusion where the dll is being loaded from.
To solve your problem, retrieve the path of the app as I mentioned before, then call SetWorkingDirectory. Finally call load library.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|