hadikazemi 0 Newbie Poster

hi i creat one file :

WAVEFORMATEX formatinfo;

formatinfo.cbSize = 0;

formatinfo.wFormatTag = WAVE_FORMAT_PCM;

formatinfo.nChannels = 1;

// 1 for mono 2 and 2 for stereo

formatinfo.wBitsPerSample = 16;

// can be 8 or 16

formatinfo.nSamplesPerSec = 8000;

// u can set nSamplesPerSec as 16000, 24000.

formatinfo.nBlockAlign = formatinfo.nChannels * (formatinfo.wBitsPerSample / 8);

formatinfo.nAvgBytesPerSec = formatinfo.nSamplesPerSec * formatinfo.nBlockAlign;



memset (&m_mmioinfoOut, 0,

sizeof (MMIOINFO));



hFile = mmioOpen(L"NEWFILE.WAV", &m_mmioinfoOut, MMIO_CREATE | MMIO_READWRITE);


if (hFile != NULL)
MessageBox(g_hWnd, L"Success",L"DirectSound Demo", MB_OK);
else
MessageBox(g_hWnd, L"failed",L"DirectSound Demo", MB_OK);

int fmtSize = 28;

chunk.fccType = mmioFOURCC('W','A','V','E');

chunk.cksize = 28;

::mmioCreateChunk(hFile, &chunk, MMIO_CREATERIFF);

chunk2.ckid = mmioFOURCC('f','m','t',' ');

chunk2.cksize =sizeof(WAVEFORMATEX);

::mmioCreateChunk(hFile, &chunk2, 0);

::mmioWrite(hFile, (const char*)&formatinfo,sizeof(formatinfo));

::mmioAscend(hFile, &chunk2, 0);

mmckinfoData.ckid = mmioFOURCC('d','a','t','a');

mmckinfoData.cksize = formatinfo.nAvgBytesPerSec;

::mmioCreateChunk(hFile, &mmckinfoData, 0);

mmioGetInfo( hFile, &m_mmioinfoOut, 0 );

but when i use :

*((BYTE*)m_mmioinfoOut.pchNext) = *((BYTE*)pbSrcData+cT);

i have one runtime error :

First-chance exception at 0x0042f165 in CreateDevice.exe: 0xC0000005: Access violation writing location 0x00000000

i see in debug that after mmioGetInfo( hFile, &m_mmioinfoOut, 0 ); m_mmioinfoOut.pchNext is 0x000000 <bad ptr>

why?