zoukankan      html  css  js  c++  java
  • 使用FindCmdLineSwitch处理命令行参数

    一、四个形式(变体)

    1function FindCmdLineSwitch(const Switch: string; const Chars: TSysCharSet; IgnoreCase: Boolean): Boolean; overload;
    2function FindCmdLineSwitch(const Switch: string): Boolean; overload;
    3function FindCmdLineSwitch(const Switch: string; IgnoreCase: Boolean): Boolean; overload;
    4function FindCmdLineSwitch(const Switch: string; var Value: string; IgnoreCase: Boolean = True;
      const SwitchTypes: TCmdLineSwitchTypes = [clstValueNextParam, clstValueAppended]): Boolean; overload;

    二、函数功能
    1、FindCmdLineSwitch 在应用程序内部判断指定的命令行参数是否存在,如果调用当前进程的命令行参数中包含了Switch参数指定的字符串, 函数返回值True,否则返回False

    三、参数功能
    1、Switch 指定命令行参数
    2、Chars  指出哪个字符为命令分隔符(通常是-/)。
                 SwitchChars = ['/','-']; // Windows下默认 
                 SwitchChars = ['-'];     // Linux  下默认 
    3、IgnoreCase 参数是否忽略大小写,True:忽略;False:不忽略
     
    四、实例
    1、Exanple.exe程序,通过Dos命令调用它时: Exanple.exe -AAA
    2、在Exanple.exe程序,
       (1)调用Exanple.exe -AAA,FindCmdLineSwitch('AAA')=True;
       (2)调用Exanple.exe -BBB,FindCmdLineSwitch('AAA')=False;

    五、Install

    function Install: Boolean;
    begin
      Result := FindCmdLineSwitch('INSTALL',['-','','/'], True) or
                FindCmdLineSwitch('UNINSTALL',['-','','/'], True);
    end;

    该函数功能:调用程序的Dos命令行中有“INSTALL”或“UNINSTALL”字符(命令行)时,(忽略大小写)返回真。

    六、FindCmdLineSwitch所在单元

    System.SysUtils

    七、参考地址:

    http://bbs.csdn.net/topics/391070266

     八、Delphi 版本:Delphi 10.3.2

  • 相关阅读:
    第一课 JSON的简介
    xml 简介
    前端面试题汇总(长期更新)
    HTML5中的canvas
    AJAX第一课 AJAX的学习和简介
    margin:0 auto和text-aglin:center的区别
    js中的正则表达式
    border和box-shadow
    css中的伪类
    (素材源码)猫猫学IOS(十五)UI之曾经大热的打砖块小游戏
  • 原文地址:https://www.cnblogs.com/kinglandsoft/p/11635764.html
Copyright © 2011-2022 走看看