PureBasic Forum
https://www.purebasic.fr/english/

[Done]ProgramID() is wrong for UWP apps
https://www.purebasic.fr/english/viewtopic.php?f=37&t=74141
Page 1 of 1

Author:  Dude [ Mon Dec 02, 2019 1:38 pm ]
Post subject:  [Done]ProgramID() is wrong for UWP apps

Just found out today that the ProgramID() returned for RunProgram() is not the correct process ID ("PID") for UWP apps, like the Win 10 Calculator. It works correctly for standard Win32 apps, though.

Code:
run=RunProgram("calc.exe","","",#PB_Program_Open)
Debug ProgramID(run) ; Doesn't match PID from Task Manager.

I did some research and the reason for this is that UWP apps are launched by ApplicationFrameHost.exe (AFH), and that's the PID that ProgramID() is getting. I guess this is not technically wrong, but since Calculator's PID doesn't match Task Manager, then it's probably not the right result to return? Ideally, ProgramID() should match Task Manager, no matter whether the run program was UWP or Win32 type.

Author:  fryquez [ Mon Dec 02, 2019 4:52 pm ]
Post subject:  Re: ProgramID() is wrong for UWP apps

No bug, ProgramID() returns the PID of the program that is started by RunProgram().

There are many cases where Windows does intercept a CreateProcess call and
there is no way for PureBasic to follow that chain.

But a remark in the help file should be added. + 1

Author:  Little John [ Mon Dec 02, 2019 8:07 pm ]
Post subject:  Re: ProgramID() is wrong for UWP apps

fryquez wrote:
But a remark in the help file should be added.

I agree.

Author:  Dude [ Wed Dec 04, 2019 9:00 am ]
Post subject:  Re: ProgramID() is wrong for UWP apps

I think the behavior of PureBasic should change, because this is an important issue for apps that interact with windows.

I'll let this screenshot of Task Manager and TaskList (DOS command) explain better: https://i.imgur.com/cdo0Dix.png :(

Author:  Fred [ Fri Dec 13, 2019 3:05 pm ]
Post subject:  Re: ProgramID() is wrong for UWP apps

I don't think it's PureBasic role to workaround apps launched by wrappers. A note could be put in the doc though

Author:  ebs [ Fri Dec 13, 2019 7:53 pm ]
Post subject:  Re: ProgramID() is wrong for UWP apps

Can anyone suggest a method to run another UWP app (Windows Camera) and be able to determine when it closes?

Page 1 of 1 All times are UTC + 1 hour
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/