(Gast)
n/a Beiträge
|
AW: Funktion gesucht, die den tatsächlichen Pfadnamen ermittelt
31. Aug 2016, 11:28
Delphi-Quellcode:
function TitleCase2(const sText: String;
const bLowerCaseFirst: Boolean = True): String;
const
cDelimiters = [#9, #10, #13, ' ', ',', '.', ':', ';', '"',
'\', '/', '(', ')', '[', ']', '{', '}'];
var
iLoop: Integer;
begin
Result := sText;
if (Result <> '') then
begin
Result[1] := UpCase(Result[1]);
for iLoop := 2 to Length(Result) do
if (Result[iLoop - 1] in cDelimiters) then
Result[iLoop] := UpCase(Result[iLoop]);
end;
end;
function GetLongPathName(ShortName:String):String;
var NameS: String;
Len : integer;
Buffer: array[0..MAX_PATH] of Char;
pDummy: PCHAR;
begin
Len := GetFullPathName(PChar(ShortName), 0, PChar(result), pDummy);
SetLength(NameS, Len);
GetFullPathName(PChar(ShortName), Len, PChar(NameS), pDummy);
result := TitleCase2(NameS);
end;
procedure TForm1.Button9Click(Sender: TObject);
begin
Caption:= GetLongPathName('c:\windows\system32');
end;
Alternative:
Delphi-Quellcode:
function TitleCase3(const sText: String;
const bLowerCaseFirst: Boolean = True): String;
var
iLoop: Integer;
begin
Result := sText;
if (Result <> '') then
begin
Result[1] := UpCase(Result[1]);
for iLoop := 2 to Length(Result) do
if (not (Result[iLoop - 1] in ['a'..'z','A'..'Z','0'..'9'])) then
Result[iLoop] := UpCase(Result[iLoop]);
end;
end;
function GetLongPathName(ShortName:String):String;
var NameS: String;
Len : integer;
Buffer: array[0..MAX_PATH] of Char;
pDummy: PCHAR;
begin
Len := GetFullPathName(PChar(ShortName), 0, PChar(result), pDummy);
SetLength(NameS, Len);
GetFullPathName(PChar(ShortName), Len, PChar(NameS), pDummy);
result := TitleCase3(NameS);
end;
procedure TForm1.Button9Click(Sender: TObject);
begin
Caption:= GetLongPathName('C:\Windows\System32\ATEST\123Test');
end;
Geändert von t.roller (31. Aug 2016 um 12:03 Uhr)
|
|
Zitat
|