建立資料流程處理常式的虛擬函式資料表
[與此頁面相關聯的功能 自訂檔案和資料流程處理常式是舊版功能。 MediaStreamSource 類別已取代它。 MediaStreamSource 類別已針對Windows 10和Windows 11進行優化。 Microsoft 強烈建議新程式碼盡可能使用 MediaStreamSource 類別 ,而不是 自訂檔案和資料流程處理常式。 Microsoft 建議使用舊版 API 的現有程式碼盡可能重寫為使用新的 API。
下列範例 (以 C) 撰寫,示範應用程式如何 (AVIBall) 建立用來參考其服務的虛擬函式資料表。
HRESULT STDMETHODCALLTYPE AVIBallQueryInterface (PAVISTREAM ps,
REFIID riid, LPVOID FAR* ppvObj);
HRESULT STDMETHODCALLTYPE AVIBallCreate (PAVISTREAM ps,
LONG lParam1, LONG lParam2);
ULONG STDMETHODCALLTYPE AVIBallAddRef (PAVISTREAM ps);
ULONG STDMETHODCALLTYPE AVIBallRelease (PAVISTREAM ps);
HRESULT STDMETHODCALLTYPE AVIBallInfo (PAVISTREAM ps,
AVIStreamHeader FAR * psi, LONG lSize);
LONG STDMETHODCALLTYPE AVIBallFindSample (PAVISTREAM ps,
LONG lPos, LONG lFlags);
HRESULT STDMETHODCALLTYPE AVIBallReadFormat (PAVISTREAM ps,
LONG lPos, LPVOID lpFormat, LONG FAR *lpcbFormat);
HRESULT STDMETHODCALLTYPE AVIBallSetFormat (PAVISTREAM ps,
LONG lPos, LPVOID lpFormat, LONG cbFormat);
HRESULT STDMETHODCALLTYPE AVIBallRead (PAVISTREAM ps,
LONG lStart, LONG lSamples, LPVOID lpBuffer, LONG cbBuffer,
LONG FAR * plBytes,LONG FAR * plSamples);
HRESULT STDMETHODCALLTYPE AVIBallWrite (PAVISTREAM ps, LONG lStart,
LONG lSamples, LPVOID lpBuffer, LONG cbBuffer, DWORD dwFlags);
HRESULT STDMETHODCALLTYPE AVIBallDelete (PAVISTREAM ps,
LONG lStart, LONG lSamples);
HRESULT STDMETHODCALLTYPE AVIBallReadData (PAVISTREAM ps,
DWORD fcc, LPVOID lp,LONG FAR *lpcb);
HRESULT STDMETHODCALLTYPE AVIBallWriteData (PAVISTREAM ps,
DWORD fcc, LPVOID lp,LONG cb);
IAVIStreamVtbl AVIBallHandler = {
AVIBallQueryInterface, // Function pointer for ::QueryInterface
AVIBallAddRef, // Function pointer for ::AddRef
AVIBallRelease, // Function pointer for ::Release
AVIBallCreate, // Function pointer for ::Create
AVIBallInfo, // Function pointer for ::Info
AVIBallFindSample, // Function pointer for ::FindSample
AVIBallReadFormat, // Function pointer for ::ReadFormat
AVIBallSetFormat, // Function pointer for ::SetFormat
AVIBallRead, // Function pointer for ::Read
AVIBallWrite, // Function pointer for ::Write
AVIBallDelete, // Function pointer for ::Delete
AVIBallReadData, // Function pointer for ::ReadData
AVIBallWriteData // Function pointer for ::WriteData
};
檔案處理常式會使用類似的程式,不同之處在于它們會針對虛擬函式資料表使用不同的定義。