Quote:Original post by Fire Lancer
Quote:
Not really - the DLL has to be unloaded before the EXE ends, if it's not then the OS will unload the DLL as part of the EXE cleanup.
Is it garunteed to do this after clearing up any globals etc in the exe and not before?
Yes.
Quote:Original post by Fire Lancer
Quote:
You can just use GetProcAddress() to get the address of your DllCanUnloadNow() function from the HMODULE
Yes thats what I'm doing to get the object factory methods from the dll in the first place. The question is just how fast is getting the address? Is it a simple lookup in a table or does windows go searching though the dll looking from a function with that name (which is something I dont really want to do everytime an object is destroyed).
I can't say for sure, I suspect it's a lookup table - LoadLibrary() on XP uses a lookup table internally to see if the library is loaded, and that's called far less frequently that GetProcAddress(). You could always use QueryPerformanceCounter() to check the time taken to call GetProcAddress().
However, you really shouldn't be creating and destroying objects all the time, so the time taken to call GetProcAddress() will be mostly irrelevant.
In fact, since I have the OS symbols on this PC, and I'm bored, I'll go see what I can find from digging around in the dissasembly for GetProcAddress [smile]
EDIT: Ok, it looks like GetProcAddress() is reasonably expensive to call. From what I can see, it doesn't use a hash map like LoadLibrary() does, instead it parses the DLL's function exports table and looks for the named function.
However, as I said above, it shouldn't be that much of a problem. If you profile and find that it is, you can always cache the function address somehow.
[Edited by - Evil Steve on January 20, 2009 5:31:17 PM]