Geht auch ohne Componente
* Arguments: Retrieves the command-line arguments associated with a Shell link object.
* Description: Retrieves the description string for a Shell link object.
* LinkObject: Retrieves the filename of Shell link object (Pfad + Dateiname)
Delphi-Quelltext
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29:
| procedure GetLinkInfo(const LinkName: String; var LinkObject,Arguments,Description: String); var IObject: IUnknown; ILink: IShellLink; IFile: IPersistFile; sObj,sArg,sDcr: Array [0..Max_Path] of Char; Find: WIN32_FIND_DATA; LinkFile: WideString; h: THandle; begin LinkFile:= LinkName; IObject := CreateComObject(CLSID_ShellLink); ILink := IObject as IShellLink; IFile := IObject as IPersistFile;
h:= FindFirstFile(PChar(LinkName), Find); If h<> INVALID_HANDLE_VALUE then begin Windows.FindClose(h); IFile.Load(PWChar(LinkFile), STGM_READ); ILink.GetPath(@sObj, Max_Path, Find, SLGP_RAWPATH); ILink.GetArguments(@sArg, Max_Path); ILink.GetDescription(@sDcr, Max_Path); end; LinkObject:= sObj; Arguments:= sArg; Description:= sDcr; end; |
Aufruf:
Delphi-Quelltext
1: 2: 3: 4: 5: 6: 7: 8:
| function GetFileNameLink(LinkName: String): String; var FileName, Args, Desc: String; begin GetLinkInfo(LinkName, FileName, Args, Desc); Result:= FileName; ShowMessage(FileName); end; |
Nachtrag:
ShlObj,ComObj und ActiveX in Uses Klausel einbinden.
Gruß gispos