调用函数 put_ClassName 时出现 AccessViolationException

发布于 2024-11-29 15:39:31 字数 887 浏览 0 评论 0原文

我正在尝试使用预定义的函数,但不断收到 AccessViolationException。我也在使用 com 对象。我调用函数 put_ClassName(BSTR obj) 但不断出现异常。

这可能是一个愚蠢的错误,但这里有一个示例:

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);

我不知道为什么会收到此错误。非常感谢任何帮助。

编辑1

看来我没有通过上述调用获得到代理表的映射:

(*pAutomation).get_ProxyFactoryMapping(&pMap);

任何人都可以告诉我是否还有其他方法来获取表映射?

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??

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

冷情妓 2024-12-06 15:39:31

您还没有为条目分配任何内容,现在它只是一个未初始化的指针。

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

維他命╮ 2024-12-06 15:39:31

正如我所想,我使用的 clsid 存在一个愚蠢的错误,现在我可以在代理表中添加一个条目。

此时,我想知道何时应该实例化我的服务器端提供程序和客户端提供程序。另外,它们是否应该在程序的生命周期中存在,因为我想从我的自定义模式中捕获事件。另一件事是,如何将我的自定义模式添加到自动化元素,以便元素可以从我的自定义模式中抛出我的事件。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文