本文整理汇总了C++中ITask::SetComment方法的典型用法代码示例。如果您正苦于以下问题:C++ ITask::SetComment方法的具体用法?C++ ITask::SetComment怎么用?C++ ITask::SetComment使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ITask
的用法示例。
在下文中一共展示了ITask::SetComment方法的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
//.........这里部分代码省略.........
{
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) )
{
TRACE1("CScheduledTask::SaveTask() - failed to set starting directory. Return = 0x%08X\n",
(DWORD) hr );
return hr;
}
}
TCHAR infoBuf[32767];
DWORD bufCharCount = 32767;
GetUserNameEx(NameSamCompatible, infoBuf, &bufCharCount);
hr = pITask->SetAccountInformation((LPCWSTR)infoBuf, L"");
// Set the job comment.
if ( m_sComment.GetLength() > 0 )
{
hr = pITask->SetComment ( T2COLE( (LPCTSTR) m_sComment ));
if ( FAILED (hr) )
{
TRACE1("CScheduledTask::SaveTask() - failed to set task comment. Return = 0x%08X\n",
(DWORD) hr );
return hr;
}
}
//TCHAR pszName[CREDUI_MAX_USERNAME_LENGTH] = "";
//TCHAR pszPwd[CREDUI_MAX_PASSWORD_LENGTH] = "";
///////////////////////////////////////////////////////////////////
// Call ITask::SetAccountInformation to specify the account name
// and the account password for Test Task.
///////////////////////////////////////////////////////////////////
//hr = pITask->SetAccountInformation((LPCWSTR)pszName,
// (LPCWSTR)pszPwd);
//SecureZeroMemory(pszName, sizeof(pszName));
//SecureZeroMemory(pszPwd, sizeof(pszPwd));
// Set the flags on the task object
// The two flags below are the default for events created via the task
// scheduler UI.
// Note that I _don't_ set TASK_FLAG_DELETE_WHEN_DONE. Setting this flag
// is bad if you have the "Notify me of missed tasks" option on in the
// scheduler. If this flag is set and the event is missed, the scheduler
// nukes the event without notifying you . How mean.
示例4: SaveTask
//.........这里部分代码省略.........
// 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 );
return hr;
}
}
// ustawiamy nazwe uzytkownika i haslo, jesli jestesmy na NT
if ( m_bNT )
{
hr = pITask->SetAccountInformation ( T2COLE( (LPCTSTR) m_sAccount),
T2COLE( (LPCTSTR) m_sPassword) );
if ( FAILED(hr) )
{
TRACE1("CTask::SaveTask() - failed to set account info. Return = 0x%08X\n",
(DWORD) hr );
return hr;
}
}
// ustawiamy komentarz do zadania
if ( m_sComment.GetLength() > 0 )
{
hr = pITask->SetComment ( T2COLE( (LPCTSTR) m_sComment ));
if ( FAILED (hr) )
{
TRACE1("CTask::SaveTask() - failed to set task comment. Return = 0x%08X\n",
(DWORD) hr );
return hr;
}
}
// ustawiamy flagi
//zapraszam do eksperymentow z flaga TASK_FLAG_DELETE_WHEN_DONE...
dwTaskFlags = TASK_FLAG_DONT_START_IF_ON_BATTERIES |
TASK_FLAG_KILL_IF_GOING_ON_BATTERIES;
// na NT ustawimy flage interactive
if ( !( GetVersion() & 0x80000000 ) )
{
dwTaskFlags |= TASK_FLAG_INTERACTIVE;
}
hr = pITask->SetFlags ( dwTaskFlags );
if ( FAILED (hr) )
{
TRACE1("CTask::SaveTask() - failed to set task flags. Return = 0x%08X\n",
(DWORD) hr );
return hr;
}
// teraz tworzymy Trigger, czyli wyzwalacz