Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Set caption "Checking" & wait until checking is completed.

Status
Not open for further replies.

a1sifat

Programmer
Aug 22, 2018
11
BD
I am building a VFP application which will see whether an ADB(Android Debug Bridge) connection has been established or not. If an ADB connection is established then the thisform.label3.caption will be "Connected" else "Not Connected". Now the application can catch the connection and disconnection events but i want to set the caption to "Checking" before it executes ADB connection checking codes. How do i achieve that?

Code:
thisform.label3.Caption= "Checking ADB Connection" 
DO shellexecute.prg
ShellExecute(0, "open", "cmd.exe", "/C adb devices > H:\New_folder\adbc_log.txt", "", 0)
 
a1sifat:

ThisForm.Caption = "Checking"

After Checking, if Success something like
If llCheckADB
ThisForm.Caption = "Connected"​
Else
ThisForm.Cpation = "Not Connected"​



Best Regards,
Scott
MSc ISM, MIET, MASHRAE, CDCP, CDCS, CDCE, CTDC, CTIA, ATS

"Everything should be made as simple as possible, and no simpler."[hammer]
 
>i want to set the caption to "Checking" before it executes ADB connection checking codes. How do i achieve that?

If "ADB connection checking codes" means executing "adb devices" you already do that, don't you?

I wonder, if you want to know how to wait for the result in H:\New_folder\adbc_log.txt, but you didn't ask that, so what is the problem with that code?

We only see what you posted, so whatever overrides the caption you set will likely be in further code after the ShellExecute. You should know Shellexecute returns after starting cmd.exe and before the adb.exe or adb.sys, adv.cmd or whatever has finished, ShellExecute is asynchronous. If you want to wait for this to be done you may rather use the WScript COM object run method, or simpler VFP RUN without the /N option but with a DOS shell window.

If you want to wait for a process you start to finish there's a more complex route for that via CreateProcess and WaitForSingleObject, it's much mpore complicated as it needs some process information struct, but it's described here including how to get the exit code of the finished process:

Bye, Olaf.

Olaf Doschke Software Engineering
 
Olaf,

your link to Wiki~ProcessExitCode returns an error 404 .....


Regards,

Koen
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top