Link to home
Start Free TrialLog in
Avatar of philippe_beauregard
philippe_beauregard

asked on

can't compile demo from TaskScheduler.zip (www.delphi-jedi.org)

I downloaded TaskScheduler.zip (www.delphi-jedi.org). I loaded the TaskSchDemo.dpr project and tied to compile it. I got the following error when I try to compile the demo:
What am I doing wrong with the setup(I am using Delphi 7)?


[Error] main.pas(202): Constant object cannot be passed as var parameter
[Error] main.pas(890): Constant object cannot be passed as var parameter
[Error] main.pas(891): Constant object cannot be passed as var parameter
[Fatal Error] TaskSchDemo.dpr(10): Could not compile used unit 'main.pas'



197      function GetITask(TaskName: string): ITask;
198      var
199        PITask: IUnknown;
200        hr: HRESULT;
201      begin
202        hr := SchedulingAgent.Activate(StrToWide(TaskName), IID_ITask, PITask);
203        if hr = S_OK then Result := ITask(PITask)
204        else
205        begin
206          ShowMessage('Error in SchedulingAgent.Activate.Error Code :' + IntToHex(hr, 8));
207          Result := nil;
208        end;
209
210      end;



890      procedure TfrmMain.btnNewWorkItemClick(Sender: TObject);
890      var
890        HR: HRESULT;
890        TaskName: string;
890        WorkItem: IUnknown;
890      
890      begin
890        TaskName := InputBox('Enter Task Name', 'Name?', '');
890        if TAskName = '' then
890        begin
890          ShowMessage('You have to enter a task name');
890          exit;
890        end;
890        Init;
890        HR := SchedulingAgent.NewWorkItem(StrToWide(TaskName), CLSID_CTask,
890          IID_IScheduledWorkItem, WorkItem);
890        Task := ITask(WorkItem); //required for save
890        ScheduledWorkItem := IScheduledWorkItem(WorkItem);
890        if HR = S_OK then StatusMemo.Lines.Add(Taskname + ' created successfully')
890        else
890        begin
890          StatusMemo.Lines.Add('Could not create the job ' + taskname + ' Error Code :' + IntTohex(hr, 8));
890          exit;
890        end;
890        hr := SaveTAsk;
890        if hr <> S_OK then StatusMemo.lines.add('Save task failed with error code' + IntTohex(hr, 8) + #13#10);
890        BtnGetTasksClick(self); //for updating
890      end;
ASKER CERTIFIED SOLUTION
Avatar of Ferruccio Accalai
Ferruccio Accalai
Flag of Italy image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of philippe_beauregard
philippe_beauregard

ASKER

Thanks F68,

That's exactly what was needed.

-phil

pleased for having helped 'u' :)