變更系統設定檔版本
[與此頁面相關聯的功能 Windows Media Format 11 SDK是舊版功能。 來源讀取器 和 匯集寫入器已取代它。 來源讀取器 和 接收寫入器 已針對 Windows 10 和 Windows 11 優化。 Microsoft強烈建議新程式碼盡可能使用 來源讀取器 和 輸出寫入器,而不是 Windows Media Format 11 SDK。 Microsoft建議使用舊版 API 的現有程式代碼,盡可能改寫成使用新的 API。]
每當您建立設定檔管理員物件時,它會剖析系統配置檔。 您可以使用 IWMProfileManager::GetSystemProfileCount 和 IWMProfileManager::LoadSystemProfile 方法來逐一查看系統配置檔,但配置檔管理員一次只會計算並列出單一版本的配置檔。 如果您想要使用此方法來尋找系統設定檔,您必須確定設定檔管理員會處理您想要的版本。 使用 IWMProfileManager2 介面的方法,來設定和擷取配置檔管理員所使用的系統配置檔版本。
版本是透過使用 WMT_VERSION 列舉型別的成員來指定。 如果您將系統配置檔版本設定為 WMT_VER_9_0,呼叫將會成功,但系統配置檔計數會是零。 這是因為沒有預先定義的系統配置檔使用 Windows 媒體音訊和視訊 9 系列編解碼器。 如需更新設定檔以使用最新編解碼器的詳細資訊,請參閱 重複使用串流組態。
如果您依其 GUID 識別碼載入系統設定檔,則設定檔管理員所使用的系統設定檔版本並不重要。 如需載入系統設定檔的詳細資訊,請參閱 載入系統設定檔。
下列範例程式代碼示範如何設定和擷取系統配置檔版本。 此範例會針對控制台輸出使用 printf,而且需要包含 stdio.h。 如需使用此程式碼的詳細資訊,請參閱 使用程式碼範例。
int main(void)
{
HRESULT hr = S_OK;
IWMProfileManager* pProfileMgr = NULL;
IWMProfileManager2* pProfileMgr2 = NULL;
WMT_VERSION profileVersion;
// Initialize COM.
hr = CoInitialize(NULL);
if(FAILED(hr))
{
printf("Could not initialize COM.");
return 0;
}
// Create a profile manager object.
hr = WMCreateProfileManager(&pProfileMgr);
if(FAILED(hr))
{
printf("Could not create a profile manager object.");
return 0;
}
// Get the IWMProfileManager2 interface.
hr = pProfileMgr->QueryInterface(IID_IWMProfileManager2,
(void**) &pProfileMgr2);
if(FAILED(hr))
{
printf("Could not get the IWMProfileManager2 interface.");
SAFE_RELEASE(pProfileMgr);
return 0;
}
// Release the old interface.
SAFE_RELEASE(pProfileMgr);
// Get the current system profile version.
hr = pProfileMgr2->GetSystemProfileVersion(&profileVersion);
if(FAILED(hr))
{
printf("Could not retrieve profile version.");
printf("\nError code: 0x%X\n", hr);
SAFE_RELEASE(pProfileMgr2);
return 0;
}
// Display the current version.
printf("Current version: ");
switch(profileVersion)
{
case WMT_VER_4_0:
printf("WMT_VER_4_0\n");
break;
case WMT_VER_7_0:
printf("WMT_VER_7_0\n");
break;
case WMT_VER_8_0:
printf("WMT_VER_8_0\n");
break;
case WMT_VER_9_0:
printf("WMT_VER_9_0\n");
break;
}
// Set the system profile version to 8.
profileVersion = WMT_VER_8_0;
hr = pProfileMgr2->SetSystemProfileVersion(profileVersion);
if(FAILED(hr))
{
printf("Could not change profile version.");
printf("\nError code: 0x%X\n", hr);
SAFE_RELEASE(pProfileMgr2);
return 0;
}
// Print verification.
printf("Successfully set version to ");
switch(profileVersion)
{
case WMT_VER_4_0:
printf("WMT_VER_4_0\n");
break;
case WMT_VER_7_0:
printf("WMT_VER_7_0\n");
break;
case WMT_VER_8_0:
printf("WMT_VER_8_0\n");
break;
case WMT_VER_9_0:
printf("WMT_VER_9_0\n");
break;
}
// Clean up.
SAFE_RELEASE(pProfileMgr2);
}
相關主題