网站首页  词典首页

请输入您要查询的函数:

 

术语 createhardlink
释义 CreateHardLink
语法:
C++
BOOL WINAPI CreateHardLink(
__in LPCTSTR lpFileName,
__in LPCTSTR lpExistingFileName,
__reserved LPSECURITY_ATTRIBUTES lpSecurityAttributes
);
CreateHardLink功能
建立与现有的文件和一个新的文件硬链接。此功能只支持NTFS文件系统,并仅可用于文件,而不是目录。
作为一个要执行此操作的事务操作,请使用CreateHardLinkTransacted功能。
参数
lpFileName [in]
新文件的名称。
此参数不能指定一个目录的名字。
lpExistingFileName [in]
现有文件的名称。
此参数不能指定一个目录的名字。
lpSecurityAttributes
版权所有;必须为NULL。
返回值
如果函数成功,返回值为非零。
如果函数失败,返回值是零(0)。为了获得更多错误信息,调用GetLastError。
该可以用这个函数创建硬链接的最大数目是每个文件1023。如果超过1023链接创建一个文件,一个错误的结果。
备注
任何一个用CreateFile或CreateHardLink创建的文件的目录项是一个硬链接到相关的文件。另外一个硬链接,是与CreateHardLink函数创建可以让您有一个文件的多个目录项,即多个硬链接到同一个文件,它可以在相同的目录,或相同或不同名称的名称不同的目录中。然而,在所有的硬链接文件必须在同一个卷。
因为只有硬链接文件的目录项,该文件的许多变化是立即可见的应用程序能够通过它的硬链接引用它。然而,目录项的大小和属性信息更新只通过它改变了联系。
安全描述符属于该文件的硬链接点。该链接本身只是一个目录项,并没有一个安全描述符。因此,当您改变一个硬链接安全描述符,您改变底层文件的安全描述符,所有硬链接指向文件允许新指定的访问。您不能给一个文件不同的安全描述符每个硬连结的基础。
此函数不修改文件的安全描述符挂钩,即使安全描述符的信息是在lpSecurityAttributes参数传递。
使用的DeleteFile删除硬链接。您可以删除任何顺序无论它们的创建顺序。
旗,属性,访问和共享是CreateFile中指定的经营每个文件的基础。也就是说,如果您打开一个文件,不允许共享,另一个应用程序不能共享,通过创建一个新的硬盘链接到文件。
当您创建在NTFS文件系统的硬链接,目录中文件的属性信息项被刷新只有当文件被打开时,或GetFileInformationByHandle是与处理特定的文件名为。
要编译的应用程序使用此函数,定义为0x0500或更高_WIN32_WINNT宏。有关详细信息,请参阅使用Windows头。
符号链接的行为,如果路径指向一个符号链接,该函数创建一个硬链接到目标。
实例
下面的代码片段说明了如何调用CreateHardLink,以便它不会修改文件的安全描述符。该pszExistingFileName参数可以是原始文件名,或者任何现有的连接到一个文件。此代码后执行,pszNewLinkName指文件。
 BOOL fCreatedLink = CreateHardLink( pszNewLinkName,
     pszExistingFileName,
     NULL // reserved, must be NULL
);
 if ( fCreatedLink == FALSE )
{
;// handle error condition
}
要求:
最低支持:client-Windows 2000专业版
最低支持server-Windows 2000服务器
HeaderWinBase.h(头文件:winuser.h)
LibraryKernel32.lib
DLLKernel32.dll
Unicode和ANSI namesCreateHardLinkW(Unicode)和CreateHardLinkA(ANSI)的
参见
CreateFile
CreateHardLinkTransacted
的DeleteFile
文件管理函数
硬链接和结
符号链接
如果有任何问题和意见,请发送给微软(wsddocfb@microsoft.com)
生成日期:2009年9月3日
==英文原文==CreateHardLink Function
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.
To perform this operation as a transacted operation, use the CreateHardLinkTransacted function.
Syntax
C++
BOOL WINAPI CreateHardLink(
__in LPCTSTR lpFileName,
__in LPCTSTR lpExistingFileName,
__reserved LPSECURITY_ATTRIBUTES lpSecurityAttributes
);
Parameters
lpFileName [in]
The name of the new file.
This parameter cannot specify the name of a directory.
lpExistingFileName [in]
The name of the existing file.
This parameter cannot specify the name of a directory.
lpSecurityAttributes
Reserved; must be NULL.
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, call GetLastError .
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.
Remarks
Any directory entry for a file that is created with CreateFile or CreateHardLink is a hard link to an associated file. An additional hard link that is created with the CreateHardLink function allows you to have multiple directory entries for a file, that is, multiple hard links to the same file, which can be different names in the same directory, or the same or different names in different directories. However, all hard links to a file must be on the same volume.
Because hard links are only directory entries for a file, many changes to that file are instantly visible to applications that access it through the hard links that reference it. However, the directory entry size and attribute information is updated only for the link through which the change was made.
The security descriptor belongs to the file to which a hard link points. The link itself is only a directory entry, 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 the newly 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 descriptor information is passed in the lpSecurityAttributes parameter.
Use DeleteFile 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 in CreateFile 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 a new hard link to the file.
When you create a hard link on the NTFS file system, the file attribute information in the directory entry is refreshed only when the file is opened, or when GetFileInformationByHandle is called with the handle of a specific file.
To compile an application that uses this function, define the _WIN32_WINNT macro as 0x0500 or later. For more information, see Using the Windows Headers .
Symbolic link behavior—If the path points to a symbolic link, the function creates a hard link to the target.
Examples
The following code snippet shows you how to call CreateHardLink so that it does not modify the security descriptor of a file. The pszExistingFileName parameter can be the original file name, or any existing link to a file. After this code is executed, pszNewLinkName refers to the file.
 BOOL fCreatedLink = CreateHardLink( pszNewLinkName,
     pszExistingFileName,
     NULL // reserved, must be NULL
);
 if ( fCreatedLink == FALSE )
{
;// handle error condition
}
Requirements
Minimum supported clientWindows 2000 Professional
Minimum supported serverWindows 2000 Server
HeaderWinBase.h (include Windows.h)
LibraryKernel32.lib
DLLKernel32.dll
Unicode and ANSI namesCreateHardLinkW (Unicode) and CreateHardLinkA (ANSI)
See Also
CreateFile
CreateHardLinkTransacted
DeleteFile
File Management Functions
Hard Links and Junctions
Symbolic Links
Send comments about this topic to Microsoft
Build date: 9/3/2009
==原始网址==http://msdn.microsoft.com/en-us/library/aa363860(VS.85).aspx\n
随便看

 

windows api函数参考手册包含2258条windows api函数文档,详细介绍nodejs、java、rust调用windows api的方法技巧,是学习windows api编程的入门中文文档。

 

Copyright © 2004-2023 Winrtm.com All Rights Reserved
京ICP备2021023879号-40 更新时间:2024/10/6 13:22:53