Desktop Bridge 开机启动设置

用xml编辑器打开Package.appxmanifest,在【Package】中加入

xmlns=”http://schemas.microsoft.com/appx/manifest/foundation/windows10″
xmlns:uap=”http://schemas.microsoft.com/appx/manifest/uap/windows10″
xmlns:desktop=”http://schemas.microsoft.com/appx/manifest/desktop/windows10″
xmlns:mp=”http://schemas.microsoft.com/appx/2014/phone/manifest”
xmlns:rescap=”http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities”
IgnorableNamespaces=”uap rescap mp desktop”

找到【Applications】/【Extensions】节点,加入


    

找到【Capabilities】节点加入

 

下面是调用代码:win32中

获取当前是否开机启动,绑定到chkBoxStartup

 var startupTask = await Windows.ApplicationModel.StartupTask.GetAsync("Win32appTask");
    switch (startupTask.State)
    {
        case Windows.ApplicationModel.StartupTaskState.Disabled:
            chkBoxStartup.Checked = false;
            break;
        case Windows.ApplicationModel.StartupTaskState.DisabledByUser:
            chkBoxStartup.Checked = false;
            break;
        case Windows.ApplicationModel.StartupTaskState.Enabled:
            chkBoxStartup.Checked = true;
            break;
    }

设置开机启动和取消,绑定到chkBoxStartup

var startupTask = await Windows.ApplicationModel.StartupTask.GetAsync("Win32appTask");
    if (startupTask.State == Windows.ApplicationModel.StartupTaskState.Enabled)
    {
        startupTask.Disable();
        chkBoxStartup.Checked = false;
        MessageBox.Show("The task has been disabled");
    }
    else
    {
        var state = await startupTask.RequestEnableAsync();
        switch (state)
        {
            case Windows.ApplicationModel.StartupTaskState.DisabledByUser:
                MessageBox.Show("The task has been disabled by the user");
                chkBoxStartup.Checked = false;
                break;
            case Windows.ApplicationModel.StartupTaskState.Enabled:
                MessageBox.Show("The task has been enabled");
                chkBoxStartup.Checked = true;
                break;
        }
    }

原创文章,转载请注明本文链接地址(违者必究):Desktop Bridge 开机启动设置

打赏作者
很喜欢这篇文章,打赏犒劳下作者,以此激励作者创作更多

您的支持将鼓励我们继续创作!

[微信] 扫描二维码打赏

[支付宝] 扫描二维码打赏

发表评论

电子邮件地址不会被公开。 必填项已用*标注