"Maarten Lankhorst" <m.b.lankhorst(a)gmail.com> wrote:
Seems native directsound keeps itself loaded by calling LoadLibrary when attaching. A simple testcase I wrote confirms that at least for xp, by not crashing.
After seeing this, I decided to write my own test, and can confirm now that this patch looks correct: after a successful LoadLibrary("dsound.dll") FreeLibrary needs to be called 2 times before it starts to return FALSE. Just for fun I tested other dlls as well (GetModuleHandle returns 0 for all of them before the LoadLibrary call): user32 requires 4 FreeLibrary calls after LoadLibrary, dinput - 1, mfc42 - 1, advapi32 - 1, comctl32 - 1. I'm attaching the program I used for testing.
+ GetModuleFileNameW(hInstDLL, modname, sizeof(modname)/sizeof(*modname)); + LoadLibraryW(modname);
Probably simple LoadLibrary("dsound.dll") should be enough. -- Dmitry.