I want to get the Windows Schedule Task infomation. I copied this code from MSDN source.
///////////////////////////////////////////////////////////////////
// Call ITaskScheduler::Activate to get the Task object.
///////////////////////////////////////////////////////////////////
ITask *pITask;
LPCWSTR lpcwszTaskName;
lpcwszTaskName = L"Test Task";
hr = pITS->Activate(lpcwszTaskName,
IID_ITask,
(IUnknown**) &pITask);
pITS->Release();
if (FAILED(hr))
{
wprintf(L"Failed calling ITaskScheduler::Activate; error = 0x%x\n",hr);
CoUninitialize();
return 1;
}
It works very well on my Win10 X64 computer. But it fails on another Win7 X86 computer.
When I use Remote Debugger, the error code is 0x80070002
. VS debugger tells me it means ERROR_FILE_NOT_FOUND
. But I go to the definition of ERROR_FILE_NOT_FOUND
#define ERROR_FILE_NOT_FOUND 2L
It's a different code.
And When I run the program directly on the Win7 x86 computer. It gave me another error code
0x8007007b
I can't find the meaning. So I don't know why the calling fails on the Win7 computer.
0x80070002
equals HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND)
, so it means the same as ERROR_FILE_NOT_FOUND
.
0x8007007b
equals HRESULT_FROM_WIN32(ERROR_INVALID_NAME)
.
So both error codes seem to indicate that the task you are looking for doesn't exist.
In the future, when you see an error code starting with 0x8
it most likely is a HRESULT
value. Dissecting the HRESULT
code as described by Wikipedia gives:
0x80000000
means failure.(hr & 0x07FF0000 ) >> 16
) which means Win32 errorhr & 0xFFFF
-> 0x0002
and 0x007b
in these cases) are the actual error value which you can look up in the reference.Firegiant provides a nice web service for directly looking up HRESULT
values and other kinds of error codes.
User contributions licensed under CC BY-SA 3.0