![]() |
Problem beim Verknüpfung erstellen
Hallo Leute!
ich benutze die untere function von Delphi-Treff.de um eine Verknüpfung anzulegen...
Delphi-Quellcode:
Nur hab ich jetzt das Problem dass ich in einer Zeile beim compilieren die Meldung erhalte "Inkompatible Datentypen 'Char' und 'AnsiChar'". Kann mir einer sagen obs dafür ne funktion wie z.b IntToStr() oder StrToDate... usw gibt?
function CreateLink(const AFilename, ALNKFilename, ADescription: 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(AFilename)); psl.SetDescription(PChar(ADescription)); psl.SetWorkingDirectory(PChar(ExtractFilePath(AFilename)) ;); if SUCCEEDED(psl.QueryInterface(IPersistFile, ppf)) then begin GetMem(wsz, MAX_PATH*2); try MultiByteToWideChar(CP_ACP, 0, PChar(ALNKFilename), -1, wsz, MAX_PATH); ppf.Save(wsz, true); result:=true; finally FreeMem(wsz, MAX_PATH*2); end; end; end; end;
Delphi-Quellcode:
Gruß
MultiByteToWideChar(CP_ACP, 0, PChar(ALNKFilename), -1, wsz, MAX_PATH);
Sir K |
Re: Problem beim Verknüpfung erstellen
Hallo,
Deine Funktion läßt sich mit meinem Delphi 7 problemlos kompilieren, deshalb muss ich mal die :glaskugel: befragen: Probiere es bitte mal mit
Delphi-Quellcode:
MultiByteToWideChar(CP_ACP, 0, PAnsiChar(ALNKFilename), -1, wsz, MAX_PATH);
|
Re: Problem beim Verknüpfung erstellen
.. mal eine kleine Frage am Rande,
Ist die Konvertierung von MultiByte(Ansi?) nach WideChar durch MultiByteToWideChar überhaupt noch notwendig? Zitat:
Grüße Klaus |
Re: Problem beim Verknüpfung erstellen
Zitat:
Gruß Sir K |
Re: Problem beim Verknüpfung erstellen
.. und wie schaut es so aus?
Delphi-Quellcode:
Grüße
begin
//GetMem(wsz, MAX_PATH*2); try //MultiByteToWideChar(CP_ACP, 0, PChar(ALNKFilename), -1, wsz, MAX_PATH); ppf.Save(ALNKFileName, true); result:=true; finally //FreeMem(wsz, MAX_PATH*2); end; end; Klaus |
Re: Problem beim Verknüpfung erstellen
Hallo,
dann befolge bitte mal den Rat von Klaus und lass die Zeile
Delphi-Quellcode:
weg. Nach Aussage von Klaus ist dies für Deine Delphiversion nicht mehr erforderlich.
MultiByteToWideChar(CP_ACP, 0, PAnsiChar(ALNKFilename), -1, wsz, MAX_PATH);
|
Re: Problem beim Verknüpfung erstellen
...dann gibts die meldung ink. datent. String und PWideChar ind der Zeile
Delphi-Quellcode:
ppf.Save(ALNKFileName, true)
|
Re: Problem beim Verknüpfung erstellen
Hallo,
Zitat:
Delphi-Quellcode:
versuchen.
ppf.Save(PWideChar(ALNKFileName), true)
|
Re: Problem beim Verknüpfung erstellen
Dann versuch es mal so:
Delphi-Quellcode:
Edith sagt: zu langsam :?
if SUCCEEDED(psl.QueryInterface(IPersistFile, ppf)) then
begin {GetMem(wsz, MAX_PATH*2); try MultiByteToWideChar(CP_ACP, 0, PChar(ALNKFilename), -1, wsz, MAX_PATH); ppf.Save(wsz, true); result:=true; finally FreeMem(wsz, MAX_PATH*2); end;} ppf.Save(PWideChar(ALNKFilename), true); result:=true; end; |
Re: Problem beim Verknüpfung erstellen
Zitat:
|
Alle Zeitangaben in WEZ +1. Es ist jetzt 13:40 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz