Source code of Windows XP (NT5)
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.

66 lines
1.4 KiB

  1. /*
  2. file.c
  3. File i/o module
  4. */
  5. #include <stdlib.h>
  6. #include <windows.h>
  7. #include <string.h>
  8. #include <commdlg.h>
  9. #include "PlaySnd.h"
  10. OPENFILENAME ofn; // passed to the File Open/save APIs
  11. void PlayFile()
  12. {
  13. char szFileName[_MAX_PATH];
  14. DWORD dwFlags;
  15. szFileName[0] = 0;
  16. ofn.lStructSize = sizeof(ofn);
  17. ofn.hwndOwner = ghwndMain;
  18. ofn.hInstance = ghModule;
  19. ofn.lpstrFilter = "Wave Files\0*.wav\0All Files\0*.*\0\0";
  20. ofn.lpstrCustomFilter = NULL;
  21. ofn.nMaxCustFilter = 0;
  22. ofn.nFilterIndex = 1;
  23. ofn.lpstrFile = szFileName;
  24. ofn.nMaxFile = sizeof(szFileName);
  25. ofn.lpstrFileTitle = NULL;
  26. ofn.nMaxFileTitle = 0;
  27. ofn.lpstrInitialDir = ".";
  28. ofn.lpstrTitle = "File Open";
  29. ofn.Flags = 0;
  30. ofn.nFileOffset = 0;
  31. ofn.nFileExtension = 0;
  32. ofn.lpstrDefExt = NULL;
  33. ofn.lCustData = 0;
  34. ofn.lpfnHook = NULL;
  35. ofn.lpTemplateName = NULL;
  36. dprintf3(("Calling GetOpenFileName"));
  37. if (GetOpenFileName(&ofn)) {
  38. dwFlags = SND_FILENAME;
  39. if (bSync) {
  40. WinAssert(!SND_SYNC);
  41. } else {
  42. dwFlags |= SND_ASYNC;
  43. }
  44. if (bNoWait) dwFlags |= SND_NOWAIT;
  45. if (!PlaySound(szFileName, NULL, dwFlags | bNoDefault)) {
  46. Error("Failed to play file: %s", szFileName);
  47. }
  48. }
  49. }