error loading MPG4DECD.dll
-
2012년 4월 14일 토요일 오전 5:59
Hi i am trying to load MPG4DECD.dll in my directshow project but app is crashing when i am adding the loaded filter in my graph. call stack shows that app is crashing in MPG4DECD.dll. Here is my code let me know what i am doing wrong here:
HRESULT CreateObjectFromPath(TCHAR* pPath, REFCLSID clsid, IUnknown** ppUnk) { // load the target DLL directly HMODULE hLib = CoLoadLibrary(OLESTR("C:\\MPG4DECD.dll"), TRUE); if (!hLib) { return HRESULT_FROM_WIN32(GetLastError()); } LPFNGETCLASSOBJECT pfnGetClassObject = NULL; // the entry point is an exported function pfnGetClassObject = (LPFNGETCLASSOBJECT)GetProcAddress(hLib, "DllGetClassObject"); if (pfnGetClassObject == NULL) { return HRESULT_FROM_WIN32(GetLastError()); } // create a class factory IUnknown* pUnk; HRESULT hr = pfnGetClassObject(clsid, IID_IUnknown, (void**)(IUnknown**)&pUnk); if (SUCCEEDED(hr)) { IClassFactory* pCF = (IClassFactory*)pUnk; if (pCF == NULL) { hr = E_NOINTERFACE; } else { // ask the class factory to create the object hr = pCF->CreateInstance(NULL, IID_IUnknown, (void**)ppUnk); } } //CoFreeLibrary(hLib); return hr; }and in main mehtod
IUnknown* pUnk; hr = CreateObjectFromPath(TEXT("c:\\MPG4C32.dll"), __uuidof(CLSID_CMpeg4DecMediaObject), &pUnk); if (SUCCEEDED(hr)) { IBaseFilter* pFilter = (IBaseFilter*)pUnk; g_pGB->AddFilter(pFilter, L"Private Filter");// this is the actual line of error g_pGB->RenderFile(wFileName, NULL); }
i am not using pPath so
TEXT("c:\\MPG4C32.dll")
will not make any diffrence
this code is based upon http://www.gdcl.co.uk/2011/June/UnregisteredFilters.htmRegards
- 편집됨 arslanmkhan 2012년 4월 14일 토요일 오전 8:43
모든 응답
-
2012년 4월 14일 토요일 오전 8:18
You should not be doing this, it's COM-incorrect:
IBaseFilter* pFilter = (IBaseFilter*)pUnk; //line giving access violation exception
To get one interface from another, you need to call IUnknown::QueryInterface. Or rather, since you don't seem to be a good old friend of COM, you can use CComQIPtr template to have it done for you.
CComQIPtr<IBaseFilter> pBaseFilter = pUnk;
It is COM basics, make sure to read some introductory information to learn these fundamentals.
- 답변으로 표시됨 arslanmkhan 2012년 4월 14일 토요일 오전 8:45
- 답변으로 표시 취소됨 arslanmkhan 2012년 4월 16일 월요일 오전 4:02
-
2012년 4월 14일 토요일 오전 8:46thanks alot will you please suggest some good introductory materiel for this
-
2012년 4월 14일 토요일 오전 9:28There are really good books published by MS Press, Inside COM, Inside ATL etc. I don't have a link handly but there should be no problem to google one.
-
2012년 4월 16일 월요일 오전 4:03
after doing this
CComQIPtr<IBaseFilter> pBaseFilter = pUnk;pBaseFilter is NULL does it mean that pUnk does not have the interface IBaseFilter if yes then how can i get filter from
C:\\MPG4DECD.dll

