Announcement

Collapse
No announcement yet.

Shell

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

  • Shell

    An asynchronous shell (hShell = Shell ("calc.exe") should return a process handle in hShell if succesfull. But if I pass hShell to GetProcessTimes, I get an error 6 "Invalid handle". Is the returnvalue from shell a Windows process handle?
    Regards,
    Peter

    "Simplicity is a prerequisite for reliability"

  • #2


    No, the return of the Shell function is the instance handle. To get the
    process handle try this:


    Declare Function OpenProcess Lib "kernel32" _
    (ByVal dwDesiredAccess&, ByVal bInheritHandle&, ByVal dwProcessId&) As Long


    Y& = SHELL(PATH$, X)

    Z& = OpenProcess(PROCESS_QUERY_INFORMATION + PROCESS_TERMINATE, False, Y&)


    Andy
    [email protected]

    Comment


    • #3
      Thanks! That does it. I now have one other question: how to get the handle of the main window of this process? (I now use findwindow, but that way, if someone starts another instance of the program, I could get the wrong handle...)

      Peter.
      Regards,
      Peter

      "Simplicity is a prerequisite for reliability"

      Comment

      Working...
      X