All pastes #36371 Raw Edit

NTFS Link 2.1 Unicod

public text v1 · immutable
#36371 ·published 2006-01-10 18:15 UTC
rendered paste body
--- source-HEAD\IconOverlayHook.pas	Tue Jan 10 16:19:18 2006
+++ source\IconOverlayHook.pas	Tue Jan 10 14:54:39 2006
@@ -140,6 +140,27 @@
   Result := 'Hardlink';
 end;
 
+function NtfsGetHardLinkInfoW(const FileName: WideString; var Info: TNtfsHardLinkInfo): Boolean;
+var
+  F: THandle;
+  FileInfo: TByHandleFileInformation;
+begin
+  Result := False;
+  F := CreateFileW(PWideChar(FileName), GENERIC_READ, FILE_SHARE_READ or FILE_SHARE_WRITE, nil, OPEN_EXISTING, 0, 0);
+  if F <> INVALID_HANDLE_VALUE then
+  try
+    if GetFileInformationByHandle(F, FileInfo) then
+    begin
+      Info.LinkCount := FileInfo.nNumberOfLinks;
+      Info.FileIndexHigh := FileInfo.nFileIndexHigh;
+      Info.FileIndexLow := FileInfo.nFileIndexLow;
+      Result := True;
+    end;
+  finally
+    CloseHandle(F);
+  end
+end;
+
 function THardlinkOverlayHook.IsMemberOf(pwszPath: PWideChar;
   dwAttrib: DWORD): HResult;
 var
@@ -154,7 +175,7 @@
   try
     // Retrieve file information, and look if there are links existing; if no,
     // than this file is *not* a link, and we skip
-    if NtfsGetHardLinkInfo(pwszPath, LinkInfo) then
+    if NtfsGetHardLinkInfoW(pwszPath, LinkInfo) then
       if LinkInfo.LinkCount > 1 then
         Result := S_OK;
   except