none
How can be known that the external application is currently closed or open ? RRS feed

  • Question

  • when i close my program without starting the notepad using "close sb application" button. So it shows this error -

    LDProcess.Stop : access is denied

    b1 = Controls.AddButton("start notepad",50,100)
    b2 = Controls.AddButton("close sb application",50,200)
    exePath = "C:\Windows\notepad.exe" 
    
    Controls.ButtonClicked = obc
    
    Sub obc
      lcb=Controls.LastClickedButton
      If (lcb = b1) Then
      id = LDProcess.Start(exePath, "")
     ElseIf (lcb = b2) Then
       LDProcess.Stop(id)
       Program.Delay(1000)
       Program.End()
    EndIf  
      EndSub
    


    msdn.yogesh

    Friday, July 7, 2017 5:56 PM

Answers

  • b1 = Controls.AddButton("start notepad",50,100)
    b2 = Controls.AddButton("close sb application",50,200)
    exePath = "C:\Windows\notepad.exe" 
    
    Controls.ButtonClicked = obc
    
    Sub obc
      lcb = Controls.LastClickedButton
      If (lcb = b1) Then
        id = LDProcess.Start(exePath, "")
      ElseIf (lcb = b2) Then
        allProc = LDProcess.GetProcesses()
        If Array.ContainsIndex(allProc, id) Then
          LDProcess.Stop(id)  ' can only stop a process, that's running
        EndIf
        
        Program.Delay(1000)
        Program.End()       ' exit self
      EndIf  
    EndSub

    • Marked as answer by msdn.yogesh Friday, July 7, 2017 6:36 PM
    Friday, July 7, 2017 6:17 PM
    Answerer