Index   Commented   Search   About

Accessing a File I/O Buffer

The following example accesses an I/O buffer directly to read data from a waveform-audio file.

HMMIO hmmio;

MMIOINFO mmioinfo;

DWORD dwDataSize;

DWORD dwCount;

HPSTR hptr;

// Get information about the file I/O buffer.

if (mmioGetInfo(hmmio, &mmioinfo, 0))

{

Error("Failed to get I/O buffer info.");

.

.

.

mmioClose(hmmio, 0);

return;

}

// Read the entire file by directly reading the file I/O buffer.

// When the end of the I/O buffer is reached, advance the buffer.

for (dwCount = dwDataSize, hptr = lpData; dwCount 0; dwCount--)

{

// Check to see if the I/O buffer must be advanced.

if (mmioinfo.pchNext == mmioinfo.pchEndRead)

{

if(mmioAdvance(hmmio, &mmioinfo, MMIO_READ))

{

Error("Failed to advance buffer.");

.

.

.

mmioClose(hmmio, 0);

return;

}

}

// Get a character from the buffer.

*hptr++ = *mmioinfo.pchNext++;

}

// End direct buffer access and close the file.

mmioSetInfo(hmmio, &mmioinfo, 0);

mmioClose(hmmio, 0);

When you finish accessing a file I/O buffer, call the mmioSetInfo function, passing an address of the MMIOINFO structure filled by the mmioGetInfo function. If you wrote to the buffer, set the MMIO_DIRTY flag in the dwFlags member of the MMIOINFO structure before calling mmioSetInfo. Otherwise, the buffer will not be flushed to disk.

Related Links

Software for Delphi and C++ Builder developers
Software for Visual Studio .NET developers
Software for Visual Basic 6 developers
Delphi Tips&Tricks
MegaDetailed.NET
TMS Scripter Studio Pro components for Delphi/C++Builder

More Online Helps

Win32 Programmer's Reference (win32.hlp)
OLE Programmer's Reference (ole.hlp)
Microsoft Windows Pen API Programmer's Reference (penapi.hlp)
Microsoft Windows Sockets 2 Reference (sock2.hlp)
Microsoft Windows Telephony API (TAPI) Programmer's Reference (tapi.hlp)
Unix Manual Pages

Free Tech Secrets ;) Copyright © 2008 Free Tect Secrets ;) greatis just4fun network just4fun