Kernel32CreateHardLink(String, String, SecurityAttributes) Method
Establishes a hard link between an existing file and a new file.
This function is only supported on the NTFS file system, and only for files, not directories.
Namespace: DevCase.Win32.NativeMethodsAssembly: DevCase.net48 (in DevCase.net48.dll) Version: 6.0.0.0 (6.0)
XMLNS for XAML: Not mapped to an xmlns.
[DllImportAttribute("Kernel32.dll", CharSet = CharSet.Auto, BestFitMapping = false,
ThrowOnUnmappableChar = true, SetLastError = true)]
public static bool CreateHardLink(
string dstFilePath,
string srcFilePath,
SecurityAttributes reserved = default
)
<DllImportAttribute("Kernel32.dll", CharSet := CharSet.Auto, BestFitMapping := false,
ThrowOnUnmappableChar := true, SetLastError := true>]
Public Shared Function CreateHardLink (
dstFilePath As String,
srcFilePath As String,
Optional reserved As SecurityAttributes = Nothing
) As Boolean
Dim dstFilePath As String
Dim srcFilePath As String
Dim reserved As SecurityAttributes
Dim returnValue As Boolean
returnValue = Kernel32.CreateHardLink(dstFilePath,
srcFilePath, reserved)
public:
[DllImportAttribute(L"Kernel32.dll", CharSet = CharSet::Auto, BestFitMapping = false,
ThrowOnUnmappableChar = true, SetLastError = true)]
static bool CreateHardLink(
String^ dstFilePath,
String^ srcFilePath,
SecurityAttributes reserved = SecurityAttributes()
)
[<DllImportAttribute("Kernel32.dll", CharSet = CharSet.Auto, BestFitMapping = false,
ThrowOnUnmappableChar = true, SetLastError = true)>]
static member CreateHardLink :
dstFilePath : string *
srcFilePath : string *
?reserved : SecurityAttributes
(* Defaults:
let _reserved = defaultArg reserved new SecurityAttributes()
*)
-> bool
No code example is currently available or this language may not be supported.
- dstFilePath String
-
The name of the new file.
This parameter may include the path but cannot specify the name of a directory.
- srcFilePath String
-
The name of the existing file.
This parameter may include the path cannot specify the name of a directory.
- reserved SecurityAttributes (Optional)
-
Reserved; must be Zero.
Boolean
If the function succeeds, the return value is
.
If the function fails, the return value is
.
The maximum number of hard links that can be created with this function is 1023 per file.
If more than 1023 links are created for a file, an error results.
To get extended error information, call
GetLastWin32Error.