- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在这里尝试做的只是创建一个接口(interface)的实例。真的应该这么简单。一直在关注任何在线资料,阅读我能找到但终生无法解决这个问题的资料。
它归结为从 CoCreateInstance 返回的 HRESULT 是 E_INVALIDARG。我已尽可能多地更改参数以尝试使其正常工作,但仍然无法正常工作。所以请看一眼,希望有人能指出一些我忽略的简单问题。
//Instantiate the sink class and hold a pointer to it.
m_pSink = new CSink();
HRESULT hr = CoInitialize(NULL);
//Get a pointer to sinks IUnknown, no AddRef. CMySink implements only
//dispinterface and the IUnknown and IDispatch pointers will be same.
LPUNKNOWN pUnkSink = m_pSink->GetIDispatch(FALSE);
CLSID clsidInterface;
hr = CLSIDFromProgID(L"Automation.AutomationInterface", &clsidInterface);
ICALib::IAutomationInterface *p_Interface = NULL;
hr = CoCreateInstance(clsidInterface, NULL, CLSCTX_LOCAL_SERVER, ICALib::IID_IAutomationInterface, (void**)p_Interface);
if (hr != S_OK) // Show a message box if the Instance of the interface is not created and do not create the object.
{
CMessageBox(CMessageBox::WARNING_OK).Show(IDS_WARNING_BADLICENSE);
m_failedToCreate = TRUE;
this->~CMainClass();
return;
}
//Establish a connection between source and sink.
//m_pUnkSrc is IUnknown of server obtained by CoCreateInstance().
//m_dwCookie is a cookie identifying the connection, and is needed to terminate the connection.
BOOL result = AfxConnectionAdvise(p_Interface, m_pSink->GetGUID(), pUnkSink, FALSE, &m_dwCookie);
(由于法律责任,此代码中未显示实际名称)
最佳答案
您需要获取 p_Interface
的地址并将其传递给 CoCreateInstance
。事实上,您只是为最后一个参数传递了一个 NULL 指针。
关于c++ - CoCreateInstance 返回 E_INVALIDARG,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25667915/
我正在调查一个 E_INVALIDARG 异常,当我尝试创建第二个常量缓冲区来存储我的灯光信息时抛出该异常: // create matrix stack early CD3D11_B
在 Directx 12 中创建管道状态对象失败并显示 E_INVALIDARG 并且调试层输出一堆废话说 D3D12_GRAPHICS_PIPELINE_STATE_DESC 实例中的数据无效: D
我在这里尝试做的只是创建一个接口(interface)的实例。真的应该这么简单。一直在关注任何在线资料,阅读我能找到但终生无法解决这个问题的资料。 它归结为从 CoCreateInstance 返回的
我将 DirectInput 与 Direct3D 11 一起使用,并针对 x64 进行编译,我从这一行得到一个 E_INVALIDARG: HRESULT hr = DirectInput8Crea
我有一个 ATL COM 组件,它引发一些由托管(C# 和 VB.NET)代码处理的事件。该组件当前由 VS2005 VB.NET 项目(作为 ActiveX 控件)使用,并且引发了所有事件并且一切正
我试图弄清楚为什么我在运行代码时总是收到 E_INVALIDARG 错误。 ID3D11Buffer * cbPerObjectBuffer; cbPerObject cbPerObj; cb
我正在使用 DirectX11 用 C++ 编写程序。现在我想从着色器开始,为此我还需要 ID3D11InputLayout //in main shader.Bind(DeviceContext);
我有以下代码: struct shaderData { char *shaderCode; UINT size; }; struct shaderData *CubeApp::GetS
我正在使用 MediaFoundation使用 SharpDX 对来自 desktop duplication frames 的视频文件进行编码. 我正在创建纹理并捕获屏幕。然后将此纹理传递给 MFC
创建 d3d11 设备和交换链的代码无法在某些计算机上运行并返回 E_INVALIDARG 错误。对于具有相同版本 DirectX 的计算机,这也有所不同。我似乎找不到不同行为的原因。 DXGI_MO
我在调用 CreateGraphicsPipelineState() 时遇到了一个奇怪的错误。该函数返回 E_INVALIDARG,即使描述已全部设置。 之前的描述有效,我尝试将 indexbuffe
我正在尝试用 C++ 初始化 Direct3D11。在安装了 Visual Studio 的机器上(所有这些都在 Windows 10 上运行),它运行良好。在其他计算机(未安装 Visual Stu
好吧,我已经迷路了几个小时了...... IXSLTemplate::putref_stylesheet 不记录除 E_FAIL 之外的任何错误。 但是在我的例子中 putref_stylesheet
问题 我正在尝试调用 ProcessOutput 以从我的解码器获取解码数据并出现以下错误: E_INVALIDARG One or more arguments are invalid. 我尝试过的
COM 接口(interface)方法可以返回各种 HRESULT 值来表示传递的参数值无效。我什么时候返回 E_POINTER 什么时候返回 E_INVALIDARG? 据我所知,如果一个方法在封装
我有以下调用,无论我尝试什么,hresult 总是 E_INVALIDARG: LogMessage(L"Creating swap chain. Emulation: " + std::to_wst
我有一个 WPF 应用程序。在构建它时出现以下错误: Could not load file or assembly or one of its dependencies. The parameter
运行带有函数 DCompositionCreateDevice2 的 Win32C++ 源代码时出现异常问题,这是用 VS 2015 编译的。 源代码编译没有任何错误,但显示上述运行时错误。用VS 2
我有一个 d3dDevice: ComPtrd3dDevice; 我在这里将它用于 dxgiDevice: ComPtr dxgiDevice2; HRESULT hr; hr
我正在尝试在 GPU 内存中创建缓冲区以从 CPU 上传数据。 GPU 访问将是只读的。数据将用作计算着色器的输入缓冲区。 CreateBuffer() 失败并出现错误 0x80070057 (E_I
我是一名优秀的程序员,十分优秀!