My big picture problem: I need to send a signal from a Windows 10 desktop application (or service, really) to a UWP XAML MVVM application on a single instance / OS machine.
I used semaphores in the global namespace, but they do not work at all on UWP (for security reasons, perhaps by design). There is no joy.
I tried UWP sockets and this works with UWP as a listener only if the client is on a remote machine. Is this a security solution too? No idea. Exempting the application from the loopback restriction does not help, since this only applies if the UWP application is the client that is executing the request. There is no joy.
OK, so I left a Windows message in a specific window on OS ...
My test application is an example of AdventureWorks for UWP on GitHub. How to do this to process a Windows message sent from another process? I'm at a dead end.
Below is the code for my test client.
Question: How do I handle this message in AdventureWorks? It is important to keep the code changes to a minimum, but I'm currently stuck and not going to continue. (It seems to be a secret secret ...)
Please, help! Sample code.
class Program { [DllImport("user32.dll")] public static extern IntPtr FindWindow(string lpClassName, String lpWindowName); [DllImport("user32.dll")] public static extern int SendMessage(IntPtr hWnd, uint wMsg, IntPtr wParam, IntPtr lParam); [DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)] static extern uint RegisterWindowMessage(string lpString); [DllImport("kernel32.dll")] static extern uint GetLastError(); static void Main(string[] args) { const string lpClassName = "ApplicationFrameWindow"; const string lpWindowName = "AdventureWorks.Shopper"; IntPtr hwnd = FindWindow(lpClassName, lpWindowName); uint messageId = RegisterWindowMessage("MetaAutomationMessage"); int sendMessageResult = SendMessage(hwnd, messageId, IntPtr.Zero, IntPtr.Zero); Console.WriteLine(string.Format("Message result is '{0}', ", sendMessageResult)); uint lastError = GetLastError(); Console.WriteLine(string.Format("GetLastError result is '{0}', ", lastError)); } }