【问题标题】:call RegQueryDWordValue to get office Excel Version using inno Setup installer使用 inno Setup 安装程序调用 RegQueryDWordValue 以获取 office Excel 版本
【发布时间】:2014-07-19 10:10:06
【问题描述】:

如何使用 inno Script 从注册表中获取安装的 MS office Excel 版本?我尝试了下面的代码,它给出了“找不到密钥”但它存在

   function InitializeSetup(): Boolean;
 var
  CurVer: Cardinal;
  key: string;

if RegQueryDWordValue(HKCR, 'Excel.Application\CurVer\','Default', CurVer) then
  begin
    // Successfully read the value
      MsgBox('Excel Version: ' + IntTOStr(CurVer),mbInformation, MB_OK);
    end else begin
      MsgBox('Key not found',mbInformation, MB_OK);
  end;

end;

【问题讨论】:

  • 请记住可以安装不同的版本。检查HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\XX.0\Excel 以获得所需的版本。

标签: excel installation registry inno-setup


【解决方案1】:

将 RegQueryDWordValue 更改为 RegQueryStringValue

function InitializeSetup(): Boolean;
 var
  CurVer: Cardinal;
  key: string;

begin


     //if RegQueryDWordValue(HKCR, 'Excel.Application\\CurVer\\','', CurVer) then
     if RegQueryStringValue(HKCR, 'Excel.Application\CurVer\','', key) then
  begin
    // Successfully read the value
      MsgBox('Excel Version: ' + key,mbInformation, MB_OK);
    end else begin
      MsgBox('Excel Not installed',mbInformation, MB_OK);
  end;

end;

【讨论】:

  • 正确,该值是REG_SZ 类型,而不是REG_DWORD。
【解决方案2】:

删除尾部反斜杠。

此外,RegEdit 中的 (Default) 值是没有名称的值:

if RegQueryDWordValue(HKCR, 'Excel.Application\CurVer','', CurVer) then

【讨论】:

    猜你喜欢
    • 2023-01-25
    • 1970-01-01
    • 2013-07-29
    • 2015-05-18
    • 2011-01-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多