Вопрос How to add custom path for icon file entry on Desktop.ini

ffmla

Участник
ill use the following code for fixed path .ico files
Код:
procedure CreateIni ();
begin
SaveStringsToFile (ExpandConstant (' {app} \Desktop.ini '), [' [. ShellClassInfo] ', ' IconFile = icon.ico ', ' IconIndex = 0 '], False);
end;
But for making like path IconFile = {app}\icon.ico in ini create error

below code not working
Код:
procedure CreateIni ();
begin
SaveStringsToFile (ExpandConstant (' {app} \Desktop.ini '), [' [. ShellClassInfo] ', ' IconFile ={app}\ icon.ico ', ' IconIndex = 0 '], False);
end;
Any help..:help:
 

vint56

Ветеран
Проверенный
[Setup]
AppName=My Program
AppVerName=My Program
DefaultDirName={pf}\My Program
OutputDir=userdocs:My Program.

[Files]
Source: compiler:Examples\MyProg.exe; DestDir: {app}; Flags: ignoreversion

Код:
procedure CurStepChanged(CurStep: TSetupStep);
var
  ErrorCode: Integer;
begin
  if CurStep = ssPostInstall then
  begin
    SetIniString('.ShellClassInfo', 'IconResource',
                      ExpandConstant('{app}\MyProg.exe') + #13#10 'IconIndex=0', ExpandConstant('{app}\desktop.ini'));
    Exec('attrib', ' +r ' + '"' + ExpandConstant('{app}') + '"', '', SW_HIDE, ewWaitUntilTerminated, ErrorCode);
    Exec('attrib', ' +h +s ' + '"' + ExpandConstant('{app}\desktop.ini') + '"', '', SW_HIDE, ewWaitUntilTerminated, ErrorCode);
  end;
end;

procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
begin
  if CurUninstallStep = usUninstall then
    DeleteFile(ExpandConstant('{app}\desktop.ini'));
end;




++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
[Setup]
AppName=Иконка
AppVerName=Иконка
DefaultDirName={pf}\Иконка
DefaultGroupName=Иконка

[Languages]
Name: "russian"; MessagesFile: "compiler:Languages\Russian.isl"

[Dirs]
Name: "{app}"; Attribs: system; AfterInstall: CreateIni();

[Files]
Source: icon.ico; DestDir: {app}

Код:
type
#ifdef UNICODE
  #define A "W"
  PChar = PAnsiChar;
#else
  #define A "A"
#endif

function SetFileAttributes(lpFileName: PChar; dwFileAttributes: DWORD): BOOL; external 'SetFileAttributesA@kernel32.dll stdcall';
//******************************************* [ Папка, в которую устанавливается программа, имеет свою иконку ] ***************************************************//
procedure CreateIni();
begin
SaveStringsToFile(ExpandConstant('{app}\Desktop.ini'), ['[.ShellClassInfo]',
'IconFile=icon.ico',
'IconIndex=0'], False)
end;

procedure CurStepChanged(CurStep: TSetupStep);
begin
if CurStep = ssPostInstall then begin
  SetFileAttributes(PChar(ExpandConstant('{app}\Desktop.ini')), FILE_ATTRIBUTE_HIDDEN or FILE_ATTRIBUTE_SYSTEM);
end;
end;
//******************************************* [ Папка, в которую устанавливается программа, имеет свою иконку ] ***************************************************//
 
Последнее редактирование:
Сверху