谁帮我把这段VC代码转成DELPHI的,谢谢了!
HMMIO m_hmmio;
MMCKINFO m_MMCkInfoParent;
WAVEFORMATEX m_PCMWaveFmtRecord;
MMCKINFO m_MMCkInfoChild;
TCHAR bigBuff[2048] = ""; // maximum common dialog buffer size
TCHAR szFilter[] =
"Text Files (*.wav)|*.wav|All Files (*.*)|*.*||";
//TCHAR csFileName[MAX_PATH];
//CString csFileName;
CString m_strFilePath;
CString strWaveInformation;
CString szExtFile;
CFileDialog dlg(TRUE, NULL, NULL,
OFN_HIDEREADONLY | OFN_ALLOWMULTISELECT, szFilter);
// Modify OPENFILENAME members directly to point to bigBuff
dlg.m_ofn.lpstrFile = bigBuff;
dlg.m_ofn.nMaxFile = sizeof(bigBuff);
if(dlg.DoModal() == IDOK)
{
m_strFilePath = dlg.GetPathName();
}
else
return;
m_hmmio = mmioOpen((LPSTR)(LPCTSTR)m_strFilePath,NULL,MMIO_READ);
if(!m_hmmio)
{
AfxMessageBox("unable to open Sound MM File");
return ;
}
m_MMCkInfoParent.fccType = mmioFOURCC('W','A','V','E');
int errorCode = mmioDescend(m_hmmio, &m_MMCkInfoParent,NULL,MMIO_FINDRIFF);
if(errorCode)
{
AfxMessageBox("Error descending into file");
mmioClose(m_hmmio,0);
m_hmmio = NULL;
return ;
}
m_MMCkInfoChild.ckid = mmioFOURCC('f','m','t',' ');
errorCode = mmioDescend(m_hmmio,&m_MMCkInfoChild,&m_MMCkInfoParent,MMIO_FINDCHUNK);
if(errorCode)
{
AfxMessageBox("Error descending in file");
mmioClose(m_hmmio,0);
m_hmmio = NULL;
return ;
}
DWORD bytesRead = mmioRead(m_hmmio,(LPSTR)&m_PCMWaveFmtRecord,m_MMCkInfoChild.cksize);
if(bytesRead < 0)
{
AfxMessageBox("Error reading PCM wave format record");
mmioClose(m_hmmio,0);
return ;
}
strWaveInformation.Format("wFormatTag = %d , nChannels = %d, nSamplesPerSec = %d, nAvgBytesPerSec = %d, nBlockAlign = %d, wBitsPerSample = %d, cbSize = %d",
m_PCMWaveFmtRecord.wFormatTag, m_PCMWaveFmtRecord.nChannels,
m_PCMWaveFmtRecord.nSamplesPerSec ,m_PCMWaveFmtRecord.nAvgBytesPerSec ,
m_PCMWaveFmtRecord.nBlockAlign, m_PCMWaveFmtRecord.wBitsPerSample,m_PCMWaveFmtRecord.cbSize);
AfxMessageBox(strWaveInformation);
mmioClose(m_hmmio,0);
HMMIO m_hmmio;
MMCKINFO m_MMCkInfoParent;
WAVEFORMATEX m_PCMWaveFmtRecord;
MMCKINFO m_MMCkInfoChild;
TCHAR bigBuff[2048] = ""; // maximum common dialog buffer size
TCHAR szFilter[] =
"Text Files (*.wav)|*.wav|All Files (*.*)|*.*||";
//TCHAR csFileName[MAX_PATH];
//CString csFileName;
CString m_strFilePath;
CString strWaveInformation;
CString szExtFile;
CFileDialog dlg(TRUE, NULL, NULL,
OFN_HIDEREADONLY | OFN_ALLOWMULTISELECT, szFilter);
// Modify OPENFILENAME members directly to point to bigBuff
dlg.m_ofn.lpstrFile = bigBuff;
dlg.m_ofn.nMaxFile = sizeof(bigBuff);
if(dlg.DoModal() == IDOK)
{
m_strFilePath = dlg.GetPathName();
}
else
return;
m_hmmio = mmioOpen((LPSTR)(LPCTSTR)m_strFilePath,NULL,MMIO_READ);
if(!m_hmmio)
{
AfxMessageBox("unable to open Sound MM File");
return ;
}
m_MMCkInfoParent.fccType = mmioFOURCC('W','A','V','E');
int errorCode = mmioDescend(m_hmmio, &m_MMCkInfoParent,NULL,MMIO_FINDRIFF);
if(errorCode)
{
AfxMessageBox("Error descending into file");
mmioClose(m_hmmio,0);
m_hmmio = NULL;
return ;
}
m_MMCkInfoChild.ckid = mmioFOURCC('f','m','t',' ');
errorCode = mmioDescend(m_hmmio,&m_MMCkInfoChild,&m_MMCkInfoParent,MMIO_FINDCHUNK);
if(errorCode)
{
AfxMessageBox("Error descending in file");
mmioClose(m_hmmio,0);
m_hmmio = NULL;
return ;
}
DWORD bytesRead = mmioRead(m_hmmio,(LPSTR)&m_PCMWaveFmtRecord,m_MMCkInfoChild.cksize);
if(bytesRead < 0)
{
AfxMessageBox("Error reading PCM wave format record");
mmioClose(m_hmmio,0);
return ;
}
strWaveInformation.Format("wFormatTag = %d , nChannels = %d, nSamplesPerSec = %d, nAvgBytesPerSec = %d, nBlockAlign = %d, wBitsPerSample = %d, cbSize = %d",
m_PCMWaveFmtRecord.wFormatTag, m_PCMWaveFmtRecord.nChannels,
m_PCMWaveFmtRecord.nSamplesPerSec ,m_PCMWaveFmtRecord.nAvgBytesPerSec ,
m_PCMWaveFmtRecord.nBlockAlign, m_PCMWaveFmtRecord.wBitsPerSample,m_PCMWaveFmtRecord.cbSize);
AfxMessageBox(strWaveInformation);
mmioClose(m_hmmio,0);
解决方案 »
- 程序改为三层后修改记录时字段只能保存一半内容?
- edit一个小问题,如何取其中一部分值,急
- [求教]怎样用delphi实现综合查询
- 如果判断一个文本里面输入的数字前三位是不是移动的号码头,就是135 136 137 138 139否则提示出错,
- 一个Rave连接数据库的简单问题
- property Handle: HWnd read GetHandle;是什么意思
- 我们公司在局域网中,通过Cisco路由器接DDN,连接总公司.win98可以ping到总公司路由器,但是用了win2k专业版就只能在局域网内ping,数据报出
- delphi搞ACCESS数据库,日期/时间字段的使用,和日期时间字段之间的时间差
- 我需要一个好用且有注册码的FTP上传软件
- 用控件QUERY 怎么和DELPHI 中的 navigator 控件 结合完成插入,删除和更新功能
- 多线程调用时报"abstract error"!
- 问一个多媒体定时器的问题
TCHAR szFilter[] =
"Text Files (*.wav)|*.wav|All Files (*.*)|*.*||";
//TCHAR csFileName[MAX_PATH];
//CString csFileName;
CString m_strFilePath;
CString strWaveInformation;
CString szExtFile;
CFileDialog dlg(TRUE, NULL, NULL,
OFN_HIDEREADONLY | OFN_ALLOWMULTISELECT, szFilter);
// Modify OPENFILENAME members directly to point to bigBuff
dlg.m_ofn.lpstrFile = bigBuff;
dlg.m_ofn.nMaxFile = sizeof(bigBuff);
if(dlg.DoModal() == IDOK)
{
m_strFilePath = dlg.GetPathName();
}
else
return;
这段是打开文件那个对话框
直接用GetOpenFileName一个API就能搞定
MMSYSTEM,Dialogs;
var
m_hmmio:HMMIO;
m_MMCkInfoParent:MMCKINFO ;
m_PCMWaveFmtRecord:WAVEFORMATEX ;
m_MMCkInfoChild:MMCKINFO ;
// TCHAR bigBuff[2048] = ""; // maximum common dialog buffer size
// TCHAR szFilter[] =
// "Text Files (*.wav)|*.wav|All Files (*.*)|*.*||"; OpenDlg: TOpenDialog;
OpenDlg_Options: TOpenOptions;
m_strFilePath:String ; strWaveInformation:String ;
szExtFile: String ; errorCode: Integer;
bytesRead: LongWord;
begin
OpenDlg := TOpenDialog.Create(Nil);
OpenDlg_Options := OpenDlg.Options;
Include( OpenDlg_Options,ofHideReadOnly);
//Include(OpenDlg_Options,ofAllowMultiSelect); //多文件需要特别处理
OpenDlg.Options := OpenDlg_Options;
OpenDlg.Filter := 'Text Files (*.wav)|*.wav|All Files (*.*)|*.*||';
if(OpenDlg.Execute() ) then
m_strFilePath := OpenDlg.FileName //OpenDlg.Files.Text //在选择多文件的时候这里可能需要注意一下文件名之间的分隔符
else
Exit;
m_hmmio := mmioOpen(PChar(m_strFilePath),NIL,MMIO_READ);
if(m_hmmio=0) then
begin
showMessage('unable to open Sound MM File');
Exit;
end; m_MMCkInfoParent.fccType := mmioStringToFOURCC('WAVE',MMIO_TOUPPER);//mmioFOURCC('W','A','V','E');
errorCode := mmioDescend(m_hmmio, @m_MMCkInfoParent,Nil,MMIO_FINDRIFF);
if(errorCode<>0) then
begin
ShowMessage('Error descending into file');
mmioClose(m_hmmio,0);
m_hmmio := 0;
Exit ;
end; m_MMCkInfoChild.ckid := mmioStringToFOURCC('fmt ',0);//mmioFOURCC('f','m','t',' ');
errorCode := mmioDescend(m_hmmio,@m_MMCkInfoChild,@m_MMCkInfoParent,MMIO_FINDCHUNK);
if(errorCode<>0) then
begin
ShowMessage('Error descending in file');
mmioClose(m_hmmio,0);
m_hmmio := 0;
Exit ;
end; bytesRead := mmioRead(m_hmmio,PChar(@m_PCMWaveFmtRecord),m_MMCkInfoChild.cksize);
if(bytesRead < 0) then
begin
ShowMessage('Error reading PCM wave format record');
mmioClose(m_hmmio,0);
Exit;
end; strWaveInformation := Format('wFormatTag = %d , nChannels = %d, nSamplesPerSec = %d, nAvgBytesPerSec = %d, nBlockAlign = %d, wBitsPerSample = %d, cbSize = %d',
[m_PCMWaveFmtRecord.wFormatTag, m_PCMWaveFmtRecord.nChannels,
m_PCMWaveFmtRecord.nSamplesPerSec ,m_PCMWaveFmtRecord.nAvgBytesPerSec ,
m_PCMWaveFmtRecord.nBlockAlign, m_PCMWaveFmtRecord.wBitsPerSample,m_PCMWaveFmtRecord.cbSize]);
ShowMessage(strWaveInformation);
mmioClose(m_hmmio,0);
end;
type
WAVEFORMATEX = tWAVEFORMATEX;