c++ problems

This forum is designated to discuss SiComponents Scheduling Agent.
petrossa
Posts: 23
Joined: Tue Aug 12, 2008 6:38 pm

c++ problems

Post by petrossa »

I just bought the SA based on the perfect working demo in Delphi. But writing an application using the component in c++ gives some problems.
1. The Comments and the Parameters property of TaskScheduler return empty strings, whilst in delphi they return the proper strings.
2. Accessing scheduler xp properties whilst running vista raises exceptions
3. the taskdialog component does not function at all, it just returns, using the taskitem EditWorkItem gives a: interface not supported.

i didnt get yet to the point of trying other functions, as i got stuck already here.

platform: Vista x64 sp1 latest update
environment: Codegear RAD Studio 2007

tests also run in Virtual Box with XP 32 Host.

please advice
isiticov
Site Admin
Posts: 2383
Joined: Thu Nov 21, 2002 3:17 pm

Post by isiticov »

Hello,

Could you please reproduce these problem on any sample project and send it to us to test? As you may notice Delphi and C++ use the same source of components and all these errors under C++ look very strange.
Best regards,
Igor Siticov.
petrossa
Posts: 23
Joined: Tue Aug 12, 2008 6:38 pm

Post by petrossa »

www.petrossa.com/errordemo.rar

for now it only shows that the parameters are not returned (at least on my system) . The other errors i'll add as time comes
isiticov
Site Admin
Posts: 2383
Joined: Thu Nov 21, 2002 3:17 pm

Post by isiticov »

Thank you very much for your demo. There is just a little modification needed in your code in order to work properly:

Code: Select all

TTaskItem * TI = (TTaskItem *) Item->Data;
TI->Activate();
Memo1->Lines->Add(TI->Comment);
if (TaskScheduler1->RunningVistaOrLater()) {
	TI->CurrentAction = 1;
}
Memo1->Lines->Add(TI->Parameters);
Please note call of Activate() method and setting of CurrentAction (under Windows Vista). We will try to improve our code in order to auto-set CurrentAction to 1 when it is not set.
Please let us know if this helps.
Best regards,
Igor Siticov.
petrossa
Posts: 23
Joined: Tue Aug 12, 2008 6:38 pm

Post by petrossa »

that works :D
Not really evident from the manual though. what does Activate do exactly, the manual is not very informative.

Would you be so kind and reload the demo? I added taskpropertiesdialog which i cant get to function
isiticov
Site Admin
Posts: 2383
Joined: Thu Nov 21, 2002 3:17 pm

Post by isiticov »

Thank you for update. Unfortunately, TaskPropertiesDialog doesn't work under Windows Vista (when using Task Scheduler 2 interface), because Task Scheduler 2.0 doesn't provide this functionality. You can link Delphi unit Prop.pas into your C++ project and use it to display task properties dialog. There is only needed to use

Code: Select all

PropertiesDlg()

function from the Props.pas unit to display and edit Task Properties.
Best regards,
Igor Siticov.
petrossa
Posts: 23
Joined: Tue Aug 12, 2008 6:38 pm

Post by petrossa »

ok. thanks for the prompt reply. You plan to to update the manual? It's very sparse.
isiticov
Site Admin
Posts: 2383
Joined: Thu Nov 21, 2002 3:17 pm

Post by isiticov »

Surely, we will try to improve it.
Best regards,
Igor Siticov.
petrossa
Posts: 23
Joined: Tue Aug 12, 2008 6:38 pm

Post by petrossa »

building props.pas as c++ package gives:

[ILINK32 Error] Error: Unresolved external '__fastcall Satask::TTaskItem::GetTaskDefinition()' referenced from C:\USERS\DOCUMENTS\RAD STUDIO\PROJECTS\DEBUG_BUILD\PROPS.OBJ
[ILINK32 Error] Error: Unresolved external '__fastcall Sautils::IsUserAnAdmin()' referenced from C:\USERS\DOCUMENTS\RAD STUDIO\PROJECTS\DEBUG_BUILD\PROPS.OBJ

i only added props.pas to the package, do i need to add more files to get the build?
isiticov
Site Admin
Posts: 2383
Joined: Thu Nov 21, 2002 3:17 pm

Post by isiticov »

I meant just add it to the C++ project itself not to the package. Also you would need to add SelectActions.pas unit and make small change in Prop.Pas:
Delete Main from the uses clause under implementation section.
Best regards,
Igor Siticov.
petrossa
Posts: 23
Joined: Tue Aug 12, 2008 6:38 pm

Post by petrossa »

ok, added to the project as units. Still gives same linker error.
petrossa
Posts: 23
Joined: Tue Aug 12, 2008 6:38 pm

Post by petrossa »

well i got it going at last. Took some puzzling however. You might consider looking into the C++ integration a bit.

First i changed the *.h includes added by the shedagent component for the *.hpp from the base Source directory. The codegear source files have no declaration for the missing functions.

Then i recompiled the schedagent package using strict c++ settings, replaced the component in the IDE and now it links (and works) well.
petrossa
Posts: 23
Joined: Tue Aug 12, 2008 6:38 pm

Post by petrossa »

I put a sort of parallel to your demo together. Rough still. Would you mind looking at www.petrossa.com/test.rar ?
Under xp the task create function works perfect. Under vista however i get an exception thrown: specified file not found. This happens after this function is called in your CreateNewTaskWizard:

FTask := FTaskScheduler.ActivateTask(wsName);

if you continue, you get an Out of Bounds exception, if you continue still the task is created anyway, but the taskname is added to the parameters.

Entering the function in the debugger quickly gets you lost in the system library.

Yo have an idea?
isiticov
Site Admin
Posts: 2383
Joined: Thu Nov 21, 2002 3:17 pm

Post by isiticov »

1. "Unable to locate task" is "internal" exception and it is not visible when running without debugger. You can just ignore it.
2. We cannot reproduce "Out of bounds" exception on our Demo project.
3. Task name added to the parameters because this is how our Demo project is designed. You can see this in the code:

Code: Select all

        if edtApplicationName.Text = Application.ExeName then
          FTask.Parameters := edtParameters.Text + ' ' + wsName
        else
          FTask.Parameters := edtParameters.Text;
Best regards,
Igor Siticov.
petrossa
Posts: 23
Joined: Tue Aug 12, 2008 6:38 pm

Post by petrossa »

tnx for the info. Nice job the component. I took one look at the task scheduler documentation and started looking for a readymade.

It is very functional, well done
Post Reply