Click here to Skip to main content
15,884,298 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,

I have a c++ application. From which i wants to communicate to Windows task scheduler to create a task. So i just wrote c++ console application( and the code i got from MSDN()[^]). the code snippet is shown below.

C#
//  Save the task in the root folder.
 IRegisteredTask *pRegisteredTask = NULL;
 hr = pRootFolder->RegisterTaskDefinition(
         _bstr_t( wszTaskName ),
         pTask,
         TASK_CREATE_OR_UPDATE,
         _variant_t(),
         _variant_t(),
         TASK_LOGON_INTERACTIVE_TOKEN,
         _variant_t(L""),
         &pRegisteredTask);
 if( FAILED(hr) )
 {
    // printf("\nError saving the Task : %x", hr );
     pRootFolder->Release();
     pTask->Release();
     CoUninitialize();
     return 1;
 }


which is working well in console application. But when i used the same code in MFC dialog based application the same API return an error "The task XML is missing a required element or attribute". Can anyone answer the behavior difference?
Posted
Comments
barneyman 23-Jun-15 3:13am    
what model are you initialing COM with in your console app?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900