question

haominghsu-3931 avatar image
0 Votes"
haominghsu-3931 asked haominghsu-3931 commented

How cam i use regedit or WPF disable and enable camera immediately(Windows 10)

I use WPF do a camera detection APP,
I want the app can turn off and turn on immediately even if the webcam already open

but I try many methods can't finish it
1. regedit set Value=Allow or Deny
HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\DeviceAccess\Global{E5323777-F976-4f5b-9B55-B94699C46E44}\Value
2. regedit set Value=Allow or Deny
HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\CapabilityAccessManager\ConsentStore\webcam\Value
3. set LetAppsAccessCamera=00000002(use Administrator)
HKEY_LOCAL_MACHINE \ SOFTWARE \ Policies \ Microsoft \ Windows \ AppPrivacy\LetAppsAccessCamera
4. use devcon.exe run disable this USB camera, but if i want to enable this I have to reboot computer...

only this method can turn off webcam immediately, but my app can't trigger this action
click this button
41680-2020-11-23-11-03-47-a000010501-101772531-service-m.png


windows-wpfwindows-10-hardware-performance
· 8
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@haominghsu-3931 Did you try to close the camera by killing process? Such as using Process.GetProcessById(processId,machineName).Kill();?

0 Votes 0 ·

No.. This project can't colse process, only want disable and enable that process's camera :(

0 Votes 0 ·

On my OS (Windows 10, 1909)
the key
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\CapabilityAccessManager\ConsentStore\webcam
seems to work
I have only a Virtual Webcam to test, but if I set the value to deny and I launch a C# app which reads the Webcam, I get "access denied"...
(and I tested a change notification with RegNotifyChangeKeyValue)


0 Votes 0 ·

I try three methods can't close alrealy opened webcam include your methods
you can try open windows10 default camera , and then edit this registry key, it doesn't colse immediately
It olny disable camera after restart

0 Votes 0 ·

@haominghsu-3931 There may be no api in WPF to close the camer immediately. The Answer may give you some help, I have tested it and it works on closing camera immediately.

0 Votes 0 ·
Show more comments

0 Answers