I have created a Flex Desktop Application with Adobe Air. I need to protect the application from being captured. By changing the window display affinity of the application, the application can be protected from being captured. How to use win API in flex? Is there any other way to protect the window from being captured?
First you have to make sure that the main window does not have the WS_EX_LAYERED
Windows style. That style makes SetWindowDisplayAffinity
fails with code 8 (ERROR_NOT_ENOUGH_MEMORY
), at least on my machine (Seven Pro 64 bits). In your -app.xml file
, set the value to false
for the node <transparent>
under <initialWindow>
.
Second, you have to choose how to inject a regular C DLL in the application process, as the API will fail with error 5 (ERROR_ACCESS_DENIED
) if you try to change the affinity of a window not living in the caller process.
One possible injection method is using the SetWindowsHookEx
API. Google will give you many hits about that one. Feel free to ask for some details. You obviously needs cooperation of another process, here (and some Win32 APIs practice).
Another possible way is coding an 'ACTIONSCRIPT® Extensions for ADOBE® AIR®' (PDF).
The later seems preferable:
I used the first technique, as I am more fluent in raw Win32 APIs about DLL, than I am with AIR and Action Script...
I successfully tested that first technique with a very simple "Hello World" AIR Desktop application, and get a nice "All Black" image after Print Screen.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With