How to delay a shell command in delphi? -
i working delphi 2010 , shellapi. need little program building grows. here jest of application:
checks see if condition exists if said condition exists begins execute 2 shell commands dependent on previous 1 executing
uses shellapi; procedure renamedir(dirfrom, dirto: string); var shellinfo: tshfileopstruct; begin shellinfo begin wnd := 0; wfunc := fo_rename; pfrom := pchar(dirfrom); pto := pchar(dirto); fflags := fof_filesonly or fof_allowundo or fof_silent or fof_noconfirmation; end; shfileoperation(shellinfo); end; procedure tform1.button1click(sender: tobject); begin renamedir('c:\dir1', 'c:\dir2'); renamedir('c:\dir3', 'c:\dir'); end;
i novice @ delphi can see issue, second command executing before previous command completes. how solve issue first command executes , finishes before second 1 called?
update: added full pseudo code shows attempting do.
if command use external command/program, consider use createprocess()
, passing infinite waitforsingleobject()
. @ execandwait()
example here.
Comments
Post a Comment