MkLink

The FSF.MkLink function supports creating hard and symbolic links, directory junctions and mounting local drives to the file system. The function works only under Windows NT 4 or higher.
int WINAPI MkLink(
  const char *Src,
  const char *Dest,
  DWORD Flags
);

Parameters

Src
Name of the file object to which the link is created.
Dest
Name of the created link.
Flags
Operation mode. One of the following flags (MKLINKOP enum):
OperationDescription
FLINK_HARDLINK Create a hard link.
FLINK_JUNCTION Create a directory junction.
FLINK_VOLMOUNT Mount a local drive to the file system.
FLINK_SYMLINKFILE Create a file symbolic link.
FLINK_SYMLINKDIR Create a directory symbolic link.

You can combine operation mode with one of the following flags:

FlagDescription
FLINK_SHOWERRMSG Show error messages.
FLINK_DONOTUPDATEPANEL Do not update the panel after the link has been created.

Return value

1 - the link was created successfully.

0 - error creating link.

Possible error resons:

Remarks

  1. The links are created according to the following rules:
    • hard links are created only for files within a single NTFS partition (NT4/Win2K/XP);
    • Directory junctions are created only for directories within local NTFS partitions (Win2K/NTFS 5.0);
    • mounting local drives to the file system is possible only on NTFS partitions (Win2K/NTFS 5.0).
  2. If the value of Src is, for example, "C:", a volume mount will be created instead of a junction.
  3. If the destination directory for a volume mount operation is terminated with a backslash, a subdirectory "disk_N" will be created in Dest, where N is the letter of the drive being mounted.
  4. On Windows 2000 you cannot create a junction which points to a CD-ROM folder, but you can mount this CD-ROM disk as an NTFS folder (see Mount Points) and then create the necessary junction.

Example

See also:
GetNumberOfLinks