从delphi7中的按钮单击运行批处理文件

问题描述 投票:4回答:2

我有一个批处理文件和一个在delphi7中开发的应用程序。两者都很好。我想在单击按钮时运行批处理文件。我该怎么办?

谢谢尼尔森

delphi delphi-7
2个回答
8
投票

使用在ShellAPI中声明的ShellExecute

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

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

您必须在使用列表中添加ShellApi

© www.soinside.com 2019 - 2024. All rights reserved.