Establishes a hard link between an existing file and a new file.
#Include <WinAPIEx.au3>
_WinAPI_CreateHardLink ( $sNewFile, $sExistingFile )
$sNewFile | The name of the new file. |
$sExistingFile | The name of the existing file. |
成功: | 返回 1. |
失败: | 返回 0 并设置 @error 标志为非 0 值. |
在MSDN中搜索
#Include <APIConstants.au3>
#Include <Array.au3>
#Include <WinAPIEx.au3>
Opt('MustDeclareVars', 1)
Global Const $sFile = @DesktopDir & '\' & StringRegExpReplace(_WinAPI_PathFindFileName(@ScriptName), '\A_+', '@')
Global $aData
; Create hard link to the current file with prefix "@" on your Desktop
_WinAPI_CreateHardLink($sFile, @ScriptFullPath)
If @error Then
MsgBox(16, 'Error', 'Unable to create hard link.')
Exit
EndIf
; Enumerate all hard links to the file
$aData = _WinAPI_EnumHardLinks($sFile)
_ArrayDisplay($aData, '_WinAPI_EnumHardLinks')
FileDelete($sFile)