共用方式為


開啟 AVI 檔案

[與此頁面相關聯的功能,AVIFile 函式和巨集,是舊版功能。 來源讀取器已取代它。 來源讀取器 已針對 Windows 10 和 Windows 11 優化。 Microsoft 強烈建議新程式碼在可能的情況下使用 Source Reader,而非使用 AVIFile 函數和巨集。 Microsoft建議使用舊版 API 的現有程式代碼,盡可能改寫成使用新的 API。]

下列範例會使用 AVIFileInit 函式初始化 AVIFile 連結庫,並使用 AVIFileOpen 函式開啟 AVI 檔案。 函式會使用預設檔案處理程式。

// LoadAVIFile - loads AVIFile and opens an AVI file. 
// 
// szfile - filename 
// hwnd - window handle 
// 
VOID LoadAVIFile(LPCSTR szFile, HWND hwnd) 
{ 
    LONG hr; 
    PAVIFILE pfile; 
 
    AVIFileInit();          // opens AVIFile library 
 
    hr = AVIFileOpen(&pfile, szFile, OF_SHARE_DENY_WRITE, 0L); 
    if (hr != 0){ 
        // Handle failure.
        return; 
    } 
 
// 
// Place functions here that interact with the open file. 
// 
 
    AVIFileRelease(pfile);  // closes the file 
    AVIFileExit();          // releases AVIFile library 
}