Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/delphi/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
从delphi7中的按钮单击运行批处理文件_Delphi_Delphi 7 - Fatal编程技术网

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

从delphi7中的按钮单击运行批处理文件,delphi,delphi-7,Delphi,Delphi 7,我有一个批处理文件和一个用delphi7开发的应用程序。两者都很好。我想在单击按钮时运行批处理文件。我能为此做些什么 谢谢 Nelson使用ShellAPI中声明的 ShellExecute( MainForm.Handle, 'open', PChar(scriptfilename), PChar(params), PChar(workingdirectory), SW_SHOW ); 您必须将ShellApi添加到使用列表中@Nelson这能

我有一个批处理文件和一个用delphi7开发的应用程序。两者都很好。我想在单击按钮时运行批处理文件。我能为此做些什么

谢谢 Nelson使用ShellAPI中声明的

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

您必须将ShellApi添加到使用列表中

@Nelson这能回答问题吗?@DavidHeffernan我们可以使用CreateProcess而不是SE吗?如何使用?要使用
CreateProcess
,必须将其作为可执行文件发送
cmd.exe
,然后发送运行脚本所需的任何参数。如果您的意思是将
'cmd.exe/C scriptfilename.bat'
@DavidHeffernan'作为'lpCommandLine'传递,则通常是
/C scriptfilename.bat
,我已经尝试过了。。我正在使用,它只显示一个空的cmd窗口,我的应用程序在
上停止,直到(Apprunning WAIT\u TIMEOUT)
循环,直到我手动关闭cmd,但是命令在Run窗口中运行OK。我应该在RunDosInMemo中更改什么吗?@saastn我不能在对一个无关问题的评论中这样做。如果你对你的代码有什么问题,可以问它。
 var
 exe_start_map:string;
 begin
  exe_start_map:=(ExtractFileDir(Application.ExeName));     
   winexec(PChar(exe_start_map+'\yourfile.bat'),sw_show);
 end;