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
如何识别Delphi程序中的命令行参数?_Delphi_Command Line_Parameters - Fatal编程技术网

如何识别Delphi程序中的命令行参数?

如何识别Delphi程序中的命令行参数?,delphi,command-line,parameters,Delphi,Command Line,Parameters,我计划使用任务调度器每X天运行一次特定的应用程序命令。我是否必须首先编写对命令行参数的支持,以便调度器可以执行它 如果是这样,有人知道什么好的命令参数组件吗?如果您只想读取启动时传递给应用程序的任何cmd行参数,可以使用Delphi的内置函数 ParamCount // Number of cmd params passed at startup ParamStr(0) // string of param zero 所以像这样给你打电话 c:\myapp.exe -foo -bar 将

我计划使用任务调度器每X天运行一次特定的应用程序命令。我是否必须首先编写对命令行参数的支持,以便调度器可以执行它


如果是这样,有人知道什么好的命令参数组件吗?

如果您只想读取启动时传递给应用程序的任何cmd行参数,可以使用Delphi的内置函数

ParamCount   // Number of cmd params passed at startup
ParamStr(0) // string of param zero
所以像这样给你打电话

c:\myapp.exe -foo -bar
将给出以下结果

ParamStr(0) = c:\myapp.exe
ParamStr(1) = -foo
ParamStr(2) = -bar

您可能希望从<强> SyStudis>Ung/P>中考虑<强> FIDCMDLIN SwiteSwitter <强>

function FindCmdLineSwitch(const SwitchValue:string):Boolean;
function FindCmdLineSwitch(const SwitchValue:string; IgnoreCase:Boolean):Boolean;
function FindCmdLineSwitch(const SwitchValue:string; SwitchChars:TSysCharSet; IgnoreCase:Boolean):Boolean;
这允许检查是否存在命令行开关,指定是否忽略其大小写,并可以选择使用不同的开关字符,例如“-”或“/”