2

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 -> Release();
    task -> Release();
    CoUninitialize();
    return false;
}

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

Tadmas
  • 6,238
  • 3
  • 39
  • 31
Sascha
  • 41
  • 7

1 Answers1

2

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.

Tadmas
  • 6,238
  • 3
  • 39
  • 31
  • This answer would be perfect if you'd show how to break down the `hr` into its components. – Mark Ransom Jan 13 '11 at 01:52
  • How would that help in this case? In all the years I've worked with COM, I think I've had to do that maybe twice. – Tadmas Jan 13 '11 at 01:57
  • Thank you :), it worked I can schedule my task now :) This task scheduler stuff in win32 is rather complex, do you know of any tutorials that describe what each IWhateva (ITask, IAction, etc.) does? – Sascha Jan 13 '11 at 02:30
  • No problem. If you get an answer on the site that solves your problem, you can click the checkmark next to it to "accept" it. As for tutorials, a lot of the funkiness comes from COM itself, which is a crazy complex system. (Your problem is actually a generic problem with COM and not specific to the task scheduler.) I'd look at a COM tutorial first. Don't know of any good ones myself, though. And I know pretty much nothing about the task scheduler API, sorry. – Tadmas Jan 13 '11 at 02:39
  • Dunno if you've tried the MSDN documentation yet: http://msdn.microsoft.com/en-us/library/aa446802(v=vs.85).aspx -- sometimes the overview sections can be helpful. – Tadmas Jan 13 '11 at 02:41