Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

52 lines
1.8 KiB

  1. #include "stock.h"
  2. #pragma hdrstop
  3. #include "w95wraps.h"
  4. // we stick this function in a file all by itself so that the linker can strip it
  5. // out if you don't call the IEPlaySound function.
  6. STDAPI_(void) IEPlaySound(LPCTSTR pszSound, BOOL fSysSound)
  7. {
  8. TCHAR szKey[256];
  9. // check the registry first
  10. // if there's nothing registered, we blow off the play,
  11. // but we don't set the MM_DONTLOAD flag so that if they register
  12. // something we will play it
  13. wnsprintf(szKey, ARRAYSIZE(szKey), TEXT("AppEvents\\Schemes\\Apps\\%s\\%s\\.current"),
  14. (fSysSound ? TEXT(".Default") : TEXT("Explorer")), pszSound);
  15. TCHAR szFileName[MAX_PATH];
  16. szFileName[0] = 0;
  17. DWORD cbSize = sizeof(szFileName);
  18. // note the test for an empty string, PlaySound will play the Default Sound if we
  19. // give it a sound it cannot find...
  20. if ((SHGetValue(HKEY_CURRENT_USER, szKey, NULL, NULL, szFileName, &cbSize) == ERROR_SUCCESS)
  21. && cbSize && szFileName[0] != 0)
  22. {
  23. DWORD dwFlags = SND_FILENAME | SND_NODEFAULT | SND_ASYNC | SND_NOSTOP | SND_ALIAS;
  24. // This flag only works on Win95
  25. if (IsOS(OS_WIN95GOLD))
  26. {
  27. #define SND_LOPRIORITY 0x10000000l
  28. dwFlags |= SND_LOPRIORITY;
  29. }
  30. // Unlike SHPlaySound in shell32.dll, we get the registry value
  31. // above and pass it to PlaySound with SND_FILENAME instead of
  32. // SDN_APPLICATION, so that we play sound even if the application
  33. // is not Explroer.exe (such as IExplore.exe or WebBrowserOC).
  34. #ifdef _X86_
  35. // only call the wrapper on x86 (doesn't exist on ia64)
  36. PlaySoundWrapW(szFileName, NULL, dwFlags);
  37. #else
  38. PlaySound(szFileName, NULL, dwFlags);
  39. #endif
  40. }
  41. }