在WinXP运行得好好的程序,到了Win2K下出现"无法定位程序输入点getaddrinfo于动态链接库WS2_32.dll上"的错误请教大家是什么原因造成的呢?

解决方案 »

  1.   

    添加  #pragma comment( lib, "WS2_32.dll" )
      

  2.   

    说错了!
    应该是把xp里 C:\WINDOWS\system32\ws2_32.dll考到2k里相应的系统文件夹吧!
      

  3.   

    应该说直接拷贝DLL是解决不了问题的。
      

  4.   

    据我遇到的情况,是因为用到了getaddrinfo的的Unicode版本造成的(不管是直接还是间接),这个函数(GetAddrInfoW),是Windows XP SP2才加上去的,低于XP SP2的版本是无法用这个函数的,拷贝DLL也是不行的。需要改代码,然后再重新编译。
      

  5.   

    http://support.microsoft.com/kb/822334/en-us
      

  6.   

    是不是用到了GetAddrInfo,FreeAddrInfo,CSocketAddr这些XP才支持的东东,需要你检查代码了。
      

  7.   

    谢谢各位的回复, 我并没有显式地调用GetAddrInfo函数, 但是, 我的程序有使用web service, 估计是web service的库函数中使用了这些函数,
      

  8.   

    我的程序有使用web service, 估计是web service的库函数中使用了这些函数~
    那这个问题就比较难解决了~~~
      

  9.   

    问题有了新的进展, 我在MSDN中看到如下信息, 网址为http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winsock/winsock/getaddrinfo_2.asp内容:
    Support for getaddrinfo on older versions of Windows The getaddrinfo function was added to the Ws2_32.dll on Windows XP and later. If you want to execute an application using this function on earlier versions of Windows (Windows 2000, Windows NT, and Windows Me/98/95), then you need to include the Ws2tcpip.h file and also include the Wspiapi.h file. When the Wspiapi.h include file is added, the getaddrinfo function is defined to the WspiapiGetAddrInfo inline function in the Wspiapi.h file. At runtime, the WspiapiGetAddrInfo function is implemented in such a way that if the Ws2_32.dll or the Wship6.dll (the file containing getaddrinfo in the IPv6 Technology Preview for Windows 2000) does not include getaddrinfo, then a version of getaddrinfo is implemented inline based on code in the Wspiapi.h header file. This inline code will be used on older Windows platforms that do not natively support the getaddrinfo function.The IPv6 protocol is supported on Windows 2000 when the IPv6 Technology Preview for Windows 2000 is installed. Otherwise getaddrinfo support on versions of Windows earlier than Windows XP is limited to handling IPv4 name resolution.The GetAddrInfoW function is the Unicode version of getaddrinfo. The GetAddrInfoW function was added to the Ws2_32.dll in Windows XP SP2. The GetAddrInfoW function cannot be used on versions of Windows earlier than Windows XP SP2. 按文中所示, 我在StdAfx.h中加入了以下两行信息:
    #include <Ws2tcpip.h>
    #include <Wspiapi.h>但是编译时, 出现如下错误, 谁能告诉我是为什么呢, 是不是还缺什么步骤呢D:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\atlmfc\include\atlspriv.inl(121) : error C2039: “WspiapiGetAddrInfo” : 不是“ATL::CSocketAddr”的成员
      

  10.   

    需要
    #include <atlsocket.h>
    并参考下面的信息解决方案
    要解决此问题, 请按照下列步骤:1. 将 Atlsocket.h 文件复制到与要使用任何目录。 此文件位于以下目录中: 
    程序 Files\Microsoft Visual Studio 2003\Vc7\atlmfc\include 
    2. 下面的代码块向 Atlsocket.h 文件步骤 1 中创建的副本。//Atlsocket.h
    #pragma comment(lib, "ws2_32.lib")
    #pragma comment(lib, "mswsock.lib")
    //Start of Addition
    #if _WIN32_WINNT < 0x0502
      #define ADDRINFOT addrinfo
      #define GetAddrInfo getaddrinfo
      #define FreeAddrInfo freeaddrinfo
    #endif
    //End of Addition namespace ATL
     
    3. 启动 Microsoft Visual C++。 
    4. 在 工具 菜单上, 单击 选项 。 在左窗格中的 选项 对话框中, 展开 项目 , 依次 VC++ 目录 。注意 如果使用 Visual C++ Express Edition, ProjectsandSolutions@@@ 展开左窗格的 选项 对话框中, 中, 然后单击 VC++ 目录 。 
    5. 显示有关目录 , 下单击 包含文件 。 然后, 添加目录位置 Atlsocket.h 文件的修改版本是定位到列表顶部。 
    6. 重建您应用程序