Microsoft DirectX 8.1 (C++)

Connecting to the Guide Store (C++)

This topic applies to Windows XP Home Edition and Windows XP Professional only.

The Guide Store, contained in Mstvgs.dll, is an in-process COM server. Because the Guide Store is single-threaded, COM needs to create an apartment for it. Use CoCreateInstanceEx and request the IGuideStore (IID_IGuideStore) interface.

Note   There is no special debug version of the DLL.

In the following example code, the application-defined InitGuideStore function initializes COM and opens the Guide Store. Global declarations and directives relevant to the function are also shown.

#define _WIN32_WINNT 0x0400    // Required for CoInitializeEx.
#import <mstvgs.dll> no_namespace
#include <objbase.h>
IGuideStore*  g_pGuideStore;
.
.
.
BOOL InitGuideStore()
{
    HRESULT hr;
 
    // Initialize COM.
    hr = CoInitializeEx(0, COINIT_APARTMENTTHREADED);
    if (FAILED(hr))
    {
        OutputDebugString("COM failed to initialize");
        return FALSE;  
    }
 
    // Create the GuideStore object.
    MULTI_QI arrInterface[1];
    arrInterface[0].pIID = &__uuidof(IGuideStore);
    arrInterface[0].pItf = static_cast<IUnknown*> (g_pGuideStore);
    arrInterface[0].hr = 0;
    hr = CoCreateInstanceEx(__uuidof(GuideStore),
                            0,   // No aggregation.
                            CLSCTX_INPROC_SERVER,
                            0,   // Create object on local machine.
                            1,   // Number of MULTI_QI structures.
                            &arrInterface[0]);
    if (FAILED(hr))
    {
          OutputDebugString("Unable to create the Guide Store object.");
 
        // Shut down COM.
        CoUninitialize();
        return FALSE;
    }
 
    g_pGuideStore = static_cast<IGuideStore*> (arrInterface[0].pItf);
 
  // Open the default database.
    hr =   g_pGuideStore->Open(_bstr_t(""));
    if (FAILED(hr))
    {
         OutputDebugString("Unable to open the Guide Store database");
 
         // Shut down COM.
         CoUninitialize();
         return FALSE;    
    }
    return TRUE;
}

In the example, an empty string is passed to IGuideStore::Open to open the default database specified in the registry. If the registry key does not exist, a database named Guidestore.mgs is opened in the default media directory.

See Also