Profilleri Kaydetme

[Windows Media Format 11 SDK bu sayfayla ilişkilendirilmiş özellik eski bir özelliktir. Kaynak Okuyucu ve Havuz Yazıcısıtarafından değiştirildi. Kaynak Okuyucu ve Havuz Yazıcısı Windows 10 ve Windows 11 için iyileştirilmiştir. Microsoft, yeni kodların mümkün olduğunda Source Reader ve Sink Writer kullanmasını, Windows Media Format 11 SDKyerine kesinlikle önerir. Microsoft, mümkünse yeni API'leri kullanmak için eski API'leri kullanan mevcut kodun yeniden yazılmasını önerir.]

Profil nesnesinin içeriğini XML ile biçimlendirilmiş bir dizeye kaydetmek için IWMProfileManager::SaveProfileyönteminikullanabilirsiniz. Profil dizesini bir dosyaya depolamak için hiçbir yöntem sağlanmadı; seçtiğiniz dosya G/Ç yordamlarını kullanabilirsiniz.

Not

Bir dosyaya yazılan profil dizesini hiçbir zaman değiştirmemelisiniz. Profilde yapmak istediğiniz tüm değişiklikler program aracılığıyla yapılmalıdır. .prx dosyasındaki değerlerin değiştirilmesi öngörülemeyen sonuçlara neden olabilir.

 

Aşağıdaki örnek, standart C stilinde dosya G/Ç kullanarak bir profili bir dosyaya kaydetme işlevidir. Bu örneği kullanan bir uygulamayı derlemek için projenize stdio.h eklemeniz gerekir.

HRESULT ProfileToFile(IWMProfileManager* pProfileMgr, 
                      IWMProfile* pProfile)
{
    HRESULT hr = S_OK;

    FILE*   pFile;
    
    WCHAR*  pwszProfileString = NULL;
    DWORD   cchProfileString = 0;

    // Save the profile to a string.
    // First, retrieve the size of the string required.
    hr = pProfileMgr->SaveProfile(pProfile, 
                                  NULL, 
                                  &cchProfileString);
    if(FAILED(hr))
    {
        printf("Could not get the profile string size.");
        return hr;
    }

    // Allocate memory to hold the string.
    pwszProfileString = new WCHAR[cchProfileString];

    if(pwszProfileString == NULL)
    {
        printf("Could not allocate memory for the profile string.");
        return E_OUTOFMEMORY;
    }

    // Retrieve the string.
    hr = pProfileMgr->SaveProfile(pProfile, 
                                  pwszProfileString, 
                                  &cchProfileString);
    if(FAILED(hr))
    {
        printf("Could not save the profile string.");
        return hr;
    }

    // Create the output file.
    pFile = fopen("MyProfile.prx", "w");

    // Write the profile string to the file.
    fprintf(pFile, "%S\n", pwszProfileString);

    // Close the file.
    fclose(pFile);

    delete[] pwszProfileString;

    return S_OK;
}

Profillerle Çalışma