I've been looking into dimming a screen on a Windows platform from my program. I know that there's a SetMonitorBrightness API that allows this, but the issue for me is that it would be nice to be able to dim the screen on Windows XP as well (which that API does not support) and also dim screens on desktop computers.
So I did some research and found this utility that seems to dim my screen on a Windows XP desktop without a problem. I tried to contact the author to find out how they implemented the dimmer but I did not hear back from them.
So I was curious to hear from developers on this site, how do you think they managed to dim the screen when the SetMonitorBrightness API is not supported?
PS. I am a newbie developer myself trying to write an energy saving program for our small business. It is a nonprofit organization and we don't have funds to hire a Windows developer to do this for us. Most of our computers are Windows XP desktops, so as you can see I can't use SetMonitorBrightness API as it is widely documented on the web.
Thanks in advance.
In the case that you cite, have a look at the screensaver with Dependancy Walker. My guess is that they create a full screen window and use SetLayeredWindowAttributes() to set a semi-opaque setting for the window, thus making the screen appear dimmed. I doubt it would save you much money.
You might want to look into the DDC protocol which allows you to control aspects of some monitors. The MS API that allows you to do this can be found roundabout here: http://msdn.microsoft.com/en-us/library/windows/hardware/ff570290%28v=vs.85%29.aspx and you should look at the I2C functions too.
Alternatively you could look for a ready made library to do the DDC stuff for you, such as http://www.nicomsoft.com/products/i2c/. They too have a dimmer application that is free for personal use and non-free for commercial use. They may even allow you to use it for free if you contact them and explain it's for a non-profit organisation.
If you are trying to do this as an energy saving program why not use a screensaver setting that turns the monitor off after a certain period of idleness? In any case
Forgive me if this information is outdated, but I have done this in the past using SetDeviceGammaRamp. The 'Get' version is available too for state saving and restore. I have seen it used in C# programs through, so it might still be relevant albeit not too common anymore.
Related
I am developing a virtual desktop application and have been an avid dexpot user for some time. I've been reading the Win32 documentation, specifically the CreateDesktop and SwitchDesktop functions. From what I understand, only one desktop can be viewed at a time, yet dexpot manages to show a real time view of all active desktops in its full screen preview mode. Does anyone know a way of possibly implementing this? My first idea is to rapidly switch desktops, but this would use up far too much processing power.
The most difficult part about what you want to do is application switching. You cannot move an application instance from one Desktop object to another. I would base my implementation off of remote desktop applications. There's plenty of open source clients you can look into for some ideas. I would look into the desktop duplication api as well. One idea that comes to mind is making one large desktop, locking the mouse and view to one particular region, and using desktop duplication to show all the split up regions as separate desktops. That's assuming desktop duplication works as I think it does. I'm not sure as I don't use windows.
Very simple question. In the MSDN documentation for the DirectSound API they state that when my application is in focus it will be the only audible program. This is exactly what I want to happen, however when setting this flag and playing sound through my application, I can still hear the background music on my computer.
So the question is, why? Is it because the application playing the background music using a different low level API, and thus different mixing buffers? Or is there some other little trick i need to tweak in order to become the only audible application.
I asked a similar/related question here, with no response. But once again if you don't know the answer to the specific DirectSound question, but you know a way of becoming the only audible application with a different API let me know!
Thanks, I'm on Windows XP 32Bit Professional, if it makes a difference.
A long time ago, the Windows developers realized that allowing one application to have total control of the audio system (whereby muting other apps) was a bad idea. And then they subsequently deprecated many of these "exclusive" and foreground/background mode flags. I believe this behavior change goes all the way back to DirectX 7.1 (WinME) and then formally everywhere on DX 8. This was 10 years ago.
Imagine your video conferencing app becoming muted when you switched the foreground application to an app that ran audio in some sort of exclusive mode. Not being able to reliably hear anyone when switching between apps is not a great experience.
As a matter of fact, prior to DX 8, many popular voice-comm apps for multi-player gaming would continually sniff for the foreground window handle and use that for the call to SetCooperativeLevel such that they wouldn't get muted.
I think it would be interesting to know, "what is that you really want to do?" that makes you assume you need total control of the audio output.
On Vista and higher, there is the WASAPI api for low-level audio. I believe there is a concept of "exclusive" mode but I don't know if trumps other apps using the sound card. YMMV.
How to disable ctrl+alt+del using C in Window OS? I tried
SystemParametersInfo(SPI_SETSCREENSAVERRUNNING, true, &bOldState, 0);
but it doesn't working for me. Can you kindly guide me, so that I can make it possible.
The SPI_SETSCREENSAVERRUNNING parameter you are using is designed for screensavers on Windows 95. It works on Windows 95/98/ME and earlier. It does not work on Windows NT/2000/XP/Vista.
The Ctrl-Alt-Del Hotkey combo can be disabled on Windows NT/2000/XP/Vista, but not usually from an application (user mode). Here are the mechanisms I'm familiar with.
I haven't tried it on Windows 7, but I'm sure some or all of these techniques still work there.
A GINA DLL can intercept the CAD sequence, but that may be overkill. It works because Windows registers the CAD Hotkey and sends a callback to GINA DLL to handle the action when you press it. A replacement GINA DLL can handle the callback differently (ignoring it), but it may be tricky to do this and remain compatible with other login mechanisms using other custom GINA DLLs.
You can write a keyboard driver to intercept it. There is pretty good free source code on the net for it if you search for it. Look for the Ctrl2Cap driver and similar things. (This driver remaps the Caps Lock key and Ctrl keys to mimic old keyboard layouts.)
You may also be able to "remap" keys in the registry to achieve your goal using the Scan Code Mapper. They added this in Windows 2000. It's limited, but workable in some situations. See this MSDN page for details. Pay attention to the limitations, though. For example, it requires a reboot for the change to take effect.
Finally, you can disable the Task Manager and other features through an administrative setting using the Windows Admin Toolkit. It still interrupts everything to show you a "You can't do that" dialog. But at least it works to limit users' access to the machine.
I wrote a device driver (option 2 on my list above) to block Ctrl-Alt-Del for Windows 95/98 (13 years ago), and later for Windows NT/2000/XP. I sold a lot of those. They're still around if you look.
Are you attempting to disable the requirement of ctrlaltdelete for login, or are you trying to disable the hotkey entirely? I don't believe the latter is even possible; it's a built-in OS-level override designed to circumvent any user-level program.
With Windows XP you can write a GINA DLL to do this. Windows 7 doesn't seem to have a GINA DLL anymore though. There may be some sort of policy setting to accomplish the same, but if so I haven't seen it documented.
Ctrl-Alt-Del is the Secure Attention Sequence. The goal is to let the user communicate securely with the OS. It can't be disabled by programs, by design - it would no longer be secure in that case.
I have an application written in QT4, that uses an openGL window. It has been running happily for months. Windows XP, service Pack 3,
Recently I was diddling with my screensaver, and happened to select the 3D text choice. When I previewed it, the QT4 application seg-faulted immediately. When I ran in the debugger,it is crashing in ig4dev32.dll, which is an intel graphics accelerator driver for Open GL.
When I do a similar test on a machine with an NVIDIA card, I (not surprisingly) get no problems.
I'm not really sure whether I'm asking for help, or insight, or whatever--has anybody ever seen it? Google tells me others have seen it happen in gaming applications, but I see no references to developers having it happen to them. Obviously, I can not use that screensaver, but I suspect the problem is "bigger" than that. Ideas?
I would start by reporting this to Intel. No doubt, they will not resolve it by the end of the week, but eventually. In the mean time, I'd also report it to Qt software, so see if they can trouble shoot it as well.
In the mean time, you know the issue and how to resolve it (no OpenGL screensavers). So all you have to do is to inform your customers. The best would be if the application itself could inform the customers, but detecting if a screensaver uses OpenGL or not does not seem feasable.
Perhaps you could do some additional tests. For instance, what happens if your application is run in paralell with, say, Google Earth in OpenGL mode?
In Windows XP the Win32 API renders the controls using GDI/GDI+.
Now I'm on 7, so if I use the API's functions, will the rendering automatically be handled by the DWM/WDDM (so by DirectX)? or will it continue to render with GDI?
Or likewise, will an old app written with WinAPI, be rendered with GDI also in Windows 7?
Thank you in advance for the help :)
In my experience, if the Aero display is on everything will render via that system, it just won't be obvious to your application. You'll still render in GDI, but it will be to a back buffer and not directly to the screen buffer (in fact it's more complicated then that). That way your older app can get the benefits of the new features, like the live preview effects, without having to be aware of them.
Really though, your application doesn't really notice a difference. The API is still the same API as before and works as you expect it. There are ways to take advantage of this, but you have to opt in to really use it.
If your application is written to use GDI, then it will continue to use GDI. The underlying implementation has changed quite a bit (as I recall, most hardware acceleration was removed in Vista, and put back in, in a new form, in Win7)
But it won't magically be transferred to Direct2D, no.
On performance front, it is the same old farce and as per usual 'Do Your Own Benchmarking' across OS-es. But, almost a decade old OS for anything GDI still slams Windows7 and plenty of apps will be incredibly more responsive on XP.. Sadness.. especially when you consider that translation of such an old API (as a compatible interface) should be trivial to any new driver or display tech.
Apparently some ops like blitting are supported but look at the result of your target 2D GDI app and judge for yourself..
Here are some observations, but please do your own for a dozen scenarios and compare, especially if it is GDI intensive like a million audio/video apps out there (no wonder iFruit boys are gaining share).
http://www.passmark.com/forum/showthread.php?t=2233
And while you will find all the typical and fluffy MSDN blog explanations that get 'technical' (ie. surface-style nonsense) the reason is very simple: buy a new OS, pull the carpet on old API and complicate it further by allowing new APIs to work with it (but not benefit the old one, easily doable by providing a new dll and .lib ).
For one history lesson and how hard it was to translate GDI calls to Direct2D or use libgdiplus from Mono and derive ideas etc, here is the propaganda:
http://blogs.msdn.com/directx/archive/2009/05/12/2d-drawing-apis-in-windows.aspx