2
votes

We have a classic desktop application on Windows which needs to communicate with the web browsers. Therefore we created web browser extensions and use the native messaging technology to pass messages between the JavaScript on a web page and the native desktop application. This way of communication is currently supported in Google Chrome, Mozilla Firefox and Opera. Now we want to perform the same task in Microsoft Edge. But unfortunately Microsoft Edge supports native messaging in a different way the other browsers do. In Chrome/Firefox/Opera simply a serialized JSON string can be passed to a native messaging host application via stdin/stdout.

As Microsoft Edge is a Universal Windows Platform Application it only supports communicating with another UWP App via AppService (and further communicating with our classic desktop application via FullTrustProcess). Our classic desktop app cannot be converted to an UWP app for many reasons. Basically this is no problem, but there are some issues I currently don't know how to solve:

UWP Apps seem to require a user interface. But the extension's purpose is only the communication, there is no UI intended.

So I could display some information about the UWP App / Edge Extension when the user opens the UWP app, but if the user closes the App (e.g. by clicking the (X) button), the UWP app process is killed by the system. If this happens during a communication process, the native messaging communication is interrupted and the user will receive an error. So far I have not found a way to avoid this. When Microsoft Edge launches the UWP App (initiated by "runtime.connectNative" in the extension's background JavaScript code) it runs in background mode and will be terminated if Microsoft Edge exits which is OK. But if the user opens the App (e.g. via start menu), the process for the App is reused and it is now running in foreground mode. And then if the App UI is closed by the user, the process which initially was started by Microsoft Edge will be terminated. I have looked at the official "ExtendedExecution" example from Microsoft, but this behaves the same way.

  • Is there any way to send the UWP App to background mode execution instead of termination if the user closes the UI of the App? So that the App can continue running in background mode as it did before?
  • Or is there any way to hide the UI in the OnLaunched event (e.g. then our classic desktop app will be opened, and the user will now not be able to manually close the UWP app any more)?

Probably I can find the HWND of the UWP app from our native desktop app and perform some ugly hacks with it, but I definitely want to avoid this.

Regards, Dominik

1

1 Answers

0
votes

There are background tasks in uwp https://docs.microsoft.com/en-us/windows/uwp/launch-resume/support-your-app-with-background-tasks

Also you'll be interested in this setting 'AppListEntry' in package.appxmanifest file. With it a link to your application won't appear in start menu

<Applications>
    <Application Id="id" Executable="$targetnametoken$.exe" EntryPoint="entrypoint.App">
      <uap:VisualElements AppListEntry="none" .../>

...