IMMCVersionInfo::GetMMCVersion method (mmc.h)

The GetMMCVersion method retrieves version information for the MMC application.

Syntax

HRESULT GetMMCVersion(
  [out] long *pVersionMajor,
  [out] long *pVersionMinor
);

Parameters

[out] pVersionMajor

The version major number. For example, if *pVersionMajor returns 2, then MMC version 2.x is running.

[out] pVersionMinor

The version minor number. For example, if *pVersionMinor returns 0, then MMC version x.0 is running.

Return value

If successful, the return value is S_OK. Other return values indicate an error code.

Remarks

The IMMCVersionInfo interface is introduced in MMC 2.0. For instructions on how to determine the MMC version if MMC 1.x is installed, see Detecting the MMC Version Number.

Examples

IMMCVersionInfo * pVersionInfo = NULL;
HRESULT   hr;

// Create an object of the MMCVersionInfo class.
hr = CoCreateInstance(CLSID_MMCVersionInfo,
                      NULL,
                      CLSCTX_INPROC_SERVER,
                      IID_IMMCVersionInfo,
                      (void**)&pVersionInfo);
if (S_OK != hr)
{
    // Error encountered.
    // If the system does not support MMCVersionInfo, report it.
    // This would occur if the system was running MMC 1.x.
    if (REGDB_E_CLASSNOTREG == hr)
        OutputDebugString(_T("MMCVersionInfo is not registered\n"));
    else
        // Another error was encountered.
        OutputDebugString(_T("Failed call to CoCreateInstance\n"));
}
else
{
    // Call the GetMMCVersion method.
    long lMajor, lMinor;
    hr = pVersionInfo->GetMMCVersion(&lMajor,
                                     &lMinor);
    if (S_OK != hr)
        OutputDebugString(_T("Failed call to GetMMCVersion\n"));
    else
    {
        OutputDebugString(_T("Success in GetMMCVersion\n"));
        // Use major and minor version information as required.
        // ...
    }
}
// Free the interface pointer.
if (NULL != pVersionInfo)
{
    pVersionInfo->Release();
    pVersionInfo = NULL;
}

Requirements

Requirement Value
Minimum supported client Windows Vista
Minimum supported server Windows Server 2008
Target Platform Windows
Header mmc.h
Library Mmc.lib
DLL Mmcndmgr.dll