|
|
1.1 root 1: /*
2:
3: file.c
4:
5: File i/o module
6:
7: */
8:
9: #include <stdlib.h>
10: #include <windows.h>
11: #include <string.h>
12: #include <commdlg.h>
13: #include "PlaySnd.h"
14:
15:
16:
17: OPENFILENAME ofn; // passed to the File Open/save APIs
18:
19: void PlayFile()
20: {
21: char szFileName[_MAX_PATH];
22: DWORD dwFlags;
23:
24: szFileName[0] = 0;
25: ofn.lStructSize = sizeof(ofn);
26: ofn.hwndOwner = ghwndMain;
27: ofn.hInstance = ghModule;
28: ofn.lpstrFilter = "Wave Files\0*.wav\0All Files\0*.*\0\0";
29: ofn.lpstrCustomFilter = NULL;
30: ofn.nMaxCustFilter = 0;
31: ofn.nFilterIndex = 1;
32: ofn.lpstrFile = szFileName;
33: ofn.nMaxFile = sizeof(szFileName);
34: ofn.lpstrFileTitle = NULL;
35: ofn.nMaxFileTitle = 0;
36: ofn.lpstrInitialDir = ".";
37: ofn.lpstrTitle = "File Open";
38: ofn.Flags = 0;
39: ofn.nFileOffset = 0;
40: ofn.nFileExtension = 0;
41: ofn.lpstrDefExt = NULL;
42: ofn.lCustData = 0;
43: ofn.lpfnHook = NULL;
44: ofn.lpTemplateName = NULL;
45:
46:
47: dprintf3("Calling GetOpenFileName");
48: if (GetOpenFileName(&ofn)) {
49:
50: dwFlags = SND_FILENAME;
51:
52: if (bSync) {
53: WinAssert(!SND_SYNC);
54: } else {
55: dwFlags |= SND_ASYNC;
56: }
57:
58: if (bNoWait) dwFlags |= SND_NOWAIT;
59:
60: if (!PlaySound(szFileName, NULL, dwFlags)) {
61: Error("Failed to play file: %s", szFileName);
62: }
63: }
64:
65: }
66:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.