Creating an Encoder Agent on a Remote Computer

Windows Media Encoder SDK banner art

To enable remote administration of Windows Media Encoder applications, you must create a WMEncoderAgent object on the remote computer and use it to create one or more instances of Windows Media Encoder. The WMEncoderAgent object passes the string names of the running WMEncoder objects to the IWMEncoderNamesCollection object. You can use these names to retrieve pointers to specific instances of Windows Media Encoder. You can use the pointers to programmatically control Windows Media Encoder on the remote computer.

Note   Windows Media Encoder must be installed on the remote computer. Also, you must use the DCOM Config utility to set the access, launch, and configuration permissions, and identify the users who can administer Windows Media Encoder. For more information, see Specifying DCOM Security Settings.

VBScript Example

' If you use a scripting language you must create a
' WMEncoderAgentLocator object, and use it to create a
' WMEncoderAgent object on the remote computer.

' Declare objects.
Dim AgentLocator
Dim EncoderAgent

' Create a WMEncAgentLocator object.
Set AgentLocator = CreateObject("WMEncLoc.WMEncAgentLocator")

' Create a WMEncoderAgent object on a remote computer.
Set EncoderAgent = AgentLocator.GetAgent("computer name")

Visual Basic Example

' Declare objects and variables.
Dim Encoder As WMEncoder
Dim EncoderApp As WMEncoderApp
Dim EncoderAgent As WMEncoderAgent
Dim EncoderNames As IWMEncoderNamesCollection

' Create a WMEncoderAgent object on a remote computer.
Set EncoderAgent = CreateObject("WMEncAgt.WMEncoderAgent", "computer name")

C++ Example

#ifndef _WIN32_WINNT
#define _WIN32_WINNT 0x0400

// Include libraries.
#include <windows.h>
#include <atlbase.h>
#include <objbase.h>
#include "wmencode.h"
#include "localagent.h"

// Declare variables.

IWMEncoderAgent* pAgent = NULL;

// Create a COSERVERINFO structure containing information
// about the computer on which to create the IWMEncoderAgent
// object.

cs.pwszName = CComBSTR("name of remote computer");
cs.pAuthInfo = NULL;

// Create a MULTI_QI structure to hold an IUnknown pointer
// to a IWMEncoderAgent object.

mqi.pIID = &IID_IWMEncoderAgent;
mqi.pItf = pAgent; = 0;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoderAgent interface on the remote computer.

hr = CoInitialize(NULL);
if ( SUCCEEDED( hr ) )
    hr = CoCreateInstanceEx(CLSID_WMEncoderAgent,

if ( SUCCEEDED( hr ) )
    hr = mqi.pItf->QueryInterface(IID_IWMEncoderAgent,
        (void**) &pAgent);

// Release pointers.
if ( pAgent )
    pAgent = NULL;

See Also