问题描述
我有一个 Windows 通用 UWP 应用,我想在 Windows 10 家庭版上将其作为替换外壳启动。
通常对于 Win32 应用程序,这是将 HKCU\Software\Microsoft\Windows NT\CurrentVersion\Winlogon\Shell 设置为适当的 EXE。
我已经在 Package.appxmanifest 中使用执行别名配置了 UWP 应用
<Extensions>
<uap5:Extension
Category="windows.appExecutionAlias"
Executable="App1.exe"
EntryPoint="App1.App">
<uap5:AppExecutionAlias>
<uap5:ExecutionAlias Alias="App1.exe" />
</uap5:AppExecutionAlias>
</uap5:Extension>
</Extensions>
我还覆盖了 App.OnActivated() 来启动应用程序:
protected override void OnActivated(IActivatedEventArgs args)
{
switch (args.Kind)
{
case ActivationKind.CommandLineLaunch:
{
CommandLineActivatedEventArgs cmdLineArgs =
args as CommandLineActivatedEventArgs;
CommandLineActivationoperation operation = cmdLineArgs.Operation;
string cmdLinestring = operation.Arguments;
string activationPath = operation.CurrentDirectoryPath;
Frame rootFrame = Window.Current.Content as Frame;
if (rootFrame == null)
{
rootFrame = new Frame();
rootFrame.NavigationFailed += OnNavigationFailed;
Window.Current.Content = rootFrame;
rootFrame.Navigate(typeof(MainPage),string.Format("CurrentDirectory={0},Arguments={1}",activationPath,cmdLinestring));
Window.Current.Activate();
}
}
break;
default:
{
Frame rootFrame = Window.Current.Content as Frame;
if (rootFrame == null)
{
rootFrame = new Frame();
rootFrame.NavigationFailed += OnNavigationFailed;
Window.Current.Content = rootFrame;
rootFrame.Navigate(typeof(MainPage),Environment.CurrentDirectory,string.Empty));
Window.Current.Activate();
}
}
break;
}
}
从命令行运行 App1.exe 工作正常。
然而放置 App1.exe 注册表:Shell='App1.exe'
不启动应用程序(登录时屏幕保持黑色。
我认为这是可能的,因为如果我设置 Shell='Skype.exe'
这是 Skype UWP 应用的执行别名,Skype 在登录时正常启动。
我正在寻找拼图的缺失部分。
** 编辑 2/14/21 ** 所以,我认为问题在于 UWP 应用程序托管在 explorer.exe 应用程序中,如果没有运行它,该应用程序将永远无法运行。或者它以某种方式启动了 UWP 框架。
我认为 Skype 很可能是托管 UWP 应用:Created Hosted apps
所以我所做的是制作一个标准的 Win32 应用程序,该应用程序启动 explorer.exe 并通过实现键盘钩子来防止 Windows 键和其他潜在的快捷方式,并隐藏任务栏,在它可以显示任何内容之前迅速削弱它。然后启动 UWP 应用。
它有点hackish,所以我没有发布它作为解决方案,希望仍然发布一个更清洁的
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)