Windows 如何刷新AviSaveOptions()显示的列表中显示的视频编解码器,以显示新安装的编解码器?

Windows 如何刷新AviSaveOptions()显示的列表中显示的视频编解码器,以显示新安装的编解码器?,windows,delphi,compression,codec,avi,Windows,Delphi,Compression,Codec,Avi,我有一个带有向导的Delphi6应用程序,可以帮助人们选择合适的视频编解码器。它使用AviSaveOptions()向用户显示视频编解码器列表,以便用户可以选择一个。该选项将保存到磁盘,以便以后重新使用。在向导中的某一点上,如果用户没有合适的视频编解码器,会指示用户使用浏览器下载并安装几种流行视频编解码器中的一种。但是,在他们安装新的视频编解码器并返回到我的应用程序后,当我第二次调用AviSaveOptions()以便他们可以选择新安装的视频编解码器时,列表不会显示新的编解码器 如果我完全退出应

我有一个带有向导的Delphi6应用程序,可以帮助人们选择合适的视频编解码器。它使用AviSaveOptions()向用户显示视频编解码器列表,以便用户可以选择一个。该选项将保存到磁盘,以便以后重新使用。在向导中的某一点上,如果用户没有合适的视频编解码器,会指示用户使用浏览器下载并安装几种流行视频编解码器中的一种。但是,在他们安装新的视频编解码器并返回到我的应用程序后,当我第二次调用AviSaveOptions()以便他们可以选择新安装的视频编解码器时,列表不会显示新的编解码器

如果我完全退出应用程序并返回向导,则调用AviSaveOptions()会在对话框中显示新的编解码器。显然,我想从我的应用程序中刷新列表,这样用户就不必重新加载程序来选择新的编解码器。我确实在调用avisavepoptions()的方法中调用了AviFileInit()和AviFileExit()。我还需要做什么才能更新对话框中AviSaveOptions()显示的编解码器列表,以显示新安装的视频编解码器?下面是我用来调用AviSaveOptions()的代码:

函数doGetUsersCompressorChoice(调用形式:TForm;fccc类型:FOURCC):FOURCC;
变量
//压缩选项文件:TAV压缩选项文件;
压缩选项:TAVICOMPRESSOPTIONS;
研究:朗布尔;
hr:HRESULT;
intfAviStream:IAVIStream;
testVideoFilenameSrc,testVideoFilename:string;
aryCompressOpts:PAVICOMPRESSOPTIONS的数组[0..0];
fullSaveOptsFilePath:字符串;
开始
//fullPathToCompressorOptsFile:='';
如果未分配(计费表),则
引发异常。创建(‘(doGetUsersCompressorChoice)调用表单未分配’);
//确保测试视频文件存在。
testVideoFilenameSrc:=getTestVideoPath\u compsettings+TEST\u COMPRESSION\u VIDEO\u FILENAME;
如果文件不存在(testVideoFilenameSrc),则
引发异常。创建(‘(doGetUsersCompressorChoice)找不到测试视频文件:‘+testVideoFilename);
//复制它,因为我们要修补它,不想损坏它
//原著。
testVideoFilename:=ChangeFileExt(testVideoFilenameSrc,'.comptest.avi');
如果文件存在(testVideoFilename),则
开始
//删除它。
如果不删除文件(testVideoFilename),则
引发异常。创建('(doGetUsersCompressorChoice)无法删除测试视频文件:'+testVideoFilename);
完如果文件存在(testVideoFilename),则
//将源文件复制到测试文件。
如果不是CopyFile(PChar(testVideoFilenameSrc)、PChar(testVideoFilename)、true),则
引发异常。创建(‘(doGetUsersCompressorChoice)无法将源视频文件复制到测试视频文件(source,dest):‘+testVideoFilenameSrc+’,‘+testVideoFilename’;
AVIFileInit;
FillChar(压缩选项),SizeOf(压缩选项),0;
aryCompressOpts[0]:=@压缩选项;
//压缩选项文件:=tavicompressionfile.Create;
尝试
//打开测试视频文件。
hr:=avireamopenfromfile(intfAviStream,PChar(testVideoFilename),fccc类型,0,OF_READ,nil);
checkAviResult('doGetUsersCompressorChoice',hr',无法打开测试视频文件(AVIStreamOpenFromFile)';
//现在提示用户输入所需的压缩机。
res:=AVISaveOptions(callingform.Handle、0、1、intfAviStream、aryCompressOpts[0]);
如果是的话
开始
{
重要提示:Microsoft不将fccType字段用于
调用AviSaveOptions()时,音频压缩器将其保留为0。
为了补偿,我们使用了一个等于
('f','a','k','e')用于音频压缩器。
因此,您无法分辨哪个音频压缩器处于
使用。假的FOURCC只是为了保存压缩机
选项文件对象和方法,因为它们
存储压缩机时需要使用标识符
设置。
我们有一条关于堆栈溢出的消息,但是
到目前为止,还没有人给出如何识别身份的答案
压缩机由压缩机返回
}
如果FfccType=流式音频,则
结果:=stringToFOURCC(四个CC\u假\u音频\u压缩程序\u ID)
其他的
//结果是所选压缩机的四cc。
结果:=aryCompressOpts[0]^.fccHandler;
尝试
FullSaveOptFilePath:=getCompressorOptsFullFilePath(结果);
//将用户选择的压缩程序设置保存到磁盘。
//压缩选项文件.save(aryCompressOpts[0]^);
如果writeCompOptsFile(FullSaveOptFilePath,aryCompressOpts[0]^)无错误,则可以
引发异常。创建(‘(doGetUsersCompressorChoice)无法将压缩程序选项保存到磁盘,文件名:‘+FullSaveOptFilePath);
//返回保存的压缩程序选项文件的完整路径。
//CompressorOptsFile的完整路径:=
//compressionoptionsfile.fullFilename;
最后
//释放压缩选项变量。
AVISaveOptionsFree(1,aryCompressOpts[0]);
完尝试
结束
其他的
开始
//用户中止了操作。只需返回0的结果。
结果:=0;
结束;
最后
//如果已分配(压缩选项文件),则
//压缩选项文件.Free;
AviFileExit;
完尝试
结束;
function doGetUsersCompressorChoice(theCallingForm: TForm; theFccType: FOURCC): FOURCC;
var
    // theCompressionOptionsFile: TAviCompressionOptionsFile;
    theCompressionOptions: TAVICOMPRESSOPTIONS;
    res: LongBool;
    hr: HRESULT;
    intfAviStream: IAVIStream;
    testVideoFilenameSrc, testVideoFilename: string;
    aryCompressOpts: array[0..0] of PAVICOMPRESSOPTIONS;
    fullSaveOptsFilePath: string;
begin
    // fullPathToCompressorOptsFile := '';
    if not Assigned(theCallingForm) then
        raise Exception.Create('(doGetUsersCompressorChoice) The calling form is unassigned.');

    // Make sure the test video file exists.
    testVideoFilenameSrc := getTestVideoPath_compsettings + TEST_COMPRESSION_VIDEO_FILENAME;

    if not FileExists(testVideoFilenameSrc) then
        raise Exception.Create('(doGetUsersCompressorChoice) Unable to find the test video file: ' + testVideoFilename);

    // Copy it since we are about to tinker with it and don't want to damage
    //  the original.
    testVideoFilename := ChangeFileExt(testVideoFilenameSrc, '.comptest.avi');

    if FileExists(testVideoFilename) then
    begin
        // Delete it.
        if not DeleteFile(testVideoFilename) then
            raise Exception.Create('(doGetUsersCompressorChoice) Unable to delete the test video file: ' + testVideoFilename);
    end; // if FileExists(testVideoFilename) then

    // Copy the source to the test file.
    if not CopyFile(PChar(testVideoFilenameSrc), PChar(testVideoFilename), true) then
        raise Exception.Create('(doGetUsersCompressorChoice) Unable to copy the source video file to the test video file (source, dest): ' + testVideoFilenameSrc + ', ' + testVideoFilename);

    AVIFileInit;

    FillChar(theCompressionOptions, SizeOf(theCompressionOptions), 0);

    aryCompressOpts[0] := @theCompressionOptions;

    // theCompressionOptionsFile := TAviCompressionOptionsFile.Create;

    try
        // Open the test video file.
        hr := AVIStreamOpenFromFile(intfAviStream, PChar(testVideoFilename), theFccType, 0, OF_READ, nil);

        checkAviResult('doGetUsersCompressorChoice', hr, 'Unable to open the test video file (AVIStreamOpenFromFile)');

        // Now prompt the user for the desired compressor.
        res := AVISaveOptions(theCallingForm.Handle, 0, 1, intfAviStream, aryCompressOpts[0]);

        if res then
        begin
            {
                IMPORTANT: Microsoft does not use the fccType field for
                audio compressors and leaves it 0 when calling AviSaveOptions().
                To compensate we are using a fake FOURCC equal to
                ('f','a','k','e') for audio compressors.

                Therefore, you can't tell which audio compressor is in
                use.  The fake FOURCC is only to keep the compressor
                options file object and methods happy since they
                need an identifier to use when storing the compressor
                settings.

                We have a message about this on Stack Overflow but
                so far no one has provided an answer on how to ID
                the compressor being returned by

            }

            if theFccType = streamtypeAUDIO then
                Result := stringToFOURCC(FOURCC_FAKE_AUDIO_COMPRESSOR_ID)
            else
                // Result is the FOURCC of the selected compressor.
                Result := aryCompressOpts[0]^.fccHandler;

            try
                fullSaveOptsFilePath := getCompressorOptsFullFilePath(Result);

                // Save the user's selected compressor settings to disk.
                // theCompressionOptionsFile.save(aryCompressOpts[0]^);
                if writeCompOptsFile(fullSaveOptsFilePath, aryCompressOpts[0]^) <> AVIERR_OK then
                    raise Exception.Create('(doGetUsersCompressorChoice) Unable to save the compressor options to disk, file name: ' + fullSaveOptsFilePath);

                // Return the full path to the saved compressor options file.
                // fullPathToCompressorOptsFile :=
                //    theCompressionOptionsFile.fullFilename;
            finally
                // Free the compression options variable.
                AVISaveOptionsFree(1, aryCompressOpts[0]);
            end; // try
        end
        else
        begin
            // User aborted operation.  Just return the Result of 0.
            Result := 0;
        end;
    finally
        // if Assigned(theCompressionOptionsFile) then
        //    theCompressionOptionsFile.Free;

        AviFileExit;
    end; // try
end;