Autor Beitrag
nowawob
Hält's aus hier
Beiträge: 1

Win98

BeitragVerfasst: Mo 14.06.04 18:21 
Welche Syntax benötige ich, wenn ich ein Program schreiben will,
das Desktop-Verknüpfungen erstellt ?
maxk
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1696
Erhaltene Danke: 1

Win XP, Debian Lenny
Delphi 6 Personal
BeitragVerfasst: Mo 14.06.04 18:33 
Schau dir mal den Source meine Komponente an: www.maxk.keepfree.de/download/ShortCut.rar

_________________
Ein Computer wird das tun, was Du programmierst - nicht das, was Du willst.
Karlson
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 2088



BeitragVerfasst: Mo 14.06.04 18:39 
Gibt auch ne Lsg. direkt aus em edh2000:

ausblenden volle Höhe 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:
30:
31:
32:
33:
34:
uses ActiveX, ShlObj, ComObj;

function CreateLink(lpszPathObj,lpszPathLink,
  lpszDesc: string):Boolean;
var
  psl: IShellLink;
  ppf: IPersistFile;

const
  IID_IPersistFile: 
     TGUID = (D1:$0000010B;
              D2:$0000;
              D3:$0000;
              D4:($C0,$00,$00,$00,$00,$00,$00,$46));
begin
  result := False;
  if SUCCEEDED(CoCreateInstance(CLSID_ShellLink,
                                nil,
                                CLSCTX_INPROC_SERVER,
                                IID_IShellLinkA,
                                psl)) then
    begin
      psl.SetPath(PChar(lpszPathObj));
      psl.SetDescription(PChar(lpszDesc));
      if SUCCEEDED(psl.QueryInterface(IID_IPersistFile,
                   ppf)) then
        begin
          ppf.Save(StringToOLEStr(lpszPathLink),TRUE);
          Result := true;
          ppf._Release;
        end;
    end;
  psl._Release;
end;


Aufrufen musst du die Funktion so:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
procedure Verknuepfungerstellen;
var a,b,c : string;
begin
a := 'c:\kalle.exe'//Zieldatei
b := 'c:\verknüpfungen\kalle.inc'//Dort wird die Verk. erstellt
c := 'verk mit kalle.exe'//Beschreibungstext;

CreateLink(a,b,c);
end;
maxk
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1696
Erhaltene Danke: 1

Win XP, Debian Lenny
Delphi 6 Personal
BeitragVerfasst: Mo 14.06.04 18:43 
Der Code ist Klasse. Da muss ich doch gleich meine Kompi umschreiben (hatte immer Probleme mit CoCreateInstance) :wink:

_________________
Ein Computer wird das tun, was Du programmierst - nicht das, was Du willst.
Karlson
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 2088



BeitragVerfasst: Mo 14.06.04 19:01 
Hehe, in Copy und Paste war ich schon immer einsame Spitze :lol: Wie schon geschrieben musste den Lob an den Autor vom edh weiterschicken ;)