Solved

Differentiate between Directory Link and Directory

Posted on 2011-09-06
2
698 Views
Last Modified: 2012-08-13
Hi,

'My Documents' is shown as a Folder in Win7 since it is a Directory Link. In findfirst I want to be able to differentiate between a propoer Folder and a
Directory link. I use Delphi 2007 on Win7.

Regards
Allan
0
Comment
Question by:Allan_Fernandes
2 Comments
 
LVL 37

Accepted Solution

by:
Geert Gruwez earned 500 total points
ID: 36493967
i can find the file with this code:
procedure TfrmTestEE.Button1Click(Sender: TObject);
var sr: TSearchRec;
  procedure AddFile;
  begin
    Memo1.Lines.Add(Format('%s : %x', [sr.Name, sr.Attr]));
  end;
begin
  if FindFirst('c:\Users\Default\MYDOCU~1', faHidden + faSysFile + faSymLink + faDirectory, sr) = 0 then
  try
    AddFile;
    while FindNext(sr) = 0 do
      AddFile;
  finally
    FindClose(sr);
  end;
end;

Open in new window


output:
My Documents : 2416

By checking the attributes i can see the symbolic link:
>  faHidden    = $00000002 platform;
> faSysFile   = $00000004 platform;
>  faDirectory = $00000010;

so far the parameters we know about ...
The 2 and 4 are in this list:
http://msdn.microsoft.com/en-us/library/system.io.fileattributes.aspx
0400: ReparsePoint
2000: NotContentIndexed

So you are looking for files with attr: Attr and $0400 = $0400

{ File attribute constants }

  faReadOnly  = $00000001 platform;
  faHidden    = $00000002 platform;
  faSysFile   = $00000004 platform;
  faVolumeID  = $00000008 platform deprecated;  // not used in Win32
  faDirectory = $00000010;
  faArchive   = $00000020 platform;
  faSymLink   = $00000040 platform;
  faNormal    = $00000080 platform;
  faTemporary = $00000100 platform;
  faAnyFile   = $000001FF;

Open in new window

0
 

Author Closing Comment

by:Allan_Fernandes
ID: 36502111
So do you do mind reading too ?
You answered my other queries too.
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Many admins will agree: WSUS is is a nice invention but using it on the client side when updating a newly installed computer is still time consuming as you have to do several reboots and furthermore, the procedure of installing updates, rebooting an…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Windows 8 comes with a dramatically different user interface known as Metro. Notably missing from the new interface is a Start button and Start Menu. Many users do not like it, much preferring the interface of earlier versions — Windows 7, Windows X…
Windows 8 came with a dramatically different user interface known as Metro. Notably missing from that interface was a Start button and Start Menu. Microsoft responded to negative user feedback of the Metro interface, bringing back the Start button a…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now