PDA

View Full Version : Remove library after unloading



mvw
10th April 2010, 11:50
Hi all,

I am trying to make an application (for windows) which can be updated by replacing the dll library at run-time, problem is that the exe seems to keep the dll file locked after unloading.

What I'm trying to do in code:


QLibrary* Lib = new QLibrary("library");
if(!Lib->load()) {
qDebug() << mainLib->errorString();
}
...
if( Lib->unload() ) {
delete Lib;
QFile::remove(libraryPath) //fails as file is locked :(
}

I've checked that the dll file is closed (process monitor, sysinternals) when trying to remove.

Does anybody know if this is something which can't be done by qLibrary, a Windows probem or whether an app restart is required?

mvw
23rd April 2010, 10:06
Found the answer, I wasn't dynamically loading the dll's. Used the option 'delay loaded dll's' in visual studio.