Has anyone come across the issue of calling WinApi.MMSystem.PlaySound returning false with an error code of 0?  It works fine in the context of a simple application, but fails in a much larger application.

Comments

  1. Making sure CoInitialize is called in the main thread and all other threads generally appear to help with COM issues. You also need balanced calls to CoUninitialize on terminate.  

    Do you load the DLL implicitly or explicitly?  I'd recommend explicit loads and making sure that your app have called CoInitialize before load.

    ReplyDelete
  2. I load it implicitly.  Explicitly loading it was my next thought, it's good to see someone else thinking the same thing.

    ReplyDelete
  3. It was the DLL.  It was written several years ago, and for some reason the programmer placed CoInitialize/CoUnitialize in the DLLMain function.  He still works here and we are both baffled as to why he did it.  Not sure if he was working around an issue that has become moot.  Almost all of our applications use this DLL and it has not caused any problems until the move to Win7/Server 2008R2.  Now we're worried about fixing it, lest we break some other application.  Lars Fosdal thanks for you help.

    ReplyDelete

Post a Comment