can anybody get this to work?
-downloaded the MSWMPSDK10 and wanted to try for a simple example. This sample intends to merely gain an interface to the already running Media Player and output the currently playing song Title and Artist.
The assumptions are that the Media Player is running, and playing a song.
No MFC, or ATL...
(understandably this is not a professional approach but for messing around in the garage it should be a fine example)
Code:
#include <windows.h>
#include <windowsx.h>
#include "wmp.h"
#include "wmpids.h"
//#include "wmp.idl"
//#import "wmp.idl"
#include "logging.h"
int APIENTRY WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpCmdLine, int nCmdShow)
{
LoggingFileObject log;
IWMPCore* Interface;
IWMPMedia3* Media;
log.printf("onward...\n");
HRESULT hr;
//query for WMP to get an interface to it
hr = Interface->QueryInterface(IID_IWMPCore, (void**)&Interface);
//bailout if it doesn't happen
if(hr == E_NOINTERFACE)
{
log.printf("bad situation\n");
return 0;
}
log.printf("moving on...\n");
//add our reference to the interface
hr = Interface->AddRef();
//hope this is not the first reference only!
//the player should've been running already
if(hr > 1)
{
char author[] = "Author";
char lang[] = "en-us";
char song[256];
VARIANT artist;
//get media interface
hr = Interface->get_currentMedia((IWMPMedia* *)&Media);
if(hr == S_OK)
{
hr = Media->get_name((USHORT**)&song);
//if(hr == S_OK)
hr = Media->getItemInfoByType((USHORT*)author, (USHORT*)lang, 0, &artist);
//if(hr == S_OK)
log.printf("Song: %s\n", song);
log.printf("Artist: %s\n", artist.bstrVal);
}
}
else
{
//don't know, maybe should crank up the player then
log.printf("fookd! -better quit screwin around...\n");
}
Interface->Release();
log.printf("done\n");
return 1;
}
the problem I'm having is about linkage for the GUID:
passiveTest.obj : error LNK2001: unresolved external symbol _IID_IWMPCore
I'm guessing it's something to do with the "wmp.idl". The samples from the SDK built w/o an issue, and I've set my built settings in the same manner, but then again this is a slightly different approach using the IID_IWMPCore GUID. None of the samples are using this.
I setup a separate project to try to built a .lib out of the .idl, but that didn't happen, I guess that's not what you do. I was thinking it would be no problem to add linkage for a wmp.lib to the project. This whole .idl issue was a problem anyway from the start because if you don't ALSO have the Internet Development SDK(yes, don't go to the msdn and try to search for the Internet Explorer SDK ; ) -then it won't work at all! Anyhow, after installing the IESDK, at least everything builds without a problem, but I can't get linkage for the GUID.
any suggestions?