Page 1 of 2

c++ problems

Posted: Wed Aug 13, 2008 5:58 am
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

Posted: Wed Aug 13, 2008 8:53 am
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.

Posted: Wed Aug 13, 2008 4:43 pm
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

Posted: Thu Aug 14, 2008 8:22 am
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.

Posted: Thu Aug 14, 2008 11:32 am
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

Posted: Thu Aug 14, 2008 12:17 pm
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.

Posted: Thu Aug 14, 2008 4:14 pm
by petrossa
ok. thanks for the prompt reply. You plan to to update the manual? It's very sparse.

Posted: Fri Aug 15, 2008 3:48 am
by isiticov
Surely, we will try to improve it.

Posted: Fri Aug 15, 2008 10:47 am
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?

Posted: Fri Aug 15, 2008 11:19 am
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.

Posted: Fri Aug 15, 2008 11:36 am
by petrossa
ok, added to the project as units. Still gives same linker error.

Posted: Sat Aug 16, 2008 11:23 am
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.

Posted: Mon Aug 18, 2008 4:36 pm
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?

Posted: Tue Aug 19, 2008 10:45 am
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;

Posted: Tue Aug 19, 2008 11:15 am
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