Thread: VC6 using WMP (.idl or .tlb help)

  1. #1
    Registered User
    Join Date
    Nov 2004
    Posts
    17

    VC6 using WMP (.idl or .tlb help)

    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?
    Last edited by zcot; 12-29-2004 at 01:14 PM.

  2. #2
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,268
    Did you link to wmp.dll? Check and see if you have a wmp.lib on your computer, and then link to that.

    Also, since you are using COM, you need to call CoInitialize(0) before you use any COM functions.

  3. #3
    Registered User
    Join Date
    Nov 2004
    Posts
    17
    ok thanks..

    yea I know very little about COM, but I guess I'll be learning about it more now.

    And yes, I tried to get linkage to wmp.dll via the SDK-supplied intermediate files wmp.h and wmp.idl files.

    There is no wmp.lib, it doesn't exist in that form I'm guessing because of the .idl posture.

    I guess if I really want to continue this journey then I could "remote" the player from an invisible thread and "->switchToPlayerApplication"... It's only about getting current access to the playing Artist and Title to send to another app... perhaps setup an IWMPEvents scheme and run with it.

    alright thanks again.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Controlling WMP with WM_APPCOMMAND
    By Ehtyar in forum Windows Programming
    Replies: 0
    Last Post: 07-22-2007, 06:00 AM
  2. using VC6 link VC7 static lib error
    By George2 in forum C++ Programming
    Replies: 5
    Last Post: 06-29-2006, 10:58 PM
  3. VC6 directories
    By Magos in forum Tech Board
    Replies: 0
    Last Post: 03-11-2005, 05:52 PM
  4. boost::serialization + vc6
    By Koyaanisqatsi in forum C++ Programming
    Replies: 1
    Last Post: 12-01-2004, 05:43 PM