CString szfilemane;
//waveInGetPosition(m_hWaveIn,&m_time,sizeof(MMTIME));//?
m_pWaveHdr1->dwBytesRecorded = m_time.u.cb;
DWORD m_WaveHeaderSize = 38;
DWORD m_WaveFormatSize = 18;
DWORD m_WrittenBytes = 0;
char lpszFilter[] = "Wave Files (*.wav)|*.wav||";
CFileDialog m_fileDlg(FALSE,NULL,"WAVE.wav",4|2,lpszFilter,NULL,0);
if(IDOK == m_fileDlg.DoModal())
{
szfilemane = m_fileDlg.GetFileName();
}
else
return ;
CFile m_file;
CFileException fileException;
//CString m_csFileName= m_SavePath;
m_file.Open(szfilemane,CFile::modeCreate|CFile::modeReadWrite, &fileException);
//写WAVE文件头
m_file.Write("RIFF",4);
unsigned int Sec=(m_pWaveHdr1->dwBytesRecorded + m_WaveHeaderSize -8);
m_file.Write(&Sec,sizeof(Sec));
m_file.Write("WAVE",4);
m_file.Write("fmt ",4);
m_file.Write(&m_WaveFormatSize,sizeof(m_WaveFormatSize));
m_file.Write(&waveformat.wFormatTag,sizeof(waveformat.wFormatTag));
m_file.Write(&waveformat.nChannels,sizeof(waveformat.nChannels));
m_file.Write(&waveformat.nSamplesPerSec,sizeof(waveformat.nSamplesPerSec));
m_file.Write(&waveformat.nAvgBytesPerSec,sizeof(waveformat.nAvgBytesPerSec));
m_file.Write(&waveformat.nBlockAlign,sizeof(waveformat.nBlockAlign));
m_file.Write(&waveformat.wBitsPerSample,sizeof(waveformat.wBitsPerSample));
m_file.Write(&waveformat.cbSize,sizeof(waveformat.cbSize));
m_file.Write("data",4);
m_file.Write(&m_pWaveHdr1->dwBytesRecorded,sizeof(m_pWaveHdr1->dwBytesRecorded));
DWORD m_seek=46;
// m_file.Seek
m_file.Write(pSaveBuffer,m_pWaveHdr1->dwBytesRecorded);
m_file.Close();