开发者

Windows Task Scheduler: IAction.QueryInterface() returns an error I cannot find a definition for

I am attempting to schedule a task (to open an .exe at a specific time) using C++ win32. But at one specific point I am getting an error, I have searched & searched to try & find the definition of this error but I cannot find it?

Do you know what this error means: Hexadecimal: 80004003 Decimal: 2147500035

I wont post the whole function because its rather long (unless you may need it to determine the error context?).

The code I am using (that causes the error) is the following:

//  QI for the executable task pointer.
hr = action -> QueryInterface( IID_IExecAction, (void**) execAction );
action -> Release();

if( FAILED(hr) )
{
    printf("QueryInterface call failed for IExecAction: %x %X %u \n", hr, hr, hr );
    rootFolder -> Re开发者_开发知识库lease();
    task -> Release();
    CoUninitialize();
    return false;
}

The output is: QueryInterface call failed for IExecAction: 80004003 80004003 2147500035


0x80004003 is an "invalid pointer" error, a.k.a. E_POINTER.

I assume the declaration of execAction is something like:

IExecAction* execAction = NULL;

But, QueryInterface expects a pointer to an interface pointer. In other words, you pass a storage location in which to place an IUnknown*... or, in this specific case, a IExecAction*.

So, you need to pass the address of execAction so QueryInterface can return the interface pointer to you. As in:

hr = action -> QueryInterface( IID_IExecAction, (void**) &execAction );

I assume this is what's happening since initializing pointer values to NULL is a common coding practice, and QueryInterface is documented to return E_POINTER when the second argument is NULL. If not, please update your question with the declaration of execAction.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜