views:

695

answers:

3

I'm attempting to compile a screensaver using Visual C++ 2008 Express Edition SP1 on Windows XP. I get a runtime error: "The procedure entry point ChangeWindowMessageFilter() could not be located in the dynamic link library USER32.dll." As far as I can tell, this is because Microsoft botched the scrnsave.lib library included in VS 2008 to call a Vista-specific function, which fails on XP because the function does not exist.

Defining WINVER doesn't seem to do anything.

How can I work around this?

A: 

You could try getting an older version of the Platform SDK, and link to its version of scrnsave.lib.

http://www.microsoft.com/downloads/details.aspx?FamilyId=A55B6B43-E24F-4EA3-A93E-40C0EC4F68E5&displaylang=en is the download link for the Windows Server 2003 SP1 Platform SDK.

Michael
I was hoping to avoid downloading and installing an entire old SDK just for one file, but unless someone can come up with a better option I may have to do this.
+1  A: 

Looking at this in MSDN for 'ChangeWindowMessageFilter' indicates that its a Vista Specific and is part of the User32.lib which is what you're linking with, as Windows XP does not have that function in the User32.dll....hence the blowup...recommended to follow Michael's suggestion to download an older version of the SDK...there is no other way to do it...I wonder can you install a different SDK side by side, one for Vista platforms and the other for Win XP platform?

Edit: I found an interesting link here about this here on a blog... It talks about the exact identical problem, grab an old copy of scrnsave.lib from an older installation (VS 2005 if you have access to one or ask a friend/colleague?) Speaking of the above function that is vista specific - here's an interesting opinion on it why it should not be touched...

Hope this helps, Best regards, Tom.

tommieb75
Feel free to ask around here for someone who may have a copy...
tommieb75
+1  A: 

Write a stub function (many details left out of the code)

BOOL WINAPI ChangeWindowMessageFilter(      
   UINT message,
   DWORD dwFlag)
{
   if (running_on_vista_or_later)
   {
      ....
      pfn = GetProcAddress(... "ChangeWindowMessageFilter");
      return pfn (message, dwFlag);
   }

   return TRUE;
}

If the obj or lib that this function is in is before user32.lib in your link line, then the linker should pick your stub function rather than the one from user32.lib.

Your stub function can detect at runtime that you are on Vista or later and call the real function, otherwise just lie and return TRUE.

John Knoeller