Article View: borland.public.cppbuilder.nativeapi
Article #8231Re: Scheduled Task Wizard
From: Vladimir Afanasyev
Date: Thu, 04 Nov 2004 13:18
Date: Thu, 04 Nov 2004 13:18
89 lines
3397 bytes
3397 bytes
"Ted Tripp" <ttripp@rankexec.com> wrote:
>Scheduled Tasks folder.
You can retrieve the location of the Tasks folder from the registry by getting data for the following value:
HKEY_LOCAL_MACHINE
SOFTWARE
Microsoft
SchedulingAgent
TasksFolder
In my case "%SystemRoot%\Tasks"
it means "C:\WINNT\Tasks"
You can run Scheduler via Scriptable Shell Objects.
It's a little tricky but possible.
Follow code for BCB5.
Init shell objects:
CoInitialize(NULL);
Variant SA=Variant::CreateObject("Shell.Application");
Function NameSpace("NameSpace");
Function Items("Items");
//Virtual folder containing icons for the Control Panel
//applications. (value = 3)
int ssfCONTROLS=3;
//get it folder - scheduler there
Variant fold=SA.Exec(NameSpace << ssfCONTROLS);
//will be enum items of folder and search scheduler
Variant It=fold.Exec(Items);
int count=It.Exec(PropertyGet("Count"));
//Search folder with name "Scheduled Tasks" inside CPAs
Variant schedulerFold=Variant::Empty();
for(int i=0; i<count; ++i)
{
if(AnsiString(Variant(It.Exec(Function("Item") << i)).Exec(PropertyGet("Name"))) == "Scheduled Tasks" )
{
schedulerFold=It.Exec(Function("Item") << i);
break;
}
}
if(schedulerFold.IsEmpty())
{
ShowMessage("Impossible! There are no any Scheduled Tasks folder");
Application->Terminate();
return;
}
//get FolderItem object:
bool d=schedulerFold.Exec(PropertyGet("IsFolder"));
Variant op=schedulerFold.Exec(PropertyGet("GetFolder"));
//find and run item "Add Scheduled Tasks"
//really find ver inside
//and it is not big secret that verb called "Open"
Variant It1=op.Exec(Items);
int count1=It1.Exec(PropertyGet("Count"));
for(int i=0; i<count1; ++i)
{
if(AnsiString(Variant(It1.Exec(Function("Item") << i)).Exec(PropertyGet("Name"))) == "Add Scheduled Tasks" )
{
Variant vb=Variant(It1.Exec(Function("Item") << i)).Exec(Function("Verbs"));
int count2=vb.Exec(PropertyGet("Count"));
AnsiString MyVerb=Variant(vb.Exec(Function("Item") << 0)).Exec(PropertyGet("Name"));
Variant(It1.Exec(Function("Item") << i)).Exec(Function("InvokeVerb") << vb);
break;
}
}
Dialog has to open. I try it for Windows2000.
Of course some changes for localized Windows:
I mean -
"Scheduled Tasks"
and
"Add Scheduled Tasks"
Vladimir.
Technical Details
Message-ID:
<418a3a2b$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.wirehub.nl!194.72.7.126.MISMATCH!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mailReferences:
<4189b3d2@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,5162d133ddb169b3 X-Google-Attributes: gid10cc67,public X-Google-Language: ENGLISH,ASCII-7-bit From: "Vladimir Afanasyev" <avv@systema.kiev.ua> Sender: "Vladimir Afanasyev" <avv@systema.kiev.ua> Reply-To: "Vladimir Afanasyev" <avv@systema.kiev.ua> Subject: Re: Scheduled Task Wizard Newsgroups: borland.public.cppbuilder.nativeapi X-User-Info: 83.218.237.46 X-Forwarded-For: unknown References: <4189b3d2@newsgroups.borland.com> NNTP-Posting-Host: 207.105.83.66 Message-ID: <418a3a2b$1@newsgroups.borland.com> Date: 4 Nov 2004 06:18:19 -0700 X-Trace: newsgroups.borland.com 1099577899 207.105.83.66 (4 Nov 2004 06:18:19 -0700) Lines: 89 Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.wirehub.nl!194.72.7.126.MISMATCH!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mail