header file: unistd.h
int link(const char *path1, const char *path2);
header file: Windows.h
BOOL WINAPI CreateHardLink( __in LPCTSTR lpFileName,
__in LPCTSTR lpExistingFileName,
__reserved LPSECURITY_ATTRIBUTES lpSecurityAttributes);
The link() function creates a new link path2 for the existing
file path1. The Windows function CreateHardLink provides similar
functionality, but with slightly different syntax. For full
details, see the MSDN article.
The CreateHardLink is a C++ function and requires Windows 2000
Professional, Windows 2000 Server, or above. Additionally,
CreateHardLink is only supported when using the NTFS
filesystem.
Example of Use in Windows
#include <windows.h>
BOOL fCreatedLink = CreateHardLink(pszNewLinkName,
pszExistingFileName,
NULL // reserved, must be NULL
);
if ( fCreatedLink == FALSE ) {
;// handle error condition
}