Function Reference


Establishes a hard link between an existing file and a new file

#include <WinAPIFiles.au3>
_WinAPI_CreateHardLink ( $sNewFile, $sExistingFile )


$sNewFile The name of the new file.
$sExistingFile The name of the existing file.

Return Value

Success: True.
Failure: False, call _WinAPI_GetLastError() to get extended error information


The _WinAPI_CreateHardLink() is only supported on the NTFS file system, and only for files, not directories.

The security descriptor belongs to the file to which a hard link points. The link itself is only a directory entry, and does not have a security descriptor.
Therefore, when you change the security descriptor of a hard link, you a change the security descriptor of the underlying file, and all hard links that point to the file allow the newly specified access.
You cannot give a file different security descriptors on a per-hard-link basis.

Use _WinAPI_DeleteFile() function to delete hard links. You can delete them in any order regardless of the order in which they are created.



See Also

Search CreateHardLink in MSDN Library.


#include <Array.au3>
#include <MsgBoxConstants.au3>
#include <WinAPIFiles.au3>

Local $sFile = @DesktopDir & '\' & StringRegExpReplace(_WinAPI_PathFindFileName(@ScriptName), '\A_+', '@')

; Create hard link to the current file with prefix "@" on your Desktop
If Not _WinAPI_CreateHardLink($sFile, @ScriptFullPath) Then
    MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Error', 'Unable to create hard link.')

; Enumerate all hard links to the file
Local $aData = _WinAPI_EnumHardLinks($sFile)

_ArrayDisplay($aData, '_WinAPI_EnumHardLinks')