首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

LNK2001异常,小弟我太急了,哪位高手能帮帮小弟我啊多谢了

2012-02-08 
LNK2001错误,我太急了,谁能帮帮我啊!!!谢谢了!//InternetForbid.cpp:定义DLL应用程序的入口点。//#include

LNK2001错误,我太急了,谁能帮帮我啊!!!谢谢了!
//   InternetForbid.cpp   :   定义   DLL   应用程序的入口点。
//

#include   "stdafx.h "
#include   "iphlpapi.h "

#ifdef   _MANAGED
#pragma   managed(push,   off)
#endif

BOOL   APIENTRY   DllMain(   HMODULE   hModule,
                                              DWORD     ul_reason_for_call,
                                              LPVOID   lpReserved
  )
{
        return   TRUE;
}

/////////////////////////////////////////
//   导出函数:   禁止或允许上网。
//   版权所有   盛光科技   //
/////////////////////////////////////////

bool   WINAPI   InternetForbid(bool   forbid)
{
        PMIB_IFROW   p1,p2;
  GetIfEntry(p2);
        p1   =   new   _MIB_IFROW;   //   申请内存
        p1-> dwIndex   =   p2-> dwIndex;
  p1-> dwAdminStatus   =   MIB_IF_ADMIN_STATUS_DOWN;
  return   SetIfEntry(p1)   ==   0;
}
#ifdef   _MANAGED
#pragma   managed(pop)
#endif

这里我使用   IP   Helper   API   (iphlpapi.h)中的函数和结构。编译成dll,def文件里公开InternetForbid函数。
但是却发生如下错误:

错误2error   LNK2019:   无法解析的外部符号   _SetIfEntry@4,该符号在函数   "bool   __stdcall   InternetForbid(bool) "   (?InternetForbid@@YG_N_N@Z)   中被引用InternetForbid.obj
错误3error   LNK2019:   无法解析的外部符号   _GetIfEntry@4,该符号在函数   "bool   __stdcall   InternetForbid(bool) "   (?InternetForbid@@YG_N_N@Z)   中被引用InternetForbid.obj
错误4fatal   error   LNK1120:   2   个无法解析的外部命令I:\C++实用\InternetForbid\Debug\InternetForbid.dll1
这是为什么呢?

[解决办法]
you should link the library :Iphlpapi.lib.

1.you can add it to project setting/ link / object.library modules
2.you can add it into your code like this:
#pragma comment(lib, "Iphlpapi.lib. ")

热点排行