共用方式為


在 AVI 檔案中開啟數據流並關閉檔案

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

下列範例會使用 AVIFileGetStream 函式開啟 AVI 檔案中的所有數據流。 如果發生錯誤,檔案會關閉。

// InsertAVIFile - opens the streams in an AVI file. 
// 
// pfile - file-interface pointer from AVIFileOpen 
// 
// Global variables 
// gcpavi - count of the number of streams in an AVI file 
// gapavi[] = array of stream-interface pointers 
 
void InsertAVIFile(PAVIFILE pfile, HWND hwnd, LPSTR lpszFile) 
{ 
    int    i; 
    gcpavi = 0; 
 
    // Open the streams until a stream is not available. 
    for (i = gcpavi; i < MAXNUMSTREAMS; i++) { 
        gapavi[i] = NULL; 
        if (AVIFileGetStream(pfile, &gapavi[i], 0L, i - gcpavi) 
            != AVIERR_OK) 
        break; 
 
    if (gapavi[i] == NULL) 
        break; 
    } 
    // Display error message-stream not found. 
    if (gcpavi == i) 
    { 
        // Handle failure.
        if (pfile) // If file is open, close it 
            AVIFileRelease(pfile); 
        return; 
    } 
    else { 
        gcpavi = i - 1; 
    } 
 
//  . 
//  . Place functions to process data here. 
//  . 
}