Registriert seit: 13. Nov 2017
355 Beiträge
Delphi 10.2 Tokyo Starter
|
AW: Verknüpfung (.lnk) Datei erzeugen
29. Jan 2018, 20:20
So?
Delphi-Quellcode:
function createLink(const aFileName, aLinkFileName, aParameter, aLinkDestination: string): Boolean;
var
psl: IShellLink;
ppf: IPersistFile;
begin
Result := False;
if Succeeded(CoCreateInstance(CLSID_ShellLink, nil, CLSCTX_inPROC_SERVER, IID_IShellLinkW, psl)) then
begin
psl.SetPath(PWideChar(aFileName));
psl.SetArguments(PWideChar(aParameter));
psl.SetWorkingDirectory(PWideChar(ExtractFilePath(aFileName)));
if Succeeded(psl.QueryInterface(IPersistFile, ppf)) then
begin
ppf.Save(PWideChar(aLinkDestination + aLinkFileName + '.lnk'), True);
Result := True;
end;
end;
end;
function GetDesktopFolder: string;
var
LStr: array [0 .. MAX_PATH] of Char;
begin
SetLastError(ERROR_SUCCESS);
Result := '';
if SHGetFolderPath(0, CSIDL_DESKTOPDIRECTORY, 0, 0, @LStr) = S_OK then
Result := IncludeTrailingPathDelimiter(LStr);
end;
function GetStartMenuFolder: string;
var
LStr: array [0 .. MAX_PATH] of Char;
begin
SetLastError(ERROR_SUCCESS);
Result := '';
if SHGetFolderPath(0, CSIDL_STARTMENU, 0, 0, @LStr) = S_OK then
Result := IncludeTrailingPathDelimiter(LStr);
end;
B := createLink(ParamStr(0), 'Shortcut Name', 'Parameter', GetDesktopFolder);
Sieht man auch hier
http://www.delphipraxis.net/191958-v...erstellen.html
|
|
Zitat
|