If you want to play the file with Windows Media Player, you could try the ShellExecute function:
Code:
ShellExecute(NULL, NULL, TEXT("C:\\SomePath\\filename.wma"), NULL, NULL, SW_SHOWMINNOACTIVE);
If you want to play a WMA file without opening WMP, you can use mci as shown by this webpage. Here is a simple sample:
Code:
#include <windows.h>
#include <stdio.h>
#if defined(_MSC_VER)
#pragma comment(lib, "Winmm.lib")
#endif
BOOL PlaySong(LPCTSTR szFile)
{
TCHAR szCommandString[1000];
wsprintf(szCommandString, TEXT("open \"%s\" type mpegvideo alias MediaFile"), szFile);
/* By default mci functions will return immediately and the task will be carried out
* asynchronously. To have the function wait, place the word "wait" at the end of the
* command string. ie. "play MediaFile wait" */
if (ERROR_SUCCESS == mciSendString(szCommandString, NULL, 0, NULL) &&
ERROR_SUCCESS == mciSendString(TEXT("play MediaFile"), NULL, 0, NULL))
{
return TRUE;
}
return FALSE;
}
int main(void)
{
if ( !PlaySong(TEXT("C:\\PathTo\\My Music\\MySong.wma")) )
{
printf("Failed to play song!");
}
getchar();
return 0;
}
The mci command language has many more options. For example, you can pause and resume, play a specific part of the song and get notification of when the song finishes playing. The mci reference is here.
Another alternative is DirectShow. This is a DirectShow sample that plays a file.