Click to See Complete Forum and Search --> : CSMTPConnection, ws2_32.dll, and GetAddrInfoW


Bomb Twenny
August 22nd, 2005, 10:19 AM
I have compiled an ATL COM object in VS.net 2003, in which I use the ATL CSMTPConnection class to send emails, however when I try to register the COM object on a Windows 2000 machine the registration fails.
The DLL ws2_32.dll appears to be missing the function GetAddrInfoW, the unicode version of GetAddrInfo. The registration works fine on WindowsXP.

Can I get this to work on Windows 2000?

MikeAThon
August 22nd, 2005, 03:53 PM
I think GetAddrInfoW requires Windows 2k "Pro". Is that what you have?

If not, then maybe this discussion thread might help: http://groups-beta.google.com/group/microsoft.public.win32.programmer.international/browse_frm/thread/c84be1d58d4dc362/9c4fa2051a673208?tvc=1&q=GetAddrInfoW+WS2_32&hl=en#9c4fa2051a673208

Or, it might relate to a known bug in atlsocket.inl. See this discussion thread: http://groups.google.com/group/microsoft.public.vc.atl/browse_frm/thread/852a68809d1d922b/879ef573ae1d76e3#879ef573ae1d76e3

Incidentally, the exact opposite symptoms that you described (i.e., it doesn't work on XP) are described in this KB article, which also mentions your CSMTPConnection class: "BUG: Cannot Locate the Procedure Entry Point FreeAddrInfoW When You Run an Application on Windows XP" at http://support.microsoft.com/default.aspx?scid=kb;en-us;822334

Maybe it's related?

Mike

Bomb Twenny
August 23rd, 2005, 05:33 AM
Thanks fo the links Mike. I think I've got it sorted now.

The CSMTPConnection class uses the CSocketAddr class which uses the function GetAddrInfo, which is not supported on Windows2000 (only XP/2003).

The version of platform SDK I was using incorrectly provides linkage to this function even when the target OS is 2000. When I installed the Platform SDK for 2003 the project fails to build for 2000.

I then had to include the following lines before the atl headers:
#include <winsock2.h>
#include <ws2tcpip.h>
#include <wspiapi.h>

#define GetAddrInfo WspiapiGetAddrInfo
#define FreeAddrInfo WspiapiFreeAddrInfo

This allows the use of getaddrinfo emulation function that apparently works on 2000, although I haven't tested this yet.