Freigeben über


IWMDMDevice3::GetFormatCapability-Methode (mswmdm.h)

Die GetFormatCapability-Methode ruft Geräteunterstützung für Dateien eines angegebenen Formats ab. Die Funktionen werden als unterstützte Eigenschaften und ihre zulässigen Werte ausgedrückt.

Syntax

HRESULT GetFormatCapability(
  [in]  WMDM_FORMATCODE        format,
  [out] WMDM_FORMAT_CAPABILITY *pFormatSupport
);

Parameter

[in] format

Wert aus der WMDM_FORMATCODE Enumeration, die das abgefragte Format darstellt.

[out] pFormatSupport

Zeiger auf die zurückgegebene WMDM_FORMAT_CAPABILITY-Struktur , die unterstützte Eigenschaften und deren zulässige Werte enthält. Diese Werte müssen von der Anwendung freigegeben werden, wie unter Abrufen von Formatfunktionen auf Geräten, die IWMDMDevice3 unterstützen.

Rückgabewert

Die Methode gibt ein HRESULT zurück. Alle Schnittstellenmethoden in Windows Media Geräte-Manager können eine der folgenden Klassen von Fehlercodes zurückgeben:

  • Com-Standardfehlercodes
  • In HRESULT-Werte konvertierte Windows-Fehlercodes
  • Windows Media Geräte-Manager Fehlercodes
Eine ausführliche Liste möglicher Fehlercodes finden Sie unter Fehlercodes.

Hinweise

Der Client kann die Liste der unterstützten Formate abrufen, indem er die IWMDMDevice3::GetProperty-Methode verwendet, um die g_wszWMDMFormatsSupported Geräteeigenschaft abzufragen.

Für ein bestimmtes Format kann ein Client diese Funktion aufrufen, um die unterstützten Eigenschaften abzurufen und Informationen zu Konfigurationen unterstützter Eigenschaften abzurufen (z. B. Kombinationen aus Bitrate und Samplerate). Diese Informationen werden als Formatfunktion ausgedrückt.

Beispiele

Die folgende Funktion wird mit einem Gerätezeiger und einem Formatcode übergeben und ruft die Formatfunktionen des Geräts für dieses Format ab. Die Funktion verwendet eine benutzerdefinierte Funktion, um die abgerufenen Werte zu löschen. Diese benutzerdefinierte Funktion wird unter Abrufen von Formatfunktionen auf Geräten angezeigt, die IWMDMDevice3 unterstützen.


// Each format configuration is described by a WMDM_FORMAT_CAPABILITY enum, and
// has a WMDM_FORMAT_CAPABILITY structure describing the device capabilities for that format.
//        Each WMDM_FORMAT_CAPABILITY structure has a WMDM_PROP_CONFIG structure listing configurations.
//            Each WMDM_PROP_CONFIG has a WMDM_PROP_DESC describing a specific format configuration.
//                Each WMDM_PROP_DESC holds specific values as a range, a set, or a flag meaning all values are accepted.
HRESULT myGetFormatCaps(WMDM_FORMATCODE formatCode, IWMDMDevice3* pDevice)
{
    HRESULT hr = S_OK;

    // Get a list of supported configurations for the format.
    WMDM_FORMAT_CAPABILITY formatCapList;
    hr = pDevice->GetFormatCapability(formatCode, &formatCapList);
    HANDLE_HR(hr, "Got a WMDM_FORMATCODE structure in GetCaps","Couldn't get a WMDM_FORMATCODE structure in GetCaps");

    // Print out the format name.
    // TODO: Display a banner for device formats.
    PrintWMDM_FORMATCODE(formatCode); // Custom function to print out the format code.
    

    // Loop through the configurations and examine each one.
    for(UINT iConfig = 0; iConfig < formatCapList.nPropConfig; iConfig++)
    {
        WMDM_PROP_CONFIG formatConfig = formatCapList.pConfigs[iConfig];

        // Preference level for this configuration (lower number means more preferred).
        // TODO: Display a banner for the preference-level output.

        // Loop through all properties for this configuration and get supported
        // values for the property. Values can be a single value, a range, 
        // or a list of enumerated values.
        for(UINT iDesc = 0; iDesc < formatConfig.nPropDesc; iDesc++)
        {
            WMDM_PROP_DESC propDesc = formatConfig.pPropDesc[iDesc];
            // TODO: Display the property name.

            // Three ways a value can be represented: any, a range, or a list.
            switch (propDesc.ValidValuesForm)
            {
                case WMDM_ENUM_PROP_VALID_VALUES_ANY:
                    // TODO: Display a message indicating that all values are valid.
                    break;
                case WMDM_ENUM_PROP_VALID_VALUES_RANGE:
                    {
                        // List these in the docs as the propvariants set.
                        WMDM_PROP_VALUES_RANGE rng = propDesc.ValidValues.ValidValuesRange;
                        // TODO: Display a banner for the values to follow
                        // TODO: Display the max value.
                        // TODO: Display the min value.
                        // TODO: Display the step value.
                    }
                    break;
                case WMDM_ENUM_PROP_VALID_VALUES_ENUM:
                    {
                        // TODO: Display a banner for the values to follow.
                        WMDM_PROP_VALUES_ENUM list = propDesc.ValidValues.EnumeratedValidValues;
                        PROPVARIANT pVal;
                        for(UINT iValue = 0; iValue < list.cEnumValues; iValue++)
                        {
                            pVal = list.pValues[iValue];
                            // TODO: Display the current value.
                            PropVariantClear(&pVal);
                            PropVariantInit(&pVal);
                        }
                    }

                    break;
                default:
                    HANDLE_HR(E_FAIL, "Undefined configuration type in GetCaps" << endl, "");
                    break;
            }
        }
    }
    // Now clear the memory used by WMDM_FORMAT_CAPABILITY.
    FreeFormatCapability(formatCapList);

e_Exit:
    return hr;
}

Anforderungen

Anforderung Wert
Zielplattform Windows
Kopfzeile mswmdm.h
Bibliothek Mssachlp.lib

Weitere Informationen

Ermitteln von Geräteformatfunktionen

IWMDMDevice3-Schnittstelle