Function ShellLinkCreate() Foundation

Create a Shell link object.

Syntax
ShellLinkCreate( <cLinkTarget>, <cLinkFile>, [<cWorkingDir>],;
                 [<cCmdArgs>],  [<cDescr>] ) --> <lSuccess>
Parameters
<cLinkTarget>
A character string with the target of the new link object. A link target can be a file or folder. <cLinkTarget> must include a fully-qualified path.
<cLinkFile>
A character string with the file name of the link object. If the file is not to reside in the current directory, <cLinkFile> must include a fully-qualified path.
<cWorkingDir>
A character string with the working directory for the link object. The parameter is optional unless the link target requires a working directory.
<cCmdArgs>
An optional character string with the command line arguments for the link object. The <cCmdArgs> parameter is useful when creating a link to an application that takes special arguments.
<cDescr>
An optional character string with the description of the new link object.
Return

ShellLinkCreate() returns a logical value that indicates whether the link could be created. In this case, the value .T. (true) is returned. In case of an error, return is .F. (false).

Description

The function ShellLinkCreate() can be used by an Xbase++ application to create a Shell link object. A link object points to another file or folder and can be placed independently of its target object. Links are frequently used to allow quick access to files or folders.

Examples
Creating and resolving a Shell link object


PROCEDURE Main() 
 LOCAL bFileExists := .F. 
 LOCAL nFile 

  // 
  // Create a dummy file to serve as the target 
  // for the link about to be created 
  IF File("samplelink.lnk") == .T. 
     Alert( "Cant't run sample - a link of the same name already exists!" ) 
     QUIT 
  ENDIF 

  IF File("samplefile.txt") == .F. 
     nFile := FCreate( "samplefile.txt" ) 
     FClose( nFile ) 
  ELSE 
     bFileExists := .T. 
  ENDIF 

  // 
  // Create a Shell link to the dummy file, 
  // specify a dummy string as the link 
  // object's description 
  // 
  ShellLinkCreate( CurDirectory() + "\" + "samplefile.txt", ; 
                   "samplelink.lnk",,,; 
                   "Test Description" ) 

  WAIT "Link created. Press a key to resolve it." 

  // 
  // Resolve the link just created 
  // 
  ? "Link target is: " + ShellLinkResolve( "samplelink.lnk" ) 

  ? 
  WAIT 

  // 
  // Clean up 
  // 
  FErase( "samplelink.lnk" ) 
  IF bFileExists == .F. 
     FErase( "samplefile.txt" ) 
  ENDIF 

RETURN 
Feedback

If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.