69,378
社区成员
发帖
与我相关
我的任务
分享
unsigned long getmusictime(char *s)//利用MCI命令,*S为文件名,返回值为文件时间的秒数
{
unsigned long m_dLength;
int m_wDeviceID;
char buf[128];
MCI_OPEN_PARMS mciOpen;
MCI_STATUS_PARMS mciStatusParms;
MCIERROR mciError;
mciOpen.lpstrElementName=(LPCTSTR)s;//取得文件名
mciError=mciSendCommand(NULL,MCI_OPEN,MCI_OPEN_ELEMENT,(DWORD)(LPVOID)&mciOpen);//打开文件
if(mciError) //出错处理
{
mciGetErrorString(mciError,buf,128);
printf("%s\n",buf);
getchar();
}
m_wDeviceID=mciOpen.wDeviceID;
mciStatusParms.dwItem=MCI_STATUS_LENGTH;
mciSendCommand(m_wDeviceID,MCI_STATUS,MCI_WAIT|MCI_STATUS_ITEM,(DWORD)(LPVOID)&mciStatusParms);//关键,取得长度
m_dLength=mciStatusParms.dwReturn;
mciSendCommand(m_wDeviceID,MCI_CLOSE,0,NULL);//关闭文件
return m_dLength;
}