You are not logged in. You can browse in the PowerBASIC Community, but you must click Login (top right) before you can post. If this is your first visit, check out the FAQ or Sign Up.
The GetExitCodeProcess API will return %STILL_ACTIVE (&h0103&) as long as an app is running, but you need the Process Handle to use it and the PB/DLL docs say that the SHELL function returns an Instance Handle. There may be an API to get the Process Handle from an Instance Handle... I can't remember. If you can't figure out how to do it, it might be easier to use CreateProcess instead of SHELL, since CreateProcess returns a Process Handle directly.
Or, if the app that you are trying to detect has (or can have) a unique string in its title bar, you could use the FindWindow API function to see if the window still exists.
I just performed a quick test and it appears that the PB/DLL SHELL function returns a Process ID, not an Instance Handle. I have posted a message containing a sample program in the Source Code Forum.
#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, 80, %WS_SYSMENU, %WS_EX_TOPMOST To hDlg
Control Add TextBox, hDlg, 101, "", 10, 10, 180, 50
Dialog Show Modal hDlg
End Function
Thank you Semen - because of my circumstances, your tip did the trick exactly. I needed to make a conditional DOS window close after running a Win95 utility (sometimes it appears, sometimes not), and the extra thread did the trick perfectly.
We process personal data about users of our site, through the use of cookies and other technologies, to deliver our services, and to analyze site activity. For additional details, refer to our Privacy Policy.
By clicking "I AGREE" below, you agree to our Privacy Policy and our personal data processing and cookie practices as described therein. You also acknowledge that this forum may be hosted outside your country and you consent to the collection, storage, and processing of your data in the country where this forum is hosted.
Comment