Click here to Skip to main content
15,880,427 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I know Windows Store Apps are executed in isolated mode (a sandbox). Hence I start an App (e.g. Microsoft Photos) by using IApplicationActivationManager.ActivateForFile, the image provided gets displayed and the return value of the function gives me the process Id (e.g. 6544 for a process named ‘ApplicationFrameHost’ and a main window title of ‘Photos’. But when I register a handler to the .Exited() event of the according process I won’t get informed when I close the App (unlike to a Win32/64 application like notepad.exe).

Unpleasantly furthermore I receive the same Process Id for the next image to be displayed as well – both images are held by the same process now. And all images displayed subsequently return the very same process Id as well... and my .Exited-Handler is still not called, neither in case I close only one of now several running Photo-Apps nor after finally I have closed all of them.

Any hint to get around that would be greatly appreciated!

What I have tried:

Since I could not yield notification about my image-process was closed I thought of looking up if it is still on display. I investigated all propertied of Process including the ProcessThreadCollection and ProcessStartInfo but found nothing to identify my displayed images. And even when I investigate the MainWindowsTitles by looping through the open windows (with User32.EnumWindows() or WindowsInterop.GetRootWindowsOfProcess(p.Id) this does not give me more then fife times “Photos” for fife displayed images – alas without the filenames of the images displayed!
Posted
Updated 15-Jan-21 8:12am
Comments
[no name] 11-Mar-19 15:45pm    
I think you're going to find that what "you" want is access to services that will require explicit grants of permission by the "user", which probably won't happen. Having to declare what you're about, you're app probably wouldn't even pass certification.
\\Coders\Rob 12-Mar-19 3:03am    
@Gerry: thx for your reply! Just to clarify: I am writing a Windows Desktop application to handle user documents. Upon user request I copy a file from Network to his Desktop and open it in the appropriate application (Word, Excel, pdf, Photos). When the user stops editing/closes the application I want to copy his changes back to the network store. Hence I need to know when he ends to use the file. This works fine for registered applications but not for Windows Store Apps!
RmcbainTheThird 15-Mar-19 8:53am    
How are you dealing with the problem of two different people working on their local copy of the file at more or less the same time? Who ever saves first is going to lose their changes when the other person saves their copy.

1 solution

process.EnableRaisingEvents = true;
process.Exited += new EventHandler(OnProcessExited);


private void OnProcessExited(object sender, EventArgs e)
{}
 
Share this answer
 
Comments
Richard Deeming 18-Jan-21 6:32am    
Read the question again - the OP has already tried this, and it doesn't work for Windows Store applications.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900