码迷,mamicode.com
首页 > 其他好文 > 详细

【Inno Setup】检测是否需要预先重启

时间:2020-05-13 14:12:21      阅读:141      评论:0      收藏:0      [点我收藏+]

标签:inno   user   com   manager   str   trim   art   pos   code   

By Martin Prikryl

If you want to detect, if there is a pending rename that requires a restart, query PendingFileRenameOperations registry value.

See also How to find out if an MSI I just installed requested a Windows reboot?

function IsRestartPending: Boolean;
var
  S: string;
begin
  if RegQueryMultiStringValue(
       HKLM, SYSTEM\CurrentControlSet\Control\Session Manager,
       PendingFileRenameOperations, S) then
  begin
    Log(Format(PendingFileRenameOperations value exists with value [%s], [S]));
    Result := (Trim(S) <> ‘‘); { This additional check is probably not needed }
  end
    else
  begin
    Log(PendingFileRenameOperations value does not exist);
    Result := False;
  end;
end;

function InitializeSetup(): Boolean;
begin
  if IsRestartPending then
  begin
    MsgBox(Restart your machine please, mbError, MB_OK);
    Result := False;
    Exit;
  end;

  Result := True;
end;

 

【Inno Setup】检测是否需要预先重启

标签:inno   user   com   manager   str   trim   art   pos   code   

原文地址:https://www.cnblogs.com/liujx2019/p/12881823.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!