Win32 MCI audio Playback
hey guys, i have a problem with using mci, i have code to display the file open dialog which displays only mp3 and wma files, after selelcting a file the file extension is stored in szFileName:
if(GetOpenFileName(&ofn))
{
MessageBox(hwnd,szFileName,"File OPen",0);
mciSendString("",szFileName,128,hwnd);
}
OK, Now, if i compile this i get no errors and no warning, when i choose to run, i get
"The procedure entry point SMapLS could not be located in the dynamic link library KERNEL32.dll."
When i comment out the mcisendstring() and leave the messagebox(), it runs fine and returns the correct full path of the file.
What am i doing wrong with the mcisendstring function.
Also note, i linked the winmm.dll and am using mmsystem.h
I cant figure out what i'm doing wrong.
First you need to open the file:
string Command;
Command="open "+szFileName;
mciSendString(Command.c_str(),NULL,0,hwnd);
Then play it:
Command="play "+szFileName+" from 0";
mciSendString(Command.c_str(),NULL,0,hwnd);
string Command;
Command="open "+szFileName;
mciSendString(Command.c_str(),NULL,0,hwnd);
Then play it:
Command="play "+szFileName+" from 0";
mciSendString(Command.c_str(),NULL,0,hwnd);
This doesnt work for me, i created a new var of type string called Command, and pasted your code, but i get errors with +szFileName+ and how (+)'s are binary operatives, i include string.h
ok, i finally have the program compiling after adding your codem however i get the same error, about the entry point, here is a snip of my code.
_--------------------------------------------------
case IDM_OPEN:
{
OPENFILENAME ofn;
char szFileName[MAX_PATH] = "";
ZeroMemory(&ofn, sizeof(ofn));
ofn.lStructSize = sizeof(ofn); // SEE NOTE BELOW
ofn.hwndOwner = hwnd;
ofn.lpstrFilter = "MPlayer Files(*.wma,*.mp3)\0*.mp3\0All Files (*.*)\0*.*\0";
ofn.lpstrFile = szFileName;
ofn.nMaxFile = MAX_PATH;
ofn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
ofn.lpstrDefExt = "wma","mp3";
if(GetOpenFileName(&ofn))
{
sFileName=szFileName;
string FileName;
FileName="open "+sFileName;
mciSendString(FileName.c_str(),NULL,128,hwnd); <--/*The error lies here, i can replace mciSendString with MessegeBox(hwnd,FileName.c_str(),"open",0 ) and it displays the full extension with the word open in front of it.*/
}
}
break;
_--------------------------------------------------
case IDM_OPEN:
{
OPENFILENAME ofn;
char szFileName[MAX_PATH] = "";
ZeroMemory(&ofn, sizeof(ofn));
ofn.lStructSize = sizeof(ofn); // SEE NOTE BELOW
ofn.hwndOwner = hwnd;
ofn.lpstrFilter = "MPlayer Files(*.wma,*.mp3)\0*.mp3\0All Files (*.*)\0*.*\0";
ofn.lpstrFile = szFileName;
ofn.nMaxFile = MAX_PATH;
ofn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
ofn.lpstrDefExt = "wma","mp3";
if(GetOpenFileName(&ofn))
{
sFileName=szFileName;
string FileName;
FileName="open "+sFileName;
mciSendString(FileName.c_str(),NULL,128,hwnd); <--/*The error lies here, i can replace mciSendString with MessegeBox(hwnd,FileName.c_str(),"open",0 ) and it displays the full extension with the word open in front of it.*/
}
}
break;
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement