Autor Beitrag
s-hus
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 17



BeitragVerfasst: Do 29.11.07 11:35 
Gibt es eine Möglichkeit, wenn man nur den Pfad der Verknüpfung hat, dort den Zielpfad auslesen zu können?
Dreht sich immer noch um die Geschichte mit dem Mehrfachstart. Es ist nun fast fertig, nur die Verknüpfungen öffnen sich noch doppelt, also müsste ich den Zielpfad von denen auslesen können. Hoffe, dass mich das dann weiterbrinen würde.
Lieben Gruß
s-hus Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 17



BeitragVerfasst: Do 29.11.07 14:55 
Habe das Ganze nun über eine Komponente gelöst, die sich TShellLink nennt und als Freeware im Internet erhältlich ist.
gispos
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 94

WIN 7
XE10, D2007
BeitragVerfasst: Do 29.11.07 19:45 
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)
ausblenden 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:
ausblenden 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