您的位置:首页 > 其它

illegal use of this type as an expression

2013-09-11 20:25 288 查看
学习MCI时看别人样例手敲代码出现的一个很经典的错误。

在C语言中定义的变量没有放在函数的开头。

#include <string.h>
#include <windows.h>
#include <Digitalv.h>
#include <mmsystem.h>
#pragma comment(lib, "winmm.lib")

int main()
{
char buf[128];
MCI_OPEN_PARMS mciOpen;
MCIERROR mciError;
UINT DeviceID;
MCI_PLAY_PARMS mciPlay;
mciOpen.lpstrDeviceType = L"mpegvideo";
mciOpen.lpstrElementName = L"year.mp3";
mciError = mciSendCommand(0, MCI_OPEN,MCI_OPEN_TYPE | MCI_OPEN_ELEMENT, (DWORD)&mciOpen);
if(mciError)
{
mciGetErrorString(mciError, (LPWSTR)buf, 128);
MessageBox(NULL, TEXT("send MCI_OPEN command failed"), TEXT("ERROR"), 0);
return;
}
DeviceID = mciOpen.wDeviceID;
mciError = mciSendCommand(DeviceID, MCI_PLAY, MCI_WAIT | MCI_DGV_PLAY_REPEAT, (DWORD)&mciPlay);
if(mciError)
{
mciGetErrorString(mciError, (LPWSTR)buf, 128);
MessageBox(NULL, TEXT("send MCI_PLAY command failed"), TEXT("ERROR"), 0);
return;
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: