Hallo!
hab mal Folgende Frage
Mit dieser Funktion können Lange Pfade in kurtze umgewandelt werden:
Delphi-Quelltext
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25:
| uses Windows, SysUtils;
function GetShortName(sLongName: string): string; var sShortName: string; nShortNameLen: Integer; begin SetLength(sShortName, MAX_PATH); nShortNameLen := GetShortPathName(PChar(sLongName), PChar(sShortName), MAX_PATH - 1); if (0 = nShortNameLen) then begin end; SetLength(sShortName, nShortNameLen); Result := sShortName; end;
procedure TForm1.Button1Click(Sender: TObject); begin Caption := GetShortName('C:\Program Files\Delphi6\Lib\test.cnt'); end; |
meinen code:
Delphi-Quelltext
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19:
| function GetShortName(sLongName: string): string; var sShortName: string; nShortNameLen: Integer; begin SetLength(sShortName, MAX_PATH); nShortNameLen := GetShortPathName(PChar(sLongName), PChar(sShortName), MAX_PATH - 1); if (0 = nShortNameLen) then begin end; SetLength(sShortName, nShortNameLen); Result := sShortName; end;
procedure TForm1.Button1Click(Sender: TObject); begin Caption := GetShortName(Edit1.Text); end; |
Es funktioniert nicht. Was mach ich falsch?
Hoffe ihr könnt mir helfen und danke schonmal im Voraus.
Peter kiers
Moderiert von
Gausi: Code- durch Delphi-Tags ersetzt