Re: Re: How to change short filename to long filename?
Posted by Magus on July 04, 2000 at 01:47:49: In Reply to: Re: How to change 'C:\ALONGN~1\NEW.TXT' to 'C:\ALongName\New.txt' posted by Jean Claude Servaye on June 28, 2000 at 17:30:04:
: ExpandFileName('NEW.TXT');
function GetFilePath (Path: pChar) : boolean; var p: pChar; begin p := StrRScan(path, '\'); Result := p <> nil; if Result then p^ := #0; end;
function Win95FileName(Path : pChar) : string ; var SearchRec : TSearchRec; More : Boolean; begin result := ''; if FileExists(Path) then begin repeat FindFirst(Path, faAnyFile, SearchRec); More := GetFilePath(Path); if More then Result := '\' + SearchRec.Name + result ; until not more; Result := Path + result; end; end; Note: when calling GetFilePath(), the pChar which passes as a parameter MUST be set before with StrNew(), or declared as an array[] of byte. Otherwise, an EAccessViolation exception is raised.
|
|