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):
Operation | Description |
---|---|
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:
Flag | Description |
---|---|
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:
- For hard links:
- Src and Dest are on different partitions;
- the partition is not NTFS;
- the partition is not local;
- Src does not exist or is not a file;
- Dest already exists;
- For directory junctions:
- Src or Dest is not on the local partition;
- the partition is not NTFS 5.0;
- Src does not exist or is not a directory;
- Dest exists, but is not an empty directory;
- For volume mounts:
- Src or Dest is not on the local partition;
- the partition for Dest is not NTFS 5.0;
- Src does not exist or is not a local drive;
- Dest exists, but is not an empty directory;
Remarks
- 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).
- If the value of Src is, for example, "C:", a volume mount will be created instead of a junction.
- 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.
- 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: