检测用户是否选择了“所有用户".或"Just Me"在自定义动作中 [英] Detecting if the user selected "All Users" or "Just Me" in a Custom Action

查看:118
本文介绍了检测用户是否选择了“所有用户".或"Just Me"在自定义动作中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试检测用户在安装程序期间是否选择了所有用户"或仅我"单选.我有一个自定义操作设置,它覆盖了几种方法(OnCommit,OnBeforeInstall等).现在,我正试图在OnCommit期间查找此信息.

I'm trying to detect if the user has selected the "All Users" or the "Just Me" radio during the install of my program. I have a custom action setup that overrides several methods (OnCommit, OnBeforeInstall, etc.). Right now I'm trying to find out this information during OnCommit.

我已经读到我想获取的属性是ALLUSERS属性,但是我没有运气找到它存储在实例/本地数据中的位置.

I've read that the property I want to get at is the ALLUSERS property, but I haven't had any luck finding where it would be stored in instance/local data.

有人知道要怎么实现吗?

Does anyone know of a way to get at it?

-本

推荐答案

要在这里回答我自己的问题.

Going to answer my own here.

解决方案是在安装项目的属性gui中查看自定义操作.从那里选择一个自定义动作,使我可以编辑CustomActionData,在这种情况下,我将放置:

The solution was to view the custom actions in the properties gui for the Setup project. From there, selecting a custom action allowed me to edit CustomActionData, in which case I put:

/AllUsers=[ALLUSERS]

从那里,我可以通过自定义操作CS代码检测它是否是所有用户的安装:

From there I could detect whether it was an all-users install from the custom action CS code:

private bool IsAllUsersInstall()
    {
        // An ALLUSERS property value of 1 specifies the per-machine installation context.
        // An ALLUSERS property value of an empty string ("") specifies the per-user installation context.

        // In the custom action data, we have mapped the parameter 'AllUsers' to ALLUSERS.
        string s = base.Context.Parameters["AllUsers"];

        if (s == null)
            return true;
        else if (s == string.Empty)
            return false;
        else
            return true;
    }

希望这对外面的人有帮助:)

Hope this helps someone out there :)

这篇关于检测用户是否选择了“所有用户".或"Just Me"在自定义动作中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆