OK, I know there are quite a few posts on this topic. However, none of them provide the solution to my issue: I don't want just to turn off my monitor(s), I wish my code to turn off a specific monitor. The URL the most people refer to, http://fci-h.blogspot.com/2007/03/turn-off-your-monitor-via-code-c.html, doesn't help here, as it turns off all the displays.
So, I have my laptop screen and an additional external monitor. While I'm watching movies, I switch the display to the external monitor and my laptop screen goes black, however, it's still on and glowing in the dark. I wish to turn it off. Could anyone help please?
EDIT: Is there any way to acomplish this, meaning it needn't have to be written in .Net. Basically, I just need an .exe file that's able to turn the particular monitor off and on alternately.
It looks like there's no good way of turning off a specific monitor, but it is possible to set your laptop's backlight to minimum brightness. Depending on which version of Windows you have, there are different ways to do it:
send IOCTL_VIDEO_SET_DISPLAY_BRIGHTNESS I/O control as described here: http://msdn.microsoft.com/en-us/magazine/dvdarchive/cc163415.aspx
use WMI method WmiSetBrightness as described here: What API call would I use to change brightness of laptop (.NET)?
use Win API SetMonitorBrightness, but I don't know of anybody who has done it in C#.
Related
i need to block any screen capture software on the computer from taking screen shots. Since all of them are work on standard API-functions, i think i could monitor and block them.
I need to use C#.
All i have found is how to monitor and block them in a certain program (screen capture program). They are looking for a function in the program, then they change it address on mine function address.
But how can i do it, if i haven't any certain programs? I need to block anyone which tries to take a screenshot.
If your final goal is possible or not I don't know, but for the hooking the API portion I can help you out.
I have used the library EasyHook many times in the past, this will let you hook and intercept system function calls from C# code fairly easily. Just read through the PDF tutorial for setup instructions.
For actually finding the API's I recommend Rohitab's API Monitor, it's still in Alpha stages but it works really well and is free. You just hook it on to a processes and it tells you every external DLL call it makes (with the parameters it passed if you have the xml definition file for the DLL, the program comes with almost all of the windows API dll's pre-defined).
The combination of EasyHook and API Monitor is a great 1-2 punch for mucking with other program's calls.
It is not possible to prevent screenshots from being taken. The battle is already lost because of the DWM (Desktop Window Manager). It's lower level than Win32 and device contexts.
If you want to protect the text in your program, there are a lot easier ways to extract it than doing screenshots and OCR. TextOut and/or Direct2D hooking and accessibility APIs.
If there's a lot of IP in your program. Then don't make it all available onscreen. Make sure it's tedious to crawl the GUI for text, and hard to automate it. And don't load whole texts in memory of the program.
Possible solutions:
1. To prevent copying of text. Draw the text as an image.
2. To prevent accessibility technologies, like screen readers - override WndProc in your control, handle and ignore the window message WM_GETOBJECT.
3. To make it harder if they try to use OCR. Draw graphics behind the text. Human readable, but much harder for a machine to interpret it.
Neither of these methods are invasive for the user.
** A very invasive suggestion **:
If you are really serious about preventing anyone from "stealing" your content.
Implement mouse and keyboard hooks. Filter out typical copy shortcuts. Prevent the mouse from leaving the boundaries of your application.
Allow your application to only run when the OS runs well-known processes and services.
If any process starts which you don't recognize, black out the application and notify the user about it, and request the user to close it. And ofc make sure someone is not just spoofing a well-known process.
Monitor the clipboard as you suggested yourself.
You can ofc soften some of these suggestions based on the context of your application.
As Scott just posted it likely can be prevented with API hooks to see that paint events only go to desktop bound handles and not others, and refuse to paint otherwise. However, you need to consider the following scenarios and see if they're relevant threat to your approach or not:
Your software may be running in a virtual machine like VMWare. Such software has capapbilities to capture screen that does so at "virtual hardware" level, and your API hooks will not be able to discern it - and this would be the easiest way approach if I wanted to bypass your protections.
As a post suggests here, nothing also prevents someone to take monitor cable and plug it into another computer's capture card, and take screenshot that way. Again, your hooks will be helpless here.
Bottom line, you can make it somewhat harder to do, but bypassing such protection may be pretty trivial thing to do.
My 2c.
I am writing a C# Windows Form application which communicates with a webcam.
However, I want to tune webcam properties inside a button click function. Examples of those properties are brightness, saturation and sharpness.
I have found IAMVideoProcAmp::Set which might aid me with this. However, I don't quite understand how to implement this.
Can anyone help me in the right direction?
What you'll need to do is wrap calls to certain APIs (whether it's Windows, DirectX, etc) which is easier said than done when it comes to C#.
Luckily this problem has been solved numerous times (as you can see by number of webcam questions here) - and you can find one good approach in the following article:
Versatile WebCam C# library
Check out "How to change contrast and saturation programmatically?"
I'm writing a small c# program, I don't want the final user to take screenshots while using my program, is it possible? Or even if he takes one, how can I know it?
Thanks in advance and sorry if this is a poor-content question due to my lack of experience in c# coding.
You can create a system-wide keyboard hook using the low-level keyboard filter and cancel any printscreen keyboard combination. But if someone has also installed a helper application (like Gadwin or something) it'll become a lot more difficult because you won't know beforehand what keyboard shortcut you should catch (most tools allow to specify your own hooks).
Here's an article on using hooks in C#
and here's a ready-made keyboard hook library for .net that uses global mouse and keyboard hooks (use Google to find more freeware and commercial libraries and tools).
On a side note: it's generally not preferred to change the system behavior. Screenshots are system behavior and serve a distinguished purpose for trouble shooting. If you prevent this, users will not be able to show you a screenshot of something wrong. But if you must do it, you can do it.
EDIT: on a deeper level, you can install an API hook. All screenshot applications use API calls to get the content of a (part of) the screen. But API hooks are hard to get right. A more trivial way is probably by writing a user-level driver. While you can prevent all this, it is really worth all the trouble?
You might want a keyboard hook. But it'll tell you if the user pressed the "print screen" key, not if someone programmatically take a screenshot using some GDI function.
I doubt it's possible to prevent all the ways of taking a screenshot.
General answer: No. It's not possible to detect this - especially from C#. There are dozens of ways to take screenshot and even applications written in C++/WinAPI can only detect some of them, but not all.
Also consider - what if user is running your app in virtual machine? He'll be able to take screenshots at host machine and you can do absolutely nothing to detect (not even prevent) this.
I was wondering how I could set a specific application (as in any running application, not just my own)'s volume level in c#.
I know I'd probably have to use P/invoke, this is fine. I'm just not sure on how the sound api's work and how I would go about getting/setting the volume of specific applications (like the volume mixer in vista/7 can).
I know it's possible to do programattically because nircmd has a feature that can do it.
Any help would be appriciated, thanks.
I think you should look here. Following the links you'll find interfaces and API functions to use to manipulate endpoints' volume. Together with the documentation, Microsoft provided some code samples in C++. As you said, it is possible to get the same functionalities to work in .NET using platform invoke.
I think (and hope) your request is, for all intents and purposes, impossible. Allowing an application to set its own volume is like allowing an application to override the user's notification icon settings. These settings are user settings, so you can't circumvent them.
Imagine for an instance that a user has the volume of his speakers set way up, but has dimmed the volumes of all individual applications. Your application comes along and goes 'whatevs, I'll just set myself to full volume'. You've just made a user go deaf, or at least cower in a corner of the room, scared to death.
I am having trouble finding a way to force any display resolution/timing I want in my C# program. I am running Windows 7 with a GeForce 210 graphics card. My current method to achieve these custom resolutions is to use the driver GUI to manually add the custom resolutions and then use Windows calls to change to those resolutions but I need a way to add new custom resolutions in real time. I have looked into the NVAPI but I was not able to find a way to do this. I also looked into the command line tool for the graphics driver but I was not able to get it to work. My last resort is to rewrite the values in registry but I would really like to avoid that. I am willing to use a different programming language or a third party tool as long as I can invoke it from the command line via my program. Can anyone point me in the right direction?
Thanks in advance.
Update (8/16/2011):
I have been working on this problem with NVIDIA and they are providing me with an advanced NVAPI that will allow me to recreate the functionality of their driver. They also confirmed that the basic version of NVAPI that they provide will not do this.
You could try using ChangeDisplaySettings
I'm not sure if it will have all the options provided by the nvidia panel, but certainly the basics like resolution, refresh rate, screen orientation, etc. I've used it myself in the past to dynamically change screen orientation (rotate to landscape/portrait) on a click of a button.
I was able to solve this problem by using the NDA version of the NVAPI. It still was not trivial but all of the tools are there.