Archive for Win32 API

Latest ScrnSave.Lib depends on ChangeWindowMessageFilter

I was trying to port a screensaver from Visual Studio 2005 to Visual Studio 2008.

After loading the project in VS2008, compilation went without any problems. However, when I tried to test the screensaver on a Windows XP box I got the error message that the function ChangeWindowMessageFilter could not be found in user32.dll. The first thing I did was to open the MSDN and search for this ChangeWindowMessageFilter function. According to the documentation ChangeWindowMessageFilter is only available on Windows Vista. I obviously didn’t use that function myself otherwise I would have known about it in the first place ;) So I checked the libraries that I was linking to. The most obvious candidate would be the ScrnSave.lib library. I searched for it and it was linking to the version that was installed by Visual Studio 2008 in C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib. To make sure I did a “dumpbin /symbols ScrnSave.Lib” on it and it was indeed using the ChangeWindowMessageFilter function.

It is pretty strange that this ScrnSave.Lib is dependent on a Vista API call. This just annoys developers that try to create a screensaver that still works on Windows XP. It should be pretty easy for the developers of ScrnSave.Lib to dynamically load the user32.dll and see if ChangeWindowMessageFilter is available.

Anyway, the easiest and quickest workaround that I’m using right now is to use the ScrnSave.Lib from the Visual Studio 2005 installation. After recompiling my screensaver with this older library it works again on Windows XP.

How to Save and Load a Windows Region with the Win32 API

In my previous post I explained how to save a Windows region to a file and how to load it again using MFC. Some people have problems translating MFC code to standard Win32 API code, so I wrote a followup article for CodeGuru explaining exactly the same thing but with Win32 API code instead of MFC.

The article explains in details how to save a Windows region to a file using GetRegionData and how to load and re-create this saved region with ExtCreateRegion using MFC.

There are 2 functions in the article: SaveRegion and LoadRegion. Read the rest of this entry »