unit ParamsMngr; {$MODE Delphi} {$codepage UTF8} interface uses StrUtils, VCLEx; {stdcalls} function HasParam (const AParams: String; const AParam: Char): Boolean; OVERLOAD; STDCALL; function HasParam (const AParams: String; const AParam: String): Boolean; OVERLOAD; STDCALL; function HasParam (const AParam: String): Boolean; OVERLOAD; STDCALL; function GetParamValue (const AParams: String; const AParam: Char): String; OVERLOAD; STDCALL; function GetParamValue (const AParams: String; const AParam: String): String; OVERLOAD; STDCALL; function GetParamValue (const AParam: string): string; overload; stdcall; function StartParams: String; STDCALL; implementation function HasParam (const AParams: String; const AParam: Char): Boolean; begin Result:= False; if AParams <> '' then if Pos('/' + AParam, AParams) > 0 then Result:= True; end; function HasParam (const AParams: String; const AParam: String): Boolean; var PS: IntEx; NextChr: Char; begin Result:= False; if AParams <> '' then begin PS:= Pos('/' + AParam, AParams); if PS > 0 then begin NextChr:= AParams[PS + Length(AParam) + 1]; if (NextChr = '=') or (NextChr = '#') then Result:= True; end; end; end; function HasParam (const AParam: String): Boolean; begin Result:= HasParam(StartParams, AParam); end; function GetParamValue (const AParams: String; const AParam: Char): String; var i, j, k: IntEx; begin Result:= ''; i:= 0; j:= 0; k:= 0; if AParams <> '' then begin i:= Pos('/' + AParam, AParams); if (i > 0) and (AParams[i+2] = '=') then j:= i+3; if j > 0 then begin k:= PosEx('#', AParams, j); if k = 0 then k:= Length(AParams) + 1; Result:= Copy(AParams, j, k-j); end; end; end; function GetParamValue (const AParams: String; const AParam: String): String; var i, j, k: IntEx; begin Result:= ''; i:= 0; j:= 0; k:= 0; if AParams <> '' then begin i:= Pos('/' + AParam, AParams); if (i > 0) and (AParams[i + Length(AParam) + 1] = '=') then j:= i + Length(AParam) + 2; if j > 0 then begin k:= PosEx('#', AParams, j); if k = 0 then k:= Length(AParams) + 1; Result:= Copy(AParams, j, k-j); end; end; end; function GetParamValue (const AParam: String): String; begin Result:= GetParamValue(StartParams, AParam); end; function StartParams: String; var i: IntEx; begin Result:= ''; if Paramcount > 0 then for i:= 1 to Paramcount do Result:= Result + ParamStr(i) + '#'; end; end.