Log in

View Full Version : Installing a filter without Regsvr32.exe


Harlequin
10th May 2003, 06:41
I'm using this code to install Fraunhofer freeDVD filters from my setup program, and it will work with all properly authored filters;)

// This registers a DirectShow Filter
// must be the full path ie. "C:\xyz software\abc.ax" not "abc.ax"

BOOL RegisterFilter(LPSTR szFilterName){
DllRegisterServer RegFilter;
HMODULE Filter;
BOOL RET;

Filter = LoadLibrary(szFilterName);
if(!Filter)return FALSE;

RegFilter = (DllRegisterServer)GetProcAddress(Filter, "DllRegisterServer");
if(RegFilter)RET = SUCCEEDED(RegFilter());
FreeLibrary(Filter);
return RET;
}

// This unregisters a DirectShow Filter.
// Delete the file afterward.

BOOL UnRegisterFilter(LPSTR szFilterName){
DllUnregisterServer UnRegFilter;
HMODULE Filter;
BOOL RET;

Filter = LoadLibrary(szFilterName);
if(!Filter)return FALSE;

UnRegFilter = (DllUnregisterServer)GetProcAddress(Filter, "DllUnregisterServer");
if(UnRegFilter)RET = SUCCEEDED(UnRegFilter());
FreeLibrary(Filter);
return RET;
}

// put the folowing in a header .h .hpp file

typedef HRESULT (*DllUnregisterServer)(void);
typedef HRESULT (*DllRegisterServer)(void);