开发者

Run a batch file from button click in delphi7

I have a batch file and an application developed in delphi7. Both are working fine.开发者_Python百科 I want to run the batch file when clicking a button. what can I do for that?

Thanks Nelson


Use ShellExecute which is declared in ShellAPI.

ShellExecute(
    MainForm.Handle,
    'open',
    PChar(scriptfilename),
    PChar(params),
    PChar(workingdirectory),
    SW_SHOW
);


 var
 exe_start_map:string;
 begin
  exe_start_map:=(ExtractFileDir(Application.ExeName));     
   winexec(PChar(exe_start_map+'\yourfile.bat'),sw_show);
 end;

you must add ShellApi in uses list

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜