uses Windows, ComObj, ShlObj, ActiveX; { Function: Create the specified file shortcuts TargetFile: shortcut points to a file or directory CreateAt: create a shortcut path to save the function returns True if successful, False represents a failure } function CreateShortCut ( the TargetFile, CreateAt: String ): Boolean; const IID_IPersistFile: TGUID = ' {} 0000010B-0000-0000-C000-000000000046 ' ; var intfLink: the IShellLink; IntfPersist: the IPersistFile; the begin IntfLink: = CreateComObject (CLSID_ShellLink) AS the IShellLink; the Result: = (IntfLink <> nil )and the SUCCEEDED (IntfLink.QueryInterface (IID_IPersistFile, IntfPersist)) and the SUCCEEDED (intfLink.SetPath (PAnsiChar (the TargetFile))) and the SUCCEEDED (IntfPersist.Save (PWideChar (a WideString (CreateAt)), True)); End ; { Function: returns the specified target shortcut file LinkFile: full path of the file the shortcut function represents a failed return an empty string otherwise successful } function GetTargetOfShorCut (LinkFile: string ): string ; const IID_IPersistFile: TGUID = ' {0000010B-0000-0000-C000 } -000 000 000 046 ' ; var intfLink: the IShellLink; IntfPersist: the IPersistFile; PFD: _WIN32_FIND_DATA; bSuccess: Boolean; the begin the Result: = '' ; IntfLink: = CreateComObject (CLSID_ShellLink) AS the IShellLink; SetString (the Result, nil , the MAX_PATH); { second parameter may also be transmitted Load method STGM_WRITE or STGM_READWRITE, information showing shortcut access STGM_READ: read-only STGM_WRITE: write only STGM_READWRITE: write GetPath method of the third parameter may also pass SLGP_UNCPRIORITY or SLGP_SHORTPATH, represents the return path of the target format SLGP_UNCPRIORIT: UNC network path SLGP_SHORTPATH: DOS 8.3 format path SLGP_RAWPATH: long path } bSuccess: = (IntfLink <> nil )and the SUCCEEDED (IntfLink.QueryInterface (IID_IPersistFile, IntfPersist)) and the SUCCEEDED (IntfPersist.Load (PWideChar (a WideString (LinkFile)), STGM_READ)) and the SUCCEEDED (intfLink.GetPath (PAnsiChar (the Result), the MAX_PATH, PFD, SLGP_RAWPATH)); IF Not bSuccess the then the Result: = '' ; End ; except SetPath GetPath and methods, other methods may be provided IShellLink interface or other information read shortcut: getArguments: obtaining parameter information GetDescription: a description information GetHotkey: obtaining shortcuts GetIconLocation: get icon GetIDList: get the shortcut target object item identifier list (Windows shell each object, such as files, directories and printers have a unique Identifiler List Item) GetPath: get the target file or directory shortcuts full path GetShowCmd: obtaining operating mode shortcuts, such as conventional the window is maximized GetWorkingDirectory: get working directory Resolve: search according to certain rules trying to get a target object, even if the target object has been deleted or moved, renamed, and here is the method information corresponding setArguments SetDescription SetHotkey SetIconLocation SetIDList SetPath SetRelativePat SetShowCmd SetWorkingDirectory