("停止录音"); else log.write("停止录音失败");
if (! waveInReset(m_hWaveIn) ) log.write("重置内存区成功"); else log.write("重置内存区失败");
m_pWaveHdr.dwBytesRecorded = mmt.u.cb;
DWORD NumToWrite=0; DWORD dwNumber = 0;
HANDLE FileHandle =
CreateFile( "myTest.wav", GENERIC_WRITE, FILE_SHARE_READ, NULL,
CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
// memset(m_pWaveHdr.lpData, 0, datasize);
dwNumber = FCC("RIFF");
WriteFile(FileHandle, &dwNumber, 4, &NumToWrite, NULL);
dwNumber = m_pWaveHdr.dwBytesRecorded + 18 + 20;
WriteFile(FileHandle, &dwNumber, 4, &NumToWrite, NULL);
dwNumber = FCC("WAVE");
WriteFile(FileHandle, &dwNumber, 4, &NumToWrite, NULL);
dwNumber = FCC("fmt ");
WriteFile(FileHandle, &dwNumber, 4, &NumToWrite, NULL);
dwNumber = 18L;
WriteFile(FileHandle, &dwNumber, 4, &NumToWrite, NULL);
WriteFile(FileHandle, &waveformat, sizeof(WAVEFORMATEX), &NumToWrite, NULL);
dwNumber = FCC("data");
WriteFile(FileHandle, &dwNumber, 4, &NumToWrite, NULL);
dwNumber = m_pWaveHdr.dwBytesRecorded;
WriteFile(FileHandle, &dwNumber, 4, &NumToWrite, NULL);
WriteFile(FileHandle, m_pWaveHdr.lpData, m_pWaveHdr.dwBytesRecorded, &NumToWrite, NULL);
SetEndOfFile(FileHandle);
CloseHandle( FileHandle ); FileHandle = INVALID_HANDLE_VALUE; // 收尾关闭句柄
log.write("应该已生成 myTest.wav 文件");
if ( waveInUnprepareHeader(m_hWaveIn, &m_pWaveHdr, sizeof(WAVEHDR)) ) log.write("Un_Prepare Header 失败"); else log.write("Un_Prepare Header 成功");
if ( GlobalFree(GlobalHandle( m_pWaveHdr.lpData )) ) log.write("Global Free 失败"); else log.write("Global Free 成功");
if (res == MMSYSERR_NOERROR ) //关闭录音设备
if (waveInClose(m_hWaveIn)==MMSYSERR_NOERROR)log.write("正常关闭录音设备");
else log.write("非正常关闭录音设备");
log.last(true);
// ExitProcess(0);
return 0;
}
// ******************* End of File *****************************