File in and out, (LPTSTR szFilename), HELP!

1
2
3
4
5
6
7
8
9
10
11
12
13
14
WAVEIN openwave(LPTSTR szFilename)
{
	
	if (!(w = (WAVEIN) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*w))))
	{
		cout << "error allocating wave handle"; 
	}

	if (!(w-> WAVEHANDLE = mmioOpen((LPTSTR) szFilename, NULL, MMIO_READ | MMIO_ALLOCBUF | MMIO_DENYWRITE)))
	{
		cout << "error reading file"; 
	}

...}


Above is the function, and below is the function call.

1
2
3
4
5

LPTSTR filename=(TEXT("C:\\tc++\\AUDIOFILES\\soundtrack\\wl.wav"));
	
wav=openwave(filename);


This works fine for me, but I want my program to allow the user to specify a wav file, pick a wave file from a list, or open from a folder. Problem is I cannot find any way to do this.

Here is the MSDN specified syntax

1
2
3
4
5
HMMIO mmioOpen(
  LPTSTR szFilename,
  LPMMIOINFO lpmmioinfo,
  DWORD dwOpenFlags
);


"szFilename

Pointer to a buffer that contains the name of the file. If no I/O procedure is specified to open the file, the file name determines how the file is opened, as follows:

If the file name does not contain a plus sign (+), it is assumed to be the name of a standard file (that is, a file whose type is not HMMIO).
If the file name is of the form EXAMPLE.EXT+ABC, the extension EXT is assumed to identify an installed I/O procedure which is called to perform I/O on the file. For more information, see mmioInstallIOProc.
If the file name is NULL and no I/O procedure is given, the adwInfo member of the MMIOINFO structure is assumed to be the standard (non-HMMIO) file handle of a currently open file.

The file name should not be longer than 128 characters, including the terminating NULL character."



The only example code other than the one I'm using, is like this, :

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
{ 
    char        szFileName[128];    // filename of file to open 
    HMMIO       hmmio;              // file handle for open file 
    MMCKINFO    mmckinfoParent;     // parent chunk information 
    MMCKINFO    mmckinfoSubchunk;   // subchunk information structure 
    DWORD       dwFmtSize;          // size of "FMT" chunk 
    DWORD       dwDataSize;         // size of "DATA" chunk 
    WAVEFORMAT  *pFormat;           // address of "FMT" chunk 
    HPSTR       lpData;             // address of "DATA" chunk 
 
    // Get the filename from the edit control. 
    . 
    . 
    . 
    // Open the file for reading with buffered I/O 
    // by using the default internal buffer 
    if(!(hmmio = mmioOpen(szFileName, NULL, 
        MMIO_READ | MMIO_ALLOCBUF))) 


But when I post this in my compiler, szFileName is underlined in red, and I'm told, that constant type szFileName is incompatible with parameter type LPTSTR.

Is the MSDN code in error? I feel like I've tried everything, and mmioOpen() will only accept a first argument of type LPTSTR. I'm not really even sure what that means.
Last edited on
Topic archived. No new replies allowed.