Forum > General
work with symlink
berghem:
Hi
In my program I get the recent file of Windons, but in C:\Users\MyUser\AppData\Roaming\Microsoft\Windows\Recent there are only symlink. Is There a function for get the real path of file?
Thanks
Wallaby:
FSCTL_GET_REPARSE_POINT or GetFinalPathNameByHandle
PascalDragon:
FPC trunk also has FileGetSymLinkTarget, though that function is currently only implemented for Windows (in your case that would be enough however ;) ).
berghem:
I saw on Google an example with FileGetSymLinkTarget, but I don't know wich unit I gave to import in my file....
I looked for with Google but i saw only delphi example and it use SysUtils, but not lazarus
This is my code
procedure TForm1.GetInfo;
var
SymLinkRec:TSymLinkRec;
begin
Memo1.Clear;
If FindFirst ('C:\Users\MyUsers\AppData\Roaming\Microsoft\Windows\Recent\*',faAnyFile or fasymlink ,Info)=0 then
begin
Repeat
With Info do
begin
If (Attr and fasymlink) = fasymlink then
Memo1.Lines.Add('found symlink: ' + info.name)
else
begin
*FileGetSymLinkTarget('C:\Users\MyUsers\AppData\Roaming\Microsoft\Windows\Recent\' + info.name,SymLinkRec);
Memo1.Lines.Add(SymLinkRec.Name);
end;
end;
Until FindNext(info)<>0;
end;
FindClose(Info);
end;
PascalDragon:
With FPC 3.3.1 this should work. Lazarus ships by default with FPC 3.0.4 however.
Navigation
[0] Message Index
[#] Next page