SiComponents Home Page SiComponents Forums
Here you will be able to get help and share your experience
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Task Renaming Revisited

 
Post new topic   Reply to topic    SiComponents Forums Forum Index -> VCL Scheduling Agent
View previous topic :: View next topic  
Author Message
CarlDippel



Joined: 13 Nov 2003
Posts: 15
Location: LI, NY

PostPosted: Sun Jun 20, 2004 10:59 am    Post subject: Task Renaming Revisited Reply with quote

I'm trying to rename task a1 by saving it as A12 and deleting a1. The A12 task is created in the current directory. How can I create it in the Scheduled Tasks directory? -Carl

Code:
var
  Task:TTaskItem;
begin
  TaskScheduler1.Open;
  Task:=TaskScheduler1.ActivateTask('a1');
  Task.Activate;
  Task.Save('A12');
  Task.Deactivate(False);
  Task.Free;
  TaskScheduler1.DeleteTask('a1');
  TaskScheduler1.Close;
end;


-- Carl Dippel carl@dippel.us www.dippel.us/carl --
Back to top
View user's profile Send private message Send e-mail Visit poster's website
isiticov
Site Admin


Joined: 21 Nov 2002
Posts: 2102

PostPosted: Mon Jun 21, 2004 6:57 am    Post subject: Reply with quote

This is strange how you was able to save task under current folder. But in that case you can try the following code as alternative:
Code:

  Task := Scheduler.ActivateTask('test_1');
  if Task = nil then exit;
  Task.Activate;
  sOldName  := Task.CurFile;
  Task.Deactivate(False);
  sNewName := ExtractFilePath(sOldName) + 'test_3.job';
  if Windows.CopyFile(PChar(sOldName), PChar(sNewName), False) then
    Scheduler.DeleteTask('test_1'); 
Back to top
View user's profile Send private message
CarlDippel



Joined: 13 Nov 2003
Posts: 15
Location: LI, NY

PostPosted: Mon Jun 21, 2004 12:42 pm    Post subject: Reply with quote

Quote:
This is strange how you was able to save task under current folder
I'm using WinXP Pro with an NTFS HD.

Quote:
But in that case you can try the following code as alternative:
It worked like a charm. Thanks a million!

BTW I used MoveFile instead of CopyFile|DeleteTask. Do you for see any problems with that change? -Carl

-- Carl Dippel carl@dippel.us www.dippel.us/carl --
Back to top
View user's profile Send private message Send e-mail Visit poster's website
isiticov
Site Admin


Joined: 21 Nov 2002
Posts: 2102

PostPosted: Mon Jun 21, 2004 8:10 pm    Post subject: Reply with quote

[quote="CarlDippel"]
Quote:
BTW I used MoveFile instead of CopyFile|DeleteTask. Do you for see any problems with that change?

No, there is no difference in methods.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    SiComponents Forums Forum Index -> VCL Scheduling Agent All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by p h p B B  © 2001, 2005 p h p B B  Group