【问题标题】:How can I find an application if i don't know its GUID如果我不知道应用程序的 GUID,如何找到应用程序
【发布时间】:2017-02-08 23:00:45
【问题描述】:

为了比较版本,我必须确定我的应用是否已经安装。 我使用注册表来存储整个必要的信息,如果我能以某种方式从注册表中读取字符串,那将非常有用。这里的主要问题是我不知道我自己的 GUID,它在之前的安装过程中是随机的。

为了生成我的注册表路径,我编写了以下脚本:

Function .onInit
    ${If} ${RunningX64}
        StrCpy $R0 "SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall"
    ${Else}
        StrCpy $R0 "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"
    ${EndIf}
FunctionEnd

主要部分:

Section "Main" sec
System::Call 'ole32::CoCreateGuid(g .s)'
Pop $0
WriteRegStr HKLM "$R0\$0" 'DisplayVersion' '${AppVersion}'
SectionEnd

所以,基本上我需要找到一种方法来读取DisplayVersion 字符串。我希望FindFirst 有一些变化,但对于注册表。

【问题讨论】:

    标签: nsis guid uninstallation


    【解决方案1】:

    使用EnumRegKey 枚举注册表项:

    !include LogicLib.nsh
    
    Section
    
    StrCpy $0 0
    loop:
        EnumRegKey $1 HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" $0
        StrCmp $1 "" done
        ReadRegStr $2 HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$1" "DisplayName"
        ${If} $2 == "My Application Name"
            ReadRegStr $2 HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$1" "DisplayVersion"
            DetailPrint "TODO: Compare $2 to version here..."
        ${EndIf}
        IntOp $0 $0 + 1
        Goto loop
    done:
    
    SectionEnd 
    

    【讨论】:

      猜你喜欢
      • 2020-10-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-05-06
      • 1970-01-01
      • 1970-01-01
      • 2014-01-29
      相关资源
      最近更新 更多