开发者

AccessViolationException when calling function put_ClassName

I am trying to use a predefined function but keep getting an AccessViolationException. I am using com objects as well. I call the function put_ClassName(BSTR obj) but keep getting an exception.

This is probably a silly error but here is a sample:

IUIAutomationProxyFactory* factory;
IUIAutomationProxyFactoryEntry* entry;
IUIAutomationProxyFactoryMapping* pMap;
LPCWSTR className = L"CustomUIAutomationCPP";
BSTR name;

CoInitialize(NULL);
HRESULT hr = CoCreateInstance(CLSID_CUIAutomation, NULL, CLSCTX_ALL, IID_IUIAutomation, (void**)&pAutomation);
(*pAutomation).get_ProxyFactoryMapping(&pMap);
factory = new CustomProxyFactory();
(*pAutomation).CreateProxyFactoryEntry(factory, &entry);

name = SysAllocString(className);
(*entry).put_ClassName(className);

I have no clue why I am getting this error. Any help is much appreciated.

EDIT 1

It seems I am not getting the mapping to the proxy table with the above call to:

(*pAutomation).get_ProxyFactoryMapping(&pMap);

Can anyone tell me if there is another wa开发者_JAVA百科y to get the table mapping??


You haven't assinged anything to entry, right now it's just an uninitialised pointer.


As I thought, there was a silly mistake with the clsid that I was using and now I am able to make an entry in the proxy table.

At this point, I am wondering when I am suppose to be instantiating my server-side provider and my client-side provider. Also, whether or not they should exist for the lifetime of the program since I would like to catch events from my custom pattern. One more thing, how to add my custom pattern to automation elements so the elements can throw my events from my custom pattern.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜