检测用户是否选择“所有用户”或“只有我”在自定义操作中

发布于 2024-08-25 23:49:00 字数 205 浏览 1 评论 0原文

我试图检测用户在安装程序期间是否选择了“所有用户”或“仅我”广播。我有一个自定义操作设置,它覆盖了多个方法(OnCommit、OnBeforeInstall 等)。现在我正试图在 OnCommit 期间找出这些信息。

我读过我想要获取的属性是 ALLUSERS 属性,但我没有找到它将存储在实例/本地数据中的位置。

有谁知道有办法得到它吗?

-本

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.

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?

-Ben

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

银河中√捞星星 2024-09-01 23:49:00

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

解决方案是在安装项目的属性 GUI 中查看自定义操作。从那里,选择一个自定义操作允许我编辑 CustomActionData,在这种情况下我输入:

/AllUsers=[ALLUSERS]

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

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;
    }

希望这对那里的人有帮助:)

Going to answer my own here.

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]

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 :)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文