IWMSPlayer::get_ID

The get_ID method retrieves a unique value that identifies a player that is receiving content from the server.

HRESULT get_ID(
  long*  pVal
);

Arguments

pVal

[out] Pointer to a long containing the ID.

Return Value

If the method succeeds, it returns S_OK. If it fails, it returns an HRESULT error code.

Return code

Number

Meaning

E_POINTER

0x80004003

pVal is a NULL pointer argument.

Remarks

This is not the same as a player’s GUID. If a client uses multiple instances of a specific version of the player to connect to the server, each connection to the server by one of the instances of the player will have a unique session ID. However, the client GUID will be the same for all instances of the player.

Also, the ID number for each connection is based on the total amount of clients that are connected to the server since Windows Media Services was started. For example, if three clients connected to the server after the service starts, they would have ID numbers from one to three. If they disconnect from the server and another client connects to the server, it would have an ID number of four.

Example

#include <windows.h>
#include <atlbase.h>    // Includes CComVariant.
#include "wmsserver.h"

// Declare variables and interfaces.
IWMSServer      *pServer;
IWMSPlayers     *pPlayers;
IWMSPlayer      *pPlayer;

HRESULT         hr;
CComVariant     varIndex;
long            lCount;
long            lValue;

// Initialize the COM library and retrieve a pointer
// to an IWMSServer interface.
hr = CoInitialize(NULL);
hr = CoCreateInstance(CLSID_WMSServer,
                      NULL,
                      CLSCTX_ALL,
                      IID_IWMSServer,
                      (void **)&pServer);
if (FAILED(hr)) goto EXIT;

// Retrieve a pointer to an IWMSPlayers interface
// and retrieve the total count of current connections.
hr = pServer->get_Players(&pPlayers);
if (FAILED(hr)) goto EXIT;
hr = pPlayers->get_Count(&lCount);
if (FAILED(hr)) goto EXIT;

// Retrieve information about each client connection.
for (long x = 0; x < lCount; x++)
{
    varIndex = x;
    hr = pPlayers->get_Item(varIndex, &pPlayer);
    if (FAILED(hr)) goto EXIT;

    // Retrieve the ID of the client.
    hr = pPlayer->get_ID(&lValue);
    if (FAILED(hr)) goto EXIT;

    // Release temporary COM objects.
    pPlayer->Release();
}

EXIT:
    // TODO: Release temporary COM objects and uninitialize COM.

Requirements

Header: wmsserver.h

Library: WMSServerTypeLib.dll

Platform: Windows Server 2003 family, Windows Server 2008 family.

See Also

Reference

IWMSPlayer Interface