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

  • 相关阅读:
    轻量级数据库sqlite的使用
    Integer引发的思考
    css限制显示行数
    数据库 chapter 17 数据仓库与联机分析处理技术
    数据库 chapter 15 对象关系数据库系统
    数据库 chapter 16 XML数据库
    数据库 chapter 14 分布式数据库系统
    数据库 chapter 11 并发控制
    数据库 chapter 12 数据库管理系统
    数据库 chapter 13 数据库技术新发展
  • 原文地址:https://www.cnblogs.com/kinglandsoft/p/11635764.html
Copyright © 2011-2022 走看看