给你个函数
function GetToken(const S: string; index: Integer; bTrail: Boolean = False; Delimiters: TSysCharSet = [' ', #9, #10, #13]): string;
var
I, W, head, tail: Integer;
bInWord : Boolean;
begin
I := 1;
W := 0;
bInWord := False;
head := 1;
tail := Length(S);
while (I <= Length(S)) and (W <= index) do
begin
if S in Delimiters then
begin
if (W = index) and bInWord then tail := I - 1;
bInWord := False;
end else
begin
if not bInWord then
begin
bInWord := True;
Inc(W);
if W = index then head := I;
end;
end;
Inc(I);
end;
if bTrail then tail := Length(S);
if W >= index then Result := Copy(S, head, tail - head + 1)
else Result := '';
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
label1.Caption := GetToken('c:/ss/dd/*.*' ,3,false ,['/']); //dd
label2.Caption := GetToken('c:/ss/dd/*.*' ,2,false ,['/']); //ss
label3.Caption := GetToken('c:/ss/dd/*.*' ,1,false ,['/']); //c:
end;