Announcement

Collapse
No announcement yet.

Running exe from PB under WIN2000

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Running exe from PB under WIN2000

    Often but not allways i get a bad handle (0) returned from SHELL().
    I use this handle to wait for end task (Don't use SHELL|)

    Should i use the winapi's for this task ??


    ------------------
    [email protected]
    hellobasic

  • #2
    Edwin --
    this is a method for lazy
    Code:
       #Compile Exe
       #Register None
       #Dim All
       #Include "Win32Api.inc"
       Global hDlg As Long
       Function MyThread (ByVal x As Long) As Long
          Shell "Notepad.Exe"
          Control Set Text hDlg, 101, "Finished"
       End Function
       Function PbMain () As Long
          Local x As Long, idThread As Long
          Thread Create MyThread(x) To idThread
          Thread Close idThread To idThread
          Dialog New 0, "Hello",,, 200, 25, %WS_SYSMENU Or %WS_CAPTION, %WS_EX_TOPMOST To hDlg
          Control Add TextBox, hDlg, 101, "", 10, 5, 180, 15
          Dialog Show Modal hDlg
       End Function
    ------------------

    Comment


    • #3
      Maybe a good idea, i'll think about it.

      The weird thing is when i run from PB6 a 16bit app, the handle is sometimes 0.
      The app IS started fine.

      This is a concern because i might delete some temp files on return while the started app requires them.

      ...


      ------------------
      [email protected]
      hellobasic

      Comment


      • #4
        Edwin --
        try this
        Code:
           #Compile Exe
           #Register None
           #Dim All
           #Include "Win32Api.inc"
        
           Function pShellExecute (Program As String, Arguments As String, nShow As Long) As Dword
              Local ShellInfo As SHELLEXECUTEINFO
              ShellInfo.cbSize = SizeOf(ShellInfo)
              ShellInfo.fMask = %SEE_MASK_FLAG_NO_UI Or %SEE_MASK_NOCLOSEPROCESS
              ShellInfo.lpFile = StrPtr(Program)
              ShellInfo.lpParameters = StrPtr(Arguments)
              ShellInfo.nShow = nShow
              If ShellExecuteEx(ShellInfo) Then Function = ShellInfo.hProcess
           End Function
        
           Function PbMain
              Local hProcess As Dword
              hProcess = pShellExecute ("Notepad.Exe","", %SW_MAXIMIZE)
              WaitForSingleObject hProcess, %INFINITE
              CloseHandle hProcess
              MsgBox "Ok"
           End Function
        ------------------

        Comment

        Working...
        X