Movatterモバイル変換


[0]ホーム

URL:


Skip to main content

This browser is no longer supported.

Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.

Download Microsoft EdgeMore info about Internet Explorer and Microsoft Edge
Table of contentsExit focus mode

CreateHardLinkTransactedA function (winbase.h)

  • 2023-02-09
Feedback

In this article

[Microsoft strongly recommends developers utilize alternative means to achieve your application’s needs. Many scenarios that TxF was developed for can be achieved through simpler and more readily available techniques. Furthermore, TxF may not be available in future versions of Microsoft Windows. For more information, and alternatives to TxF, please seeAlternatives to using Transactional NTFS.]

Establishes a hard link between an existing file and a new file as a transacted operation.This function is only supported on the NTFS file system, and only for files, not directories.

Syntax

BOOL CreateHardLinkTransactedA(  [in] LPCSTR                lpFileName,  [in] LPCSTR                lpExistingFileName,       LPSECURITY_ATTRIBUTES lpSecurityAttributes,  [in] HANDLE                hTransaction);

Parameters

[in] lpFileName

The name of the new file.

This parameter cannot specify the name of a directory.

[in] lpExistingFileName

The name of the existing file.

This parameter cannot specify the name of a directory.

lpSecurityAttributes

Reserved; must beNULL.

[in] hTransaction

A handle to the transaction. This handle is returned by theCreateTransaction function.

Return value

If the function succeeds, the return value is nonzero.

If the function fails, the return value is zero (0). To get extended error information, callGetLastError.

The maximum number of hard links that can be created with this function is 1023 per file. If more than 1023links are created for a file, an error results.

The files must reside on the local computer; otherwise,the function fails and the last error code is set toERROR_TRANSACTIONS_UNSUPPORTED_REMOTE.

Remarks

Any directory entry for a file that is created withCreateFileTransacted orCreateHardLinkTransacted is a hard link to anassociated file. An additional hard link that is created with theCreateHardLinkTransacted function allows you tohave multiple directory entries for a file, that is, multiple hard links to the same file, which can be differentnames in the same directory, or the same or different names in different directories. However, all hard links to afile must be on the same volume.

Because hard links are only directory entries for a file, when an application modifies a file through any hardlink, all applications that use any other hard link to the file see the changes. Also, all of the directoryentries are updated if the file changes. For example, if a file size changes, all of the hard links to the fileshow the new file size.

The security descriptor belongs to the file to which a hard link points. The link itself is only a directoryentry, 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 thenewly specified access. You cannot give a file different security descriptors on a per-hard-link basis.

This function does not modify the security descriptor of the file to be linked to, even if security descriptorinformation is passed in thelpSecurityAttributes parameter.

UseDeleteFileTransacted to delete hard links.You can delete them in any order regardless of the order in which they are created.

Flags, attributes, access, and sharing that are specified inCreateFileTransacted operate on a per-file basis.That is, if you open a file that does not allow sharing, another application cannot share the file by creating anew hard link to the file.

When you create a hard link on the NTFS file system, the file attribute information in the directory entry isrefreshed only when the file is opened, or whenGetFileInformationByHandle is called with thehandle of a specific file.

Symbolic links:  If the path points to a symbolic link, the function creates a hard link to the target.

In Windows 8 and Windows Server 2012, this function is supported by the following technologies.

TechnologySupported
Server Message Block (SMB) 3.0 protocolNo
SMB 3.0 Transparent Failover (TFO)No
SMB 3.0 with Scale-out File Shares (SO)No
Cluster Shared Volume File System (CsvFS)No
Resilient File System (ReFS)No
 

Note that SMB 3.0 does not support TxF.

Note

The winbase.h header defines CreateHardLinkTransacted as an alias that automatically selects the ANSI or Unicode version of this function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code that is not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, seeConventions for Function Prototypes.

Requirements

RequirementValue
Minimum supported clientWindows Vista [desktop apps only]
Minimum supported serverWindows Server 2008 [desktop apps only]
Target PlatformWindows
Headerwinbase.h (include Windows.h)
LibraryKernel32.lib
DLLKernel32.dll

See also

CreateFileTransacted

DeleteFileTransacted

File Management Functions

Hard Links and Junctions

Symbolic Links

Transactional NTFS


Feedback

Was this page helpful?

YesNo

In this article

Was this page helpful?

YesNo