编程方式访问所有用户开始菜单 [英] Programmatically access All Users Start Menu

查看:158
本文介绍了编程方式访问所有用户开始菜单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有谁知道如何以编程方式访问所有用户启动菜单?

Does anyone know how to programmatically access the "All Users" Startup Menu?

在XP中,设在这里:

C:\Documents and Settings\All Users\Start Menu\Programs\Startup

而在Windows 7中,位置为:

And in Windows 7, located here:

C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup

具体而言,我有一个安装和部署的项目,我想提出一个快捷方式到应用程序在启动菜单中的所有用户,以便应用程序启动,只要有人登录。

Specifically, I've got a Setup and Deployment project, and I'd like to put a shortcut to the application in the Startup menu for all users so that the application is start whenever anyone logs in.

编辑:<一href="http://www.neowin.net/forum/topic/580258-c%23-get-path-of-start-menu-programs-all-users/page__p__588773578&#entry588773578">I'm pretty的肯定,这就是布莱恩接到了他的答案。

推荐答案

没有对 Environment.GetFolderPath 以正常的方式为所有用户开始菜单中定义的常量,但您可以通过使用Win32 API SHGetSpecialFolderPath 做这种方式:

There is no constant defined for the normal way of Environment.GetFolderPath for the all users start menu, but you can do it this way by using the Win32 API SHGetSpecialFolderPath:

class Program
{
    [DllImport("shell32.dll")]
    static extern bool SHGetSpecialFolderPath(IntPtr hwndOwner,
       [Out] StringBuilder lpszPath, int nFolder, bool fCreate);
    const int CSIDL_COMMON_STARTMENU = 0x16;  // All Users\Start Menu

    static void Main(string[] args)
    {
        StringBuilder path = new StringBuilder(260);
        SHGetSpecialFolderPath(IntPtr.Zero, path, CSIDL_COMMON_STARTMENU, false);
        string s = path.ToString();
    }
}

这篇关于编程方式访问所有用户开始菜单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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