>---test.prg-------------------------- >#Define HomeDir 'c:\temp\5\' > >***************** >*ALGO: >* 1. "runsvc" - run test.exe which creates the service object, >* 2. "service" - and runs the service >* 3. "runtask" - the service executes "test.exe x" which should be a task >* 4. "task" - now test.exe creates the task object, which executes the task >* >* before each point the process ID is written to a file with the given ID >* as the server instancing for Task and Service is set to "SINGLE" >* I would expect the there will be 4 DIFFERENT PID's, >* but there are only 3 different one's >***************** > >Lparameters tcPar1 > >Set Resource Off > >If Pcount()=0 > writepid('runsvc', _vfp.ProcessID) > > Local x > x=Createobjectex('test.Service','') > x.wr_pid() > x.Run() > x=.Null. >Else > writepid('runtask', _vfp.ProcessID) > > Local x,Y > x=Createobjectex('test.Task','') > x.wr_pid() > >*uncomment the lines below to get one more DIFFERENT PID >*y=CreateObject('test.Task') >*y.wr_pid() > > x.Run() > x=.Null. >Endif > >Define Class Task As Relation OlePublic > > Procedure wr_pid > writepid(This.Class, _vfp.ProcessID) > > Procedure Run > Do pretend_doing_sg >Enddefine > >Define Class Service As Task OlePublic > > Procedure Run > Declare Integer ShellExecute In shell32.Dll Integer hndWin, ; > STRING cAction, String cFileName, String cParams, String cDir, ; > INTEGER nShowWin > > lcFileName = HomeDir+"test.exe" > lcAction = "open" > lcDir = '' > lcPar = 'x' > > =ShellExecute(_vfp.hWnd, lcAction, lcFileName, lcPar, lcDir, 0) > > Do pretend_doing_sg > >Enddefine > >Procedure writepid > Lparameters tcPar, tnPid > Strtofile(tcPar+Str(tnPid,10)+Chr(13)+Chr(10), HomeDir+'pidlog.txt',1) >*StrToFile(lcFileName+ ' '+tcPar+Str(tnPid,10)+Chr(13)+Chr(10), HOMEDIR+'pidlog.txt',1) > >Procedure pretend_doing_sg > lnDurationsec=Seconds() > Do While Seconds() < lnDurationsec+5 > Enddo > >---pidlog.txt--------------- >runsvc 2384 >Service 1256 >runtask 2524 >Task 1256