Started by Nicola, October 19, 2023, 12:17:33 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.


A little help please. Maybe I didn't do my research thoroughly, but I wanted to ask how I know, if possible, when the program launched with SHELLEXECUTE was closed.
Thank you

uses minwin
'uses dialogs

int id=ShellExecute(0,"open", "notepad.exe", "t.txt", "",1)
print id

print "end"

Frank Brübach

Hi Nicola.. try  this way...

uses minwin
string c="..\co2.exe" 'gxo2.exe
string t="notepad.exe"
string f="ta.txt"

ShellExecute 0,"open", t, ""+f, "",1

Make First a Text File call IT "ta.txt" and content for example "hello Nicola" same folder must Work now Notepad Editor is open with your hello Nicola message

Bye Frank

Charles Pegge

I found that it did not respond to "notepad.exe" but "notepad" worked


Notepad executions seems temperamental. Sometimes it works, sometimes not (Windows 11)


"notepad.exe" works correctly. (win 10)
Anyway, my question was: can the starting program (the one in which there is the shellexecute command) know, i.e. have a return, to know when the started program has completed its work and has closed or has been closed by the operator?
For example, if I started a conversion with ffmpeg, could I get a return on the completion of the conversion?
I hope I've been more precise...
Thank you


I don't know if there is a command like ShellExecute_Wait(...,...) that pauses the program while waiting for the other one to finish its work.

Charles Pegge

I normally use the exec function in sysutil which gives you the choice to wait for completion or not.

CreateProcess will also allow you to monitor the process with its PROCESS_INFORMATION structure

uses sysutil
int wait=1
exec "notepad.exe ..\t.o2bas",wait
print "ok"

Within inc\

function Exec(string c, int wait=0) as int
  CreateProcess null,c,0,0,0,0,0,0,@infs,@infp
  if wait
    WaitForMultipleObjects 1,@infp.hthread,1,-1
  end if
  CloseHandle infp.hProcess
  CloseHandle infp.hThread
  return 0
  end function

  function QuExec(string c,d,f, int wait=0) as int
    return Exec(qu+c+qu+" "+d+" "+qu+f+qu, wait)
  end function

  function DOS(string s, int wait=0)
  string c
  if s then
    c="cmd.exe /c "+s
  end if
  Exec c, wait
  end function


Thank you Charles.

I try it....


Hi Charles.
I've tried it and it's all ok. Thank you.

I wanted to ask you what QUEXEC does.
Also I saw in SysUtil there is also the GETFILELIST function. I tried it and I saw that I always get the list of files, based on the filter, present in the current directory...


Charles Pegge

quexec is for commands and/or filenames that need to be enclosed by quotemarks. This is required when the pathnames could have spaces in them.

GetFileList works in the current directory, so you need to change to the required directory before using it.

You can also set the dirq flag to get a list of subdirectories instead of files.