E_ACCESSDENIED on CoCreateInstance
Posted
by vucetica
on Stack Overflow
See other posts from Stack Overflow
or by vucetica
Published on 2010-05-18T13:55:47Z
Indexed on
2010/05/18
14:00 UTC
Read the original article
Hit count: 387
com
|directshow
Here is a code snippet
#include "stdafx.h"
#include <tchar.h>
#include <windows.h>
#include <dshow.h>
#include <ExDisp.h>
int _tmain(int argc, _TCHAR* argv[])
{
CoInitialize(NULL);
HRESULT hr = S_OK;
DWORD err = 0;
// Try to create graph builder
IGraphBuilder* pGraph = 0;
hr = CoCreateInstance(CLSID_FilterGraph, NULL,
CLSCTX_INPROC_SERVER, IID_IGraphBuilder, (void**)&pGraph );
err = GetLastError();
// Here, hr is E_ACCESSDENIED
// err is 5 (ERROR_ACCESS_DENIED)
// Try to create capture graph builder (succeeds)
ICaptureGraphBuilder2* pBuild = 0;
hr = CoCreateInstance(CLSID_CaptureGraphBuilder2, NULL, CLSCTX_INPROC_SERVER, IID_ICaptureGraphBuilder2, (void **)&pBuild );
err = GetLastError();
// Here, hr is S_OK
// err is 0 (ERROR_SUCCESS)
// Try to create IWebBrowser (succeeds)
IWebBrowser2* pBrowser = 0;
hr = CoCreateInstance (CLSID_InternetExplorer, NULL, CLSCTX_LOCAL_SERVER, IID_IWebBrowser2, (LPVOID *)&pBrowser);
err = GetLastError();
// Here, hr is S_OK
// err is 0 (ERROR_SUCCESS)
return 0;
}
I'm trying to create IFilterGraph, which fails with E_ACCESSDENIED. On the other hand, creating other directshow objects works ok. The same with some other COM objects (tried with IWebBrowser2 as an example). Any idea what can be the problem? Thanks!
© Stack Overflow or respective owner