使用DSPack从文件加载directshow过滤器

时间:2017-05-22 07:39:04

标签: delphi directshow dspack

如何使用DSPack加载未在delphi 7中的.ax文件注册的DirectShow过滤器? 我发现an example in C++,我不知道如何将其翻译成Delphi。

1 个答案:

答案 0 :(得分:3)

Here you go

function LoadFilter(const Fhandle: HMODULE; clis: TGUID): IBaseFilter; overload;
Var
  DllGetClassObject: Function(Const clsid, IID: TGUID; Var Obj)
    : HRESULT; STDCALL;
  ClassF: IClassFactory;
Begin
  result := nil;
  try
    If Fhandle = 0 Then
      exit;
    // NOTE: Fhandle is typically obtained as a result of LoadLibrary API
    //       call loading DLL hosting the DirectShow filter
    DllGetClassObject := GetProcAddress(Fhandle, 'DllGetClassObject');
    DllGetClassObject(clis, IClassFactory, ClassF);
    if assigned(ClassF) then
    begin
      if ClassF.CreateInstance(nil, IID_IBaseFilter, result) = ERROR_SUCCESS
      then
        exit;
    end;
  except
    exit;
  end;
end;