在接下来的日子,会将积累的一些函数发布,一则为了交流,二则为了40 -_-!为了偷懒,没有想SysUtils中那样Overload三个函数, 传参实例:D:\Temp\csdn.exe -FD:\Program Files\hi.exe
调用示例:
var Params: string;
if FindCmdLineSwitch('F', Params) > 0 then ShowMessage(Params)实现:
function FindCmdLineSwitch(const Switch: string; var Params: string; IgnoreCase: Boolean): Integer;
var
I: Integer;
S: string;
begin
Result := 0;
for I := 1 to ParamCount do
begin
S := ParamStr(I);
if (S[1] in SwitchChars) then
if IgnoreCase then
begin
if (AnsiCompareText(Copy(S, 2, Length(Switch)), Switch) = 0) then
begin
Params := Copy(S, Length(Switch) + 2{Switch的位置+1, 起始位置再+1, 下同}, Maxint);
Result := I;
Exit;
end;
end
else begin
if (AnsiCompareStr(Copy(S, Length(Switch) + 2, Maxint), Switch) = 0) then
begin
Params := Copy(S, Length(Switch), Maxint);
Result := I;
Exit;
end;
end;
end;
end;
你的可用分比别人少吧!每天发帖即可得 30 可用分!
调用示例:
var Params: string;
if FindCmdLineSwitch('F', Params) > 0 then ShowMessage(Params)实现:
function FindCmdLineSwitch(const Switch: string; var Params: string; IgnoreCase: Boolean): Integer;
var
I: Integer;
S: string;
begin
Result := 0;
for I := 1 to ParamCount do
begin
S := ParamStr(I);
if (S[1] in SwitchChars) then
if IgnoreCase then
begin
if (AnsiCompareText(Copy(S, 2, Length(Switch)), Switch) = 0) then
begin
Params := Copy(S, Length(Switch) + 2{Switch的位置+1, 起始位置再+1, 下同}, Maxint);
Result := I;
Exit;
end;
end
else begin
if (AnsiCompareStr(Copy(S, Length(Switch) + 2, Maxint), Switch) = 0) then
begin
Params := Copy(S, Length(Switch), Maxint);
Result := I;
Exit;
end;
end;
end;
end;
你的可用分比别人少吧!每天发帖即可得 30 可用分!
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货