• 使用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

  • 相关阅读:
    EA教程 (四) SQLHelper类
    详解包含、扩展和泛化
    几种常用的单例模式详解
    我的分层
    EA教程(二)数据库
    软件版本号如何定义
    精解PV操作之信号量
    eclipse连接数据库驱动汇总
    [Leetcode 17] 13 Roman to Integer
    Short term goal for 2013 rest time
  • 原文地址:https://www.cnblogs.com/kinglandsoft/p/11635764.html
Copyright © 2020-2023  润新知