How to apply SetWindowDisplayAffinity to pre-created windows

  agent, c++, dll-injection, winapi, windows

I understood the explanation of the purpose of SetWindowDisplayAffinity. => This statement is clear and understandable.

The code we will then run for another application will give us an access denied error.

My main problem.
I don’t want to show open applications like notepad, chrome, visual studio and how can I do that. Do I need to inject dll into these applications? if so could you guide me or suggest a method

How can I run SetWindowDisplayAffinity function in one of the applications in this screenshot.

Source: Windows Questions