The inno setup script modifies the configuration file parameters and exits the running program before uninstalling

                                                                            Inno setup tool use summary

1. Modify a ticket configuration file method in the packaging script:

Example: Modify the parameter Langtype in the configuration file through language selection

[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"
Name: "chinesesimplified"; MessagesFile: "compiler:Languages\ChineseSimplified.isl"

[Code]
procedure CurStepChanged(CurStep: TSetupStep); 
var
languageName: string;
begin
  if CurStep=ssDone then // execute after software installation
  begin
    languageName := ActiveLanguage(); // get the language selected by the user
    if 'chinesesimplified' = languageName then
    begin
      SetIniString('LANGUAGE','Langtype','2',ExpandConstant('{app}/Settings/Config/config.dat')); end
    else 
    if 'english' = languageName then
    begin
  SetIniString('LANGUAGE',' Langtype','1',ExpandConstant('{app}/Settings/Config/config.dat'));
    end;
  end; 
end;    

Configuration file content config.dat

[LANGUAGE]
Total=24
Langtype=1

2、

When inno setup is packaged, close the running program method before uninstalling, and exit the program with the window name.
// Determine whether the client is running when uninstalling
function InitializeUninstall(): Boolean;
var ErrorCode: Integer;
var IsRunning: HWND; 
begin
  Result :=true; //The installation program continues
  IsRunning:=FindWindowByWindowName('xxx xxx');/ /xxx xxx is the name of the window
  if(IsRunning<>0)then
  begin
  if Msgbox('The uninstaller has detected that the software is running.' #13#13 'Do you want to continue uninstalling? Click "Yes" to continue uninstalling, or press "No" Quit!', mbConfirmation, MB_YESNO) = idYES then
    begin
      PostMessage(IsRunning, 18, 0, 0); // quit
      IsRunning:=FindWindowByWindowName('xxx xxx');
    end 
   else 
    begin
     end;
   end;
end;

//----------Uninstall the driver, delete the relevant directory after completion ----------
procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
begin
    if CurUninstallStep = usDone then
    begin
       //Delete {app } Folder and all files in it
    DelTree(ExpandConstant('{app}'), True, True, True);
    DelTree(ExpandConstant('{commonappdata}\xx'), True, True, True);//need to be cleared folder name

    end;
end;

Guess you like

Origin blog.csdn.net/liujing_sy/article/details/112978004