Autor Beitrag
AXMD
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 4006
Erhaltene Danke: 7

Windows 10 64 bit
C# (Visual Studio 2019 Express)
BeitragVerfasst: Di 26.08.03 15:51 
Hi,

ich verwende folgenden Code (aus meinem Delphi 5 Kochbuch), um einen Link zu erstellen. Das hat bisher immer funktioniert - bis zu dem Tag, an dem ich meine Sources unter Windows XP kompiliert habe - unter jedem OS gibt es die Meldung, dass die Verknüpfung nicht erstellt werden konnte. Was mache ich falsch?

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:
function TForm4.CreateLink(lpszPathobj, lpszPathLink, lpszDesc: String): Boolean;
var
  psl: IShellLink;
  ppf: IPersistFile;
  wsz: PWideChar;
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
      GetMem(wsz, MAX_PATH * 2);
      try
        MultiBytetoWideChar(CP_ACP, 0, PChar(lpszPathLink), - 1, wsz, MAX_PATH);
        ppf.Save(wsz, true);
        Result := true;
      finally
        FreeMem(wsz, MAX_PATH * 2);
        end;
     end;
   end;
end;


ausblenden Delphi-Quelltext
1:
2:
3:
4:
  if Form3.FlatCheckListBox1.Items[0].Checked then begin
    if (not(CreateLink(path + 'dstp.exe', GetFolder(CSIDL_DESKTOP) + '\Terminplaner.lnk''Startet den DSTP Terminplaner zur einfachen Organisation Ihrer Termine am Computer'))) and (not(CreateLink(path + 'dstp.exe', GetFolder(CSIDL_COMMON_DESKTOPDIRECTORY) + '\Terminplaner.lnk''Startet den DSTP Terminplaner zur einfachen Organisation Ihrer Termine am Computer'))) then
      MessageDlg('Erstellen einer Verknüpfung fehlgeschlagen!'+#13+#10+'Ziel: ' + GetFolder(CSIDL_DESKTOP) + '\Terminplaner.lnk', mtError, [mbOK], 0);
    end;


AXMD

PS.: Ich will nur den Fehler lokalisieren und nicht hören, ich soll einen Stanard-Installer wie Install Shield verwenden ;)
MathiasSimmack
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Di 26.08.03 22:22 
Hast du mal den Code aus den FAQs probiert?
Ist IMHO von Popov da eingetragen worden.

Ach ja, du könntest auch einen Standardinstaller nehmen ... :mrgreen:
Tino
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Veteran
Beiträge: 9839
Erhaltene Danke: 45

Windows 8.1
Delphi XE4
BeitragVerfasst: Mi 27.08.03 10:15 
Hat glaube ich noch keiner gesagt: Aber du könntest zum Beispiel InstallShield benutzen... 8)
blackbirdXXX

ontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic starofftopic starofftopic star
Beiträge: 1077
Erhaltene Danke: 1

Ubuntu Dapper

BeitragVerfasst: Do 09.10.03 19:57 
Wenn mich nicht alles täuscht muss man getfolder in setfolder umändern.

_________________
Klein, schwarz und ärgert Techniker? Jumper!