步驟 3: 支援 QueryInterface
[與此頁面 相關的功能 DirectShow是舊版功能。 它已被 MediaPlayer、 IMFMediaEngine和 Media Foundation 中的音訊/視訊擷取取代。 這些功能已針對Windows 10和Windows 11進行優化。 Microsoft 強烈建議新程式碼盡可能使用 MediaPlayer、 IMFMediaEngine 和 音訊/視訊擷取 ,而不是 DirectShow。 Microsoft 建議盡可能重寫使用舊版 API 的現有程式碼,以使用新的 API。]
若要向用戶端公開篩選的新介面,請執行下列動作:
將 DECLARE_IUNKNOWN 宏包含在篩選準則的公用宣告區段中:
public: DECLARE_IUNKNOWN;
覆寫 CUnknown::NonDelegatingQueryInterface 來檢查兩個介面的 IID:
STDMETHODIMP CGrayFilter::NonDelegatingQueryInterface(REFIID riid, void **ppv) { if (riid == IID_ISpecifyPropertyPages) { return GetInterface( static_cast<ISpecifyPropertyPages*>(this), ppv); } else if (riid == IID_ISaturation) { return GetInterface(static_cast<ISaturation*>(this), ppv); } else { // Call the parent class. return CBaseFilter::NonDelegatingQueryInterface(riid, ppv); // NOTE: This example assumes that the filter inherits directly // from CBaseFilter. If your filter inherits from another class, // call the NonDelegatingQueryInterface method of that class. } }
下一 步:步驟 4。建立屬性頁。
相關主題