【问题标题】:GetModuleHandle on Windows Phone 8.0Windows Phone 8.0 上的 GetModuleHandle
【发布时间】:2013-08-29 17:55:43
【问题描述】:

我正在尝试在 Windows Phone 8.0 本机 C++ 库上加载 winsock dll。

 HMODULE ws2mod = GetModuleHandle("ws2_32.dll");
    win_getaddrinfo = GetProcAddress(ws2mod, "getaddrinfo");
    if (win_getaddrinfo)
        return win_getaddrinfo(node, service, hints, res); 

我收到链接器错误:

Error   178 error LNK2019: unresolved external symbol GetModuleHandle referenced in

当我在 Visual Studio 上双击并执行 Goto Definition 时,我在 Windows Phone Kits 的 libloaderapi.h 文件中看到了定义。

我应该链接的库是什么?以下是当前的库:

WindowsPhoneCore.lib
RuntimeObject.lib
PhoneAppModelHost.lib

【问题讨论】:

    标签: c++ windows-phone-8 static-linking


    【解决方案1】:

    GetModuleHandle 不在 WP8 的已批准 API 列表中。

    但是getaddrinfo 是。我认为你可以直接链接到ws2_32.lib 并直接调用getaddrinfo,而不是通过GetProcAddress

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多