Play a WMA file

//
// Play a WMA file, the easy way. No MFC required. No UI presented.
// 2003 Glenn Slayden
//
// The argument to PlayWMA can be a URL or local file.
// Install the Windows Media Player 9 SDK (free from Microsoft).
// This example must be linked with the file wmp_i.c, which is in with one of the SDK sample programs.
// The following include file is also in that SDK.
//

#include "\windows media components\wmsdk\wmpsdk9\include\wmp.h"

void PlayWMA(WCHAR *pwch_url)
{
	CLSID clsid_wmp;	// SDK headers are missing an adequate CLSID_ definition, so roll your own
	CLSIDFromString(L"{6BF52A52-394A-11d3-B153-00C04F79FAA6}",&clsid_wmp);

	IWMPCore *p_iwmpcore;
	CoCreateInstance(clsid_wmp,NULL,CLSCTX_ALL,IID_IWMPCore,(void **)&p_iwmpcore);

	BSTR bs = SysAllocString(pwch_url);
	HRESULT hr = p_iwmpcore->put_URL(bs);
	SysFreeString(bs);

	// might want to wait until clip is done playing before doing the following...
	p_iwmpcore->Release();
}