>In an application that handles several hundred thousands of image files (especially JPGs) the need to eliminate doubling of image-data got me to consider windows shortcut files as a way of pointing to an image file from different directories.
>
>In VFP I can create those links using the windows scripting host along the lines of the following function:
>
>LPARAMETERS lcDestinationPath, lcDestinationFilename, lcShortcutTarget
>LOCAL oWsh
>
>* add Backspace just in case
>lcDestinationPath = ADDBS(lcDestinationPath )
>
>* get reference to the Windows Scripting Host
>* (if installed on the system – may not always be the case)
> oWsh = CREATEOBJECT("wscript.shell")
>
>* path and filename for the short-cut file
>oShort = oWsh.CreateShortcut(lcDestinationPath + ; lcDestinationFilename+".LNK")
>
>* die Datei, zu der der Shortcut führen soll ist lcShortcutTarget
>
>* Target path setzen in den WSH object
> oShort.TargetPath = lcShortcutTarget
>
> * das ganze abspeichern wie oben definiert
> oShort.Save
>
> RELEASE pWsh
>
>Since I would like to also traverse a directory of LNK-files and show the pictures referred to I need to set the picture-property of my image control the target of the link (to not the link itself), for example:
>
>The link file in a directory:
>
>"PIC_T033327.JPG.LNK.LNK"
>
>The target of this link file:
>
>"H:\WEB_SCHWANGER_KOPIEN\001_ANDREABROUWER_000891\PROOFS_BW_AL\PIC_T033364.JPG"
>
>Interestingly enough, when I use the VFP getfile() function and pick one of those linkfiles, GETFILE() resolves the link file and extracts the path to the JPG (the target of the link file). Unfortunately adir() does not and doesn’t seem to have parameters to do so.
>
>When I look at the content of the LNK-file, it is obvious, that the Drive, path, filename etc. are contained therein, but is there a good or simple way to read out the exact info?
>
>Does anyone know were to find the file structure or documentation about these shortcut files?
>
>Maybe there is a windows scripting host approach or an api call of sorts?
>
>Any help would be greatly appreciated.
>
>Teddy Billewicz – Heidelberg, GERMANY
Teddy,
You can extract it useing Shell.Application but I doubt you need:
Declare short SHGetSpecialFolderPath In Shell32.Dll ;
integer hwndOwner, String @ lpszPath, ;
integer nFolder, short Fcreate
#Define MAX_PATH 267
#Define CSIDL_DESKTOP 0x0000
lpszPath = Replicate(Chr(0),MAX_PATH)
If SHGetSpecialFolderPath(0,@lpszPath,CSIDL_DESKTOP,0) # 0
lcFolder = Left(lpszPath,At(Chr(0),lpszPath)-1)
Endif
loShell = Createobject("Shell.Application")
loFolder = loShell.Namespace(m.lcFolder)
For lnFile = 1 To Adir(aLnk,Addbs(m.lcFolder)+"*.lnk")
loItem = loFolder.ParseName(aLnk[m.lnFile,1])
If !Isnull(loItem) AND loItem.IsLink
objLink = loItem.GetLink
? "Link properties of shortcut:"+aLnk[m.lnFile,1]
? "-------------------------------------"
? "Description:", objLink.Description
? "Path:", objLink.Path
? "Arguments:", objLink.Arguments
? "WorkingDirectory:", objLink.WorkingDirectory
? "-------------------------------------"
Else
? "File doesn't exist or not a link."
Endif
Endfor
Why instead of creating tons of shortcuts you don't put the path&filenames in a table along with a Description that'd replace shortcut.
Cetin