Andreas Goebel schrieb:
>> Otherwise if you can't get the DLL instance of your plugin to pass to
>> GetModuleFileName(), you can try another trick:
>>
>> HINSTANCE handle =LoadLibrary( name of your plugin dll here );
>> if (handle)
>> {
>>     GetModuleFileName(handle, filename, sizeof(filename));
>>     PathRemoveFileSpec(filename);
>>     FreeLibrary(handle);
>> }
>>
>> This should work because the list of loaded DLLs is searched first by
>> LoadLibrary().
>>
>>   
> This works! Only one should not free the handle, as the lib is
> (probably) not loaded again, this gives a crash.
> 

You should do FreeLibrary() because it's reference counted internally.

see http://msdn.microsoft.com/en-us/library/ms683152(VS.85).aspx:

> The system maintains a per-process reference count for each loaded module. A 
> module that was loaded at process initialization due to load-time dynamic 
> linking has a reference count of one. The reference count for a module is 
> incremented each time the module is loaded by a call to LoadLibrary. The 
> reference count is also incremented by a call to LoadLibraryEx unless the 
> module is being loaded for the first time and is being loaded as a data or 
> image file. 


regards Ralph

_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to