Interact with Metro application from Win32 - windows-8

I have a traditional Win32 program which gets some data using WMI (and it cannot be fetched using API available to Metro apps). Now I want to make a tile with part of this information. As I've understood, it's impossible to simply send this data from Win32 program to the Metro application. What's the preferred way to do such thing?

There is no direct app to app communication method. What you want to do can be accomplished in several ways, however. Your Win32 app could write data to a location on the file system that a Metro style has access to. Also, you could synchronize your Win32 app with your Metro style app using the cloud. You need to be careful, however, as this might violate some of the app certification requirements.

If you are simply writing something for yourself (not concerned with publish your app), you might consider taking the functionality that currently have within your desktop app and encapsulating it within a wcf service running on localhost. Metro apps can call wcf services.

One option would be to have your Win32 program create the tile XML and deposit in Windows Azure storage (or really anything accessible via a URI) and then your Windows 8 Store application could subscribe to that tile via a Periodic Notification.
There are some constraints here which may or may not be relevant to your application - like the refresh rate of the tile (discrete periods from 30 minutes to 1 day) and the machine must be connected to the network when the poll from the URL is made.
You might be able to incorporate a background task to do something similar.

Related

Pass data between two winRT apps

Is there a way for apps running on WinRT to send information between them? I know about WinRT's sandboxing and the reasons behind it, but is there some mechanism for two apps created by the same author to pass data between each other?
This was announced for Windows 10 only. You can see the MSDN documentation for this already.
If you mean running 2 apps at the same time by split-screen, you could consider using socket to communicate between these 2 apps. But you need to ensure the port is not occupied.
The classes you need to use:
StreamSocketListener class
StreamSocket class
Article to reference: How to connect with a stream socket (XAML)
This is not possible in windows 8.1 applications because these are sandbox applications

establish communication between metro and desktop

I'm trying to make my store app communication with desktop app through websockets.
I know we can make metro app as a client and do WinRT way of communicating over.
For the desktop server part, i'm planning to write a dll that will contain server code and receive metro texts being sent over.
Can someone please tell if this is possible and how to write server code in a dll and if so should we be using winhttp for wbesockets in server side ?
Windows Store (WInRT) apps are executing in a sandbox which isolates them from network communication with other applications on the local machine (localhost). That being said, this protection can be disabled using CheckNetIsolation.exe. Visual Studio automatically does the same for debugging purposes, allowing you to call e.g. a web service on your local machine during development.
As for the desktop side; to communicate with web sockets client, you can make advantage of WinHTTP. There's a working example on MSDN.
Keep in mind, though, that any application communicating with localhost will not be certified for Windows Store and will require several additional steps to install it:
The Windows Store application package will need to be sideloaded since it won't be published in Windows Store.
Any desktop component it communicates with will need to be installed separately the same way as any other desktop application.
Using CheckNetIsolation.exe loopback exemption will need to be added for the Windows Store app.
If you can avoid it, I definitely suggest you don't try communicating directly with a desktop application from you Windows Store app.

Share settings between related Windows Store Apps

We are currently planning to develop a suite of Windows Store Apps. They are independent and fully work alone, but they are related and act in concert. If a user has several of them, they should share some of their settings (and data), so that the user does not have to manually change these settings in every single one of them.
Is such a scenario even intented?
And how to implement it?
Registry: Does not work. Apps cannot access the registry.
ApplicationData (LocalFolder, LocalSettings etc.): Does not work. Apps cannot access the data of other apps.
Cloud services: Kind of works, but only when the machine is online. Our apps should work offline, too. And we would need to create/rent such a cloud service, which would cause additional costs.
KnownFolder.DocumentsLibrary: This –currently– looks like the only solution to me. The apps are already saving and sharing data there, so let's just save our settings there, too. But the name of the shared folder is one of the settings! And Windows Store Apps cannot create hidden files, so the user can see the settings file. This makes this solution a bit... "rough".
Any other ideas or additional information I have missed?
If you want them to sync with each other instantly, even when the device is offline, then that's your only option. Windows 8 Apps are not intended to share settings.
So much want of sharing.
Roaming API will only share with the SAME app, the SAME user, ANY W8 device.
SkyDrive will only share across ANY app, the SAME user, ANY device.
Using Azure (or any web service) will share across ANY app, ANY user, ANY device.
Don't do this
Don't use the register, the API is not supported
Don't use the file system, the boundaries cause your app to be brittle
Don't use ApplicationData.AnyFolder, this is restricted to a single app GUID
You had might as well get "instant" out of your language, man. That just doesn't happen. But you can have fast (let's call it near instant); you can use Sockets or SignalR to connect your client to some service out there with nearly instant responses. A less sophisticated approach would be to poll from your client, too. It has served developers for decades.

Serial communication in metro style app?

I am developing metro style app which should read data from external device using serial communication but unfortunately metro apps does not support "Serial and parallel port API ". So i thought to use hyperterminal to read data from serial port and use it in my metro application. Is there any way to access data directly from hyperterminal using c# in metro style app? If no is there any other way to access data from serial port in metro style app?
You cannot make this work with Hyperterminal either. The sandbox in which Store apps operate explicitly defeats any attempt a Store app might make to use a inter-process communication mechanism.
Do ask yourself if it makes sense to publish such an application in the Store. The odds that a user that visits the store will have the required hardware to make your app useful are extremely slim. These kind of apps will stay desktop apps for a long time to come. If the manufacturer of the device sees a market opportunity to get his device operating in store apps then he'll create a Store compatible driver for it. But that's up to them, you cannot do this yourself.

How do I control a process from a web app?

I want to interact with a running process (doing things like querying information and changing settings) through a web application. How would I accomplish this?
From a 1000 foot view, you can expose an entry point from the running application the web service can access. In the case of ASP.NET/Windows Services (or any other running .net application on a windows machine) you can create a remotable object in the Windows Service which the ASP.NET web service can call and interface with.
If I were to do this on my own I would expose an API for the application using sockets. If you wanted to geat into the real crazy stuff you could expose a SOAP interface with your application - then have a MUCH eaiser time intergrating the control of the application in C# or even PHP.
I could be more specific but need to know
what OS you are running on
what
server side language you are using
for your webpage
do you have the
ability to modify the application you
want to control?