Getting a Pointer to WebTV for Windows

[This is preliminary documentation and subject to change.]

Before your application can register a ITVControl notification sink or use the methods exposed by ITVViewer, it must first obtain a reference to the WebTV for Windows object. Your application cannot create a new instance of WebTV for Windows, so instead it must get a reference to a running instance by calling the GetActiveObject Automation function. To locate more information on GetActiveObject, see Further Information on Television Services for the Client.

Typically, your application gets this reference to WebTV for Windows during its initialization. Getting a WebTV for Windows reference at initialization ensures that WebTV for Windows is available before your application attempts to use it.

The following code obtains a reference to WebTV for Windows:

IUnknown *punk = NULL;
ITVViewer *ptvx = NULL;
 
//Get a reference to WebTV for Windows
GetActiveObject(CLSID_TVViewer, NULL, &punk);
 
// Check whether a reference to WebTV for Windows was returned
if (punk != NULL)
{
  'Get a reference to the ITVViewer interface
  punk->QueryInterface(IID_ITVViewer, (void **)&ptvx);
 
  'Release the WebTV for Windows object
  punk->Release();
}