Click here to Skip to main content
15,170,651 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I write a MFC program that clicks a button to play music.The program runs well at company's computer, but at my computer it gets a strangely bug that triggered a breakpoint. I have confused for two days. Thank you for any help!
The code:
void Cmci_Test1Dlg::OnBnClickedButton1()
	// TODO: Add your control notification handler code here

	char buf[128];
	MCIERROR mciError;
	mciOpen.lpstrDeviceType ="mpegvideo";
	mciOpen.lpstrElementName ="F:\\TDDOWNLOAD\\Rolling In The Deep.mp3";
	mciError = mciSendCommand(0,MCI_OPEN,MCI_OPEN_TYPE | MCI_OPEN_ELEMENT,(DWORD)&mciOpen);
		UINT DeviceID = mciOpen.wDeviceID;   
		MCI_PLAY_PARMS mciPlay;   

		mciError = mciSendCommand(DeviceID, MCI_PLAY, 0,(DWORD)&mciPlay); 

the bug:
Windows has triggered a breakpoint in mci_Test1.exe.

This may be due to a corruption of the heap, which indicates a bug in mci_Test1.exe or any of the DLLs it has loaded.

This may also be due to the user pressing F12 while mci_Test1.exe has focus.

The output window may have more diagnostic information.
Updated 10-Dec-11 5:55am
[no name] 10-Dec-11 10:57am
EDIT: added formatting

Since we cannot see the output window on your computer it is impossible to guess what may be happening. Use your debugger to gather some more detail about the problem and provide full information about the error and any associated messages.
Well, first thing to check... are you sure that file exists in the system at home? Also, your device type you specify as "mpegvideo"... are you sure that's valid for an mp3 file?

Second... If you look at the documentation for mciSendCommand() here[^]... it states that the error code is the low-order word of the returned DWORD and the high-order word contains the driver identifier (if device specific). Means that mciGetErrorString() may require you to filter out the high-order word (although, the function might already do that internally).

In another words...
    mciGetErrorString((mciError &= 0x00FF),buf,128);
I have figured out this problem. The reason is that i installed a video player in my home computer. When i uninstalled the player, the program runs normally.
Thank you for your help.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900