本文整理汇总了C++中ITask::SetApplicationName方法的典型用法代码示例。如果您正苦于以下问题:C++ ITask::SetApplicationName方法的具体用法?C++ ITask::SetApplicationName怎么用?C++ ITask::SetApplicationName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ITask
的用法示例。
在下文中一共展示了ITask::SetApplicationName方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SetTaskProperties
//---------------------------------------------------------------------------
void TTaskScheduler::SetTaskProperties(wstring taskName, TTaskParams taskParams){
ITask *pITask = Activate(taskName);
if(pITask == NULL){
return;
}
if(taskParams.accountName.length() > 0 && taskParams.accountPwd.length() > 0){
pITask->SetAccountInformation(taskParams.accountName.data(),
taskParams.accountPwd.data());
}
if(taskParams.appName.length() > 0){
pITask->SetApplicationName(taskParams.appName.data());
}
if(taskParams.appParameters.length() > 0){
pITask->SetParameters(taskParams.accountName.data());
}
if(taskParams.comments.length() > 0){
pITask->SetComment(taskParams.comments.data());
}
if(taskParams.workingDirectory.length() > 0){
pITask->SetWorkingDirectory(taskParams.workingDirectory.data());
}
Save(pITask);
pITask->Release();
}
示例2: setScheduleTask
/**
* Set a Task into task scheduler. It takes values to insert from Schedule form.
* If task already exists, it is updated with passed parameters.
* Starting time is always set to current time (task starts now).
*
* @param frequency : NEVER or EVERY_DAY
* @param dayNum : repeate the task every 'dayNum'
* @param minNum : repeate the task every 'minNum'
* @return 0 if no errors.
*/
int setScheduleTask (const char* frequency, const int dayNum, const int minNum) {
HRESULT hr = S_OK;
bool newTask = false;
ITaskScheduler* pITS = NULL;
ITask* pITask;
IPersistFile* pIPersistFile;
wstring taskName, user;
// Init COM library & create instance for Task scheduler.
if ((pITS = initScheduleInstance()) == NULL) {
goto error;
}
// Task is associated with current user
if (getScheduledTaskName(taskName)) {
goto error;
}
// We need the extended username "MACHINE\USER" to ensure that
// the job can run also for users logged in with another domain (ref bug #307010).
if (getWindowsUserEx(user)) {
goto error;
}
//
// Try to open EXISTING TASK.
//
LOG.debug("Try opening the Windows task: \"%ls\"", taskName.c_str());
hr = pITS->Activate(taskName.c_str(),
IID_ITask,
(IUnknown**) &pITask);
if (FAILED(hr)) {
if (hr == E_OBJECT_NOT_FOUND) {
//
// NEW TASK -> create it.
//
LOG.debug(DBG_SCHED_TASK_NOT_FOUND);
newTask = true;
WCHAR path[512];
OutlookConfig* config = OutlookConfig::getInstance();
// Get current working dir (from config)
const char* t = config->getWorkingDir();
WCHAR* wt = toWideChar(t);
wsprintf(path, TEXT("\"%s\\%s\""), wt, TEXT(PROGRAM_NAME_EXE));
delete [] wt; wt = NULL;
hr = pITS->NewWorkItem(taskName.c_str(), // Name of task
CLSID_CTask, // Class identifier
IID_ITask, // Interface identifier
(IUnknown**)&pITask); // Address of task interface
if (FAILED(hr)) {
char* msg = readSystemErrorMsg(hr);
setErrorF(getLastErrorCode(), ERR_SCHED_NEWWORKITEM, hr, msg);
delete [] msg;
pITS->Release();
goto error;
}
// Set path and comment on new task.
pITask->SetApplicationName(path);
pITask->SetComment(SCHED_COMMENT);
}
else {
char* msg = readSystemErrorMsg(hr);
setErrorF(getLastErrorCode(), ERR_SCHED_ACTIVATE, hr, msg);
delete [] msg;
pITS->Release();
goto error;
}
}
pITS->Release();
//
// Set task params: flags, account info, parameters
if (strcmp(NEVER, frequency) == 0) {
pITask->SetFlags(TASK_FLAG_DISABLED);
}
else {
pITask->SetAccountInformation(user.c_str(), NULL);
pITask->SetFlags(TASK_FLAG_INTERACTIVE | TASK_FLAG_RUN_ONLY_IF_LOGGED_ON);
}
// ...so we have "OutlookPlugin.exe schedule"
pITask->SetParameters(SCHED_PARAM);
//.........这里部分代码省略.........
示例3: SaveTask
//.........这里部分代码省略.........
hr = pISched->NewWorkItem ( T2COLE ( szTaskName ), CLSID_CTask,
IID_ITask, &pIUnk );
if ( FAILED(hr) )
{
TRACE1("CScheduledTask::SaveTask() - couldn't create a new work item. Return = 0x%08X\n",
(DWORD) hr );
return hr;
}
// We now have an IUnknown pointer. This is queried for an ITask
// pointer on the work item we just added.
hr = pIUnk->QueryInterface ( IID_ITask, (void **) &pITask );
if ( FAILED(hr) )
{
TRACE1("CScheduledTask::SaveTask() - QI() on IUnknown failed to get an ITask. Return = 0x%08X\n",
(DWORD) hr );
return hr;
}
// Clean up the IUnknown, as we are done with it.
pIUnk->Release();
pIUnk = NULL;
// Set the program name.
hr = pITask->SetApplicationName ( T2COLE( (LPCTSTR) m_sProgramPath ));
if ( FAILED(hr) )
{
TRACE1("CScheduledTask::SaveTask() - failed to set application. Return = 0x%08X\n",
(DWORD) hr );
return hr;
}
// Set the app's parameters.
if ( m_sParameters.GetLength() > 0 )
{
hr = pITask->SetParameters ( T2COLE( (LPCTSTR) m_sParameters ));
if ( FAILED(hr) )
{
TRACE1("CScheduledTask::SaveTask() - failed to set parameters. Return = 0x%08X\n",
(DWORD) hr );
return hr;
}
}
// Set the starting directory.
if ( m_sStartingDir.GetLength() > 0 )
{
hr = pITask->SetWorkingDirectory ( T2COLE( (LPCTSTR) m_sStartingDir ));
if ( FAILED(hr) )
{
示例4: SaveTask
//.........这里部分代码省略.........
}
}
// tworzymy nowe zadanie.
hr = pISched->NewWorkItem ( T2COLE ( szTaskName ), CLSID_CTask,
IID_ITask, &pIUnk );
if ( FAILED(hr) )
{
TRACE1("CTask::SaveTask() - couldn't create a new work item. Return = 0x%08X\n",
(DWORD) hr );
return hr;
}
//mamy wskaznik do IUnknown, odpytujemy go, aby uzyskac
//wskaznik do interfejsu ITask
hr = pIUnk->QueryInterface ( IID_ITask, (void **) &pITask );
if ( FAILED(hr) )
{
TRACE1("CTask::SaveTask() - QI() on IUnknown failed to get an ITask. Return = 0x%08X\n",
(DWORD) hr );
return hr;
}
// wskaznika do IUnknown juz nie potrzebujemy
pIUnk->Release();
pIUnk = NULL;
// ustawiamy nazwe dla aplikacji
hr = pITask->SetApplicationName ( T2COLE( (LPCTSTR) m_sProgramPath ));
if ( FAILED(hr) )
{
TRACE1("CTask::SaveTask() - failed to set application. Return = 0x%08X\n",
(DWORD) hr );
return hr;
}
// ustawiamy parametry dla aplikacji
if ( m_sParameters.GetLength() > 0 )
{
hr = pITask->SetParameters ( T2COLE( (LPCTSTR) m_sParameters ));
if ( FAILED(hr) )
{
TRACE1("CTask::SaveTask() - failed to set parameters. Return = 0x%08X\n",
(DWORD) hr );
return hr;
}
}
// ustawiamy folder startowy dla aplikacji
if ( m_sStartingDir.GetLength() > 0 )
{
hr = pITask->SetWorkingDirectory ( T2COLE( (LPCTSTR) m_sStartingDir ));
if ( FAILED(hr) )
{
TRACE1("CTask::SaveTask() - failed to set starting directory. Return = 0x%08X\n",
(DWORD) hr );