This sample demonstrates how to create a symbolic link for a file.
You can find the SymLink sample project at:
- Start > Programs > Embarcadero RAD Studio > Samples > Delphi > RTL > SymLink
- Subversion Repository for Delphi: http://radstudiodemos.svn.sourceforge.net/viewvc/radstudiodemos/branches/RadStudio_XE2/Delphi/RTL/SymLink/
This sample is a Delphi console application that allows the user to create a symbolic link file for a target file.
How to Use the Sample
- Navigate to Start > Programs > Embarcadero RAD Studio > Samples and open symlink.dproj.
- Build symlink.exe.
- You can either:
- Set the names of the symlink file and target file in the Run > Parameters dialog and then press F9 or choose Run > Run.
- In the command line, navigate to the folder where the symlink executable was created and use the symlink [LinkFile] [TargetFile] command.
The project has one file, symlink.dpr, which contains the main program source module.
There are no classes in this application. The .dpr file is responsible for creating the symbolic link file based on the command-line parameters provided by the user.
- The TFile.CreateSymLink method is used to create the symbolic link file.
- ParamCount and ParamStr are the functions used to handle the command-line parameters.
- In order to create the symlink file, it must not already exist.