CreateHardLink

[This is preliminary documentation and subject to change.]

The CreateHardLink function establishes an NTFS hard link between an existing file and a new file. An NTFS hard link is similar to a POSIX hard link.

BOOL CreateHardLink(
  LPCTSTR lpFileName,
  LPCTSTR lpExistingFileName,
  LPSECURITY_ATTRIBUTES lpSecurityAttributes
);
 

Parameters

lpFileName
Pointer to the name of the new file to be opened.
lpExistingFileName
Pointer to the name of the existing file to be linked to the new file.
lpSecurityAttributes
Pointer to a SECURITY_ATTRIBUTES structure that specifies a security descriptor for the new file and determines whether child processes can inherit the returned handle. If lpSecurityAttributes is NULL, the object receives a default security descriptor and the handle cannot be inherited.

Return Values

If the function succeeds, the return value is nonzero.

If the function fails, the return value is zero. To get extended error information, call GetLastError.

Remarks

You can use hard links to provide multiple names for the same underlying file. Hard links synchronize updates to the underlying file. Therefore, modifications performed on the existing file are also performed on the new file to which it is linked.

QuickInfo

  Windows NT: Requires version 5.0 or later.
  Windows: Unsupported.
  Windows CE: Unsupported.
  Header: Declared in winbase.h.
  Import Library: Use kernel32.lib.
  Unicode: Implemented as Unicode and ANSI versions on Windows NT.

See Also

File Systems Overview, File System Functions, SECURITY_ATTRIBUTES