Autor Beitrag
AScomp
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 162


Delphi 5, Delphi 7, Delphi 2007, Delphi 2009, Delphi XE, Delphi 10 Seattle
BeitragVerfasst: Do 05.02.09 22:35 
Hallo zusammen,

hätte da noch ein letztes Problem für heute. ^^

Und zwar werden die Verknüpfungen seit D2009 nicht mehr korrekt erstellt, schätze ein Problem mit Unicode:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
function TFormMain.CreateLink(lpszPathObj, lpszArg, lpszPathLink, lpszDesc, WorkDir, lpszIcon: String): Boolean;
var
   psl: IShellLink;
   ppf: IPersistFile;
begin
     result := False;
     if SUCCEEDED(CoCreateInstance(CLSID_ShellLink, nil, CLSCTX_INPROC_SERVER, IID_IShellLinkA, psl)) then begin
        psl.SetPath(PChar(lpszPathObj));
        psl.SetArguments(PChar(lpszArg));
        psl.SetDescription(PChar(lpszDesc));
        if Copy(WorkDir, Length(WorkDir) - 1, Length(WorkDir)) = '\\' then
           psl.SetWorkingDirectory(PChar(Copy(WorkDir, 1, Length(WorkDir) - 1)))
        else
           psl.SetWorkingDirectory(PChar(WorkDir));
        psl.SetIconLocation(PChar(lpszIcon), 0);
        if SUCCEEDED(psl.QueryInterface(IID_IPersistFile, ppf)) then begin
           ppf.Save(StringToOLEStr(lpszPathLink), TRUE);
           result := true;
        end;
     end;
end;


Hat bis Delphi 2007 einwandfrei funktioniert, mit Delphi 2009 wird zwar die Verknüpfung erstellt, aber alle Werte sind falsch (teilweise abgehackt, teilweise gar nicht vorhanden).

Hat jemand eine Idee?

_________________
Viele Grüße,
Andy
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19335
Erhaltene Danke: 1751

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Do 05.02.09 22:42 
user profile iconAScomp hat folgendes geschrieben Zum zitierten Posting springen:
ausblenden Delphi-Quelltext
1:
     if SUCCEEDED(CoCreateInstance(CLSID_ShellLink, nil, CLSCTX_INPROC_SERVER, IID_IShellLinkA, psl)) then begin					
Du gibst hier die Ansi-Version an (A am Ende). Schreib mal lieber W oder ohne den Buchstaben, dann solte es gehen.

Ansonsten könntest du alles explizit auf Ansi schreiben, wenn du die Unicodeunterstüzung ohnehin nicht nutzt (also PAnsiChar, AnsiString, ...).
AScomp Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 162


Delphi 5, Delphi 7, Delphi 2007, Delphi 2009, Delphi XE, Delphi 10 Seattle
BeitragVerfasst: Do 05.02.09 22:43 
Aiaiaiai, danke dir! Ist schon spät, das A hab ich glatt übersehen!