delphi - How to edit a file using a specified editor? -


currently, i'm using following function in order open file using default editor , sure application waits until user closes editor window.

function editandwait(const afilename : string) : boolean; var   info: tshellexecuteinfo; begin   fillchar(info, sizeof(info), 0);   info.cbsize := sizeof(info);   info.lpverb := 'edit';   info.lpfile := pansichar(afilename);   info.nshow := sw_show;   info.fmask := see_mask_nocloseprocess;   result := shellexecuteex(@info);   if(result) , (info.hprocess <> 0)    begin     waitforsingleobject(info.hprocess, infinite);     closehandle(info.hprocess);   end; end; 

i write similar function allow specify editor executable use editing.

function editandwait(const afilename : string; const aeditor : string) : boolean; begin   //... end; 

as david said, have run editor program , pass file parameter.

there several ways it. similar current function:

function editandwait(const afilename : string; const aeditor : string) : boolean; var   info: tshellexecuteinfo; begin   fillchar(info, sizeof(info), 0);   info.cbsize := sizeof(info);   info.lpverb := 'open';   info.lpfile := pchar(aeditor);   info.nshow := sw_show;   info.fmask := see_mask_nocloseprocess;   info.lpparameters := pchar(afilename);   result := shellexecuteex(@info);   if(result) , (info.hprocess <> 0)    begin     closehandle(info.hprocess);     waitforsingleobject(info.hprocess, infinite);   end; end; 

Comments

Popular posts from this blog

serialization - Convert Any type in scala to Array[Byte] and back -

matplotlib support failed in PyCharm on OSX -

python - Matplotlib: TypeError: 'AxesSubplot' object is not callable -