分割字符串例子 function TuseIso.getlastdirname( dir: string): string; var i, j: integer; pos1: Integer; pos2: Integer; begin pos1 := 0; pos2 := 0; if dir = '' then begin result := ''; exit; end; if (DirectoryExists(dir) and (dir[Length(dir)]<>'\')) then dir:=dir+'\'; j := 0; for i := Length(dir) downto 1 do begin if dir[i] = '\' then begin if j = 0 then pos1 := i; if j = 1 then pos2 := i; j := j + 1; end; if j >= 2 then break; end; if pos1 = pos2 then begin Result := ''; exit; end; result := copy(dir, pos2 + 1, (pos1 - 1 - pos2));end; //这个函数得到路径字符串,然后取最后一个路径名 //和你那个分割类似,看看能不能帮你
function TuseIso.getlastdirname( dir: string): string;
var
i, j: integer;
pos1: Integer;
pos2: Integer;
begin
pos1 := 0;
pos2 := 0;
if dir = '' then
begin
result := '';
exit;
end;
if (DirectoryExists(dir) and (dir[Length(dir)]<>'\'))
then dir:=dir+'\';
j := 0;
for i := Length(dir) downto 1 do
begin
if dir[i] = '\' then
begin
if j = 0 then
pos1 := i;
if j = 1 then
pos2 := i;
j := j + 1;
end;
if j >= 2 then break;
end;
if pos1 = pos2 then
begin
Result := '';
exit;
end;
result := copy(dir, pos2 + 1, (pos1 - 1 - pos2));end;
//这个函数得到路径字符串,然后取最后一个路径名
//和你那个分割类似,看看能不能帮你
字符串string其实就是字符的数组,你可以用youstr[i]来取得
字符串string中任意一个字符。
i取值范围[1..length(youstr)].