microsoft / Windows-Camera

Tools and samples for camera related APIs on Windows
MIT License
217 stars 69 forks source link

Ask a question about the CameraSettingsExternalSettingsApp project companion apps #60

Closed l-xg closed 2 weeks ago

l-xg commented 5 months ago

CameraSettingsExternalSettingsApp Hi,This project has great features, but I'm having some problems with it, so any help would be really appreciated!

1、Without DMFT driver, can we use UWP app to register companion app directly? 2、How to judge who the current companion app is(at the code level)? 3、How to remove the companion app completely(at the code level)?

LPBourret commented 4 months ago

Hi,

  1. the companion app is meant to be set by the camera vendor, not necessarily by anyone who may want to impact the default values aside from the Windows Camera Settings page. That said, the "SCSVCamPfn" registry entry identifies the app with such capability (https://github.com/microsoft/Windows-Camera/tree/master/Samples/CameraSettingsExternalSettingsApp#registering-the-app-with-camera-settings) so if you have Read /Write registry access in an app, it would be possible to programmatically specify an app's PFN for a target camera. Having such capability in a UWP app requires elevated privilege which can be obtain with "runFullTrust" (https://github.com/microsoft/Windows-Camera/tree/master/Samples/CameraSettingsExternalSettingsApp#registering-the-app-with-camera-settings). To access the registry location for a specific camera, you can use the CM_Open_Device_Interface_Key() API (https://learn.microsoft.com/en-us/windows/win32/api/cfgmgr32/nf-cfgmgr32-cm_open_device_interface_keyw), where the first parameter is the symbolic link name of the target camera. Using the retrieved key, you then would use RegSetValue() (https://learn.microsoft.com/en-us/windows/win32/api/winreg/nf-winreg-regsetvaluea) to set the "SCSVCamPfn" subkey value.
  2. This also allows you to read the value of the companion app associated to a camera, and then correlate that companion app Package Family Name (PFN) with an app such as by using the PackageManager.FindPackagesForUser() API (https://learn.microsoft.com/en-us/uwp/api/windows.management.deployment.packagemanager.findpackagesforuser?view=winrt-22621#windows-management-deployment-packagemanager-findpackagesforuser(system-string-system-string))
  3. Using the above steps, you could remove a companion app PFN set for a camera, but I would be very cautious and avoid doing so, overriding the intended design of a camera vendor.
l-xg commented 3 months ago

Hi, LPBourret Thank you for your reply😊, I will verify the relevant APIs.