regasm c:\cbUtilites\cbUtilities.dll /codebase
And here is one demo code for testing,Local o As "cbNetCOM.Utilities", eh As 'cbUtilityEvents' o = Createobject("cbNetCOM.Utilities") Local lcFileName m.lcFileName = 'd:\temp\seTest.txt' Strtofile('',m.lcFileName) eh=Createobject("cbUtilityEvents",m.o) Eventhandler(m.o, m.eh) o.ShellExecProcess("notepad.exe", m.lcFileName, .F., .F.) * Shellexecuted the process * Lets do some work while it is running * Just to demonstrate it is async and we get the event * when it exists Public oTimer as Timer oTimer = CreateObject('myTimer') m.oTimer.Enabled = .t. Define Class myTimer as Timer Interval = 5000 && every 5 seconds Procedure Timer ? 'I am doing nothing useful, just hanging around.', Datetime() endproc enddefine Define Class cbUtilityEvents As Session OlePublic Implements IcbEvents In "C:\cbUtilities\CBUTILITIES.TLB" oHook = Null Procedure Init(toHook) This.oHook = m.toHook Endproc Procedure IcbEvents_OnProcessExit(ExitCode As Number, exitTime As Date, exceptionMessage As String) As VOID If Empty(m.exceptionMessage) ? 'Process has exited on', m.exitTime, ' with exit code', m.ExitCode MessageBox(FileToStr('d:\temp\seTest.txt')) Else ? 'Process had and exception. Message:', m.exceptionMessage Endif Eventhandler(This.oHook,This,.T.) This.oHook = Null Endproc EnddefinePS: Forgot to tell parameters (although intellisense names are self explanatory):
ShellExecProcess(fileNameToShellExec, cArguments [, [lHidden] [, lWaitToExit]] )ileNameToShellExec: Exe filename (or something like mydocument.doc to invoke with associated application).