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 way to get the table mapping??
You haven’t assinged anything to entry, right now it’s just an uninitialised pointer.