函数参考


_WinAPI_FindFirstFileName

Creates an enumeration of all the hard links to the specified file.

#Include <WinAPIEx.au3>
_WinAPI_FindFirstFileName ( $sPath, ByRef $sLink )

参数

$sPath The name of the file.
$sLink The first link name found for the specified file.

返回值

Success The search handle.
失败: 返回 0 并设置 @error 标志为非 0 值, @extended 标志可能包含一个系统错误代码.

注意/说明

After the search handle has been established, use it in the _WinAPI_FindNextFileName() function to search for
other hard links to the specified file.

When the search handle is no longer needed, it should be closed using the _WinAPI_FindClose() function.

本函数需要 Windows Vista 或更高版本系统.

相关

详情参考

在MSDN中搜索


示例/演示


#Include <Array.au3>
#Include <WinAPIEx.au3>

Opt('MustDeclareVars', 1)

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

Global $hSearch, $sLink

; 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

$hSearch = _WinAPI_FindFirstFileName($sFile, $sLink)
While Not @error
    ConsoleWrite(_WinAPI_PathAppend(_WinAPI_PathStripToRoot($sFile), $sLink) & @CR)
    _WinAPI_FindNextFileName($hSearch, $sLink)
WEnd

Switch @extended
    Case 38 ; ERROR_HANDLE_EOF

    Case Else
        MsgBox(16, @extended, _WinAPI_GetErrorMessage(@extended))
EndSwitch

FileDelete($sFile)