How check if Screen recorder run in wpf?

linky 21 Reputation points
2020-11-09T08:27:49.907+00:00

Hi I have media element in my program and I do not want the user record the Content. So I need to Block every Screen recorder in Windows, Linux and Mac.

First: I wanted to use Process.GetProcess to Block all of that program and Create Black list, But there is so many of them and the name process of some of them different in each OS.

Second: I decided to Create White list and only let use Use program I want, otherwise my app is stop working until user close all program. But in this solution can not be filtered properly because C# can not get the Owner of process.

Now I think all of the Screen Recorder with All screen records, with any feature, probably have a fixed central structure and use a registry, especially in operating systems.

I wanted to know what this registry is and how to check it with c#? Also, if my solution is wrong, how can I recognize and close the screen records? Even if the user has programmed his own screen recorder?

Developer technologies | Windows Presentation Foundation
0 comments No comments
{count} votes

Answer accepted by question author
  1. Castorix31 91,416 Reputation points
    2020-11-09T08:58:03.7+00:00

    You can use SetWindowDisplayAffinity

    I did a test on my OS (Windows 10 1909) and it worked

    Declarations :

    [DllImport("User32.dll", SetLastError = true)]  
    private static extern bool SetWindowDisplayAffinity(IntPtr hWnd, uint dwAffinity);  
    
    public const int WDA_NONE   = 0x00000000;  
    public const int WDA_MONITOR = 0x00000001;  
    public const int WDA_EXCLUDEFROMCAPTURE = 0x00000011;  
    

3 additional answers

Sort by: Most helpful
  1. linky 21 Reputation points
    2020-11-10T06:11:41.083+00:00

    Thank you. I will try and tell you the result here.

    0 comments No comments

  2. linky 21 Reputation points
    2020-11-10T07:03:14.937+00:00

    Your code worked on my OS. my OS is win 10 and the according to MSDN this code worked for win 7 and higher Version. but are this code worked on Linux and Mac to?

    0 comments No comments

  3. linky 21 Reputation points
    2020-11-10T09:20:48.943+00:00

    sorry for another post in row.
    I took a few more tests and found that despite the video not being recorded, the audio was still being recorded. What solution would you suggest for this too?
    Or I want stop playing the media element after recorder open. But how can I do it?


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.