How to use IcmpCreateFile();
-
I got this error while building the project. I have included all header files but still this error remains???:confused:
1>Ping.obj : error LNK2019: unresolved external symbol _IcmpCreateFile@0 referenced in function "public: int __thiscall CPing::PingThis(class ATL::CStringT<wchar_t,class StrTraitMFC<wchar_t,class ATL::ChTraitsCRT<wchar_t> > >)" (?PingThis@CPing@@QAEHV?$CStringT@_WV?$StrTraitMFC@_WV?$ChTraitsCRT@_W@ATL@@@@@ATL@@@Z) 1>F:\Manmohan\Visual C++\IPM\Debug\IPM.exe : fatal error LNK1120: 1 unresolved externals
// Ping.cpp
// This is a custom c++ class added to the project
#include "StdAfx.h"#include <IPHlpApi.h>
#include <IcmpAPI.h>
#include "Ping.h"CPing::CPing(void)
{
}CPing::~CPing(void)
{
}// Ping function
int CPing::PingThis(CString m_sAddress)
{
HANDLE hIcmpFile = IcmpCreateFile();
if (hIcmpFile == INVALID_HANDLE_VALUE)
{
return -1;
}return 0;
}
Future Lies in Present. Manmohan Bishnoi
-
I got this error while building the project. I have included all header files but still this error remains???:confused:
1>Ping.obj : error LNK2019: unresolved external symbol _IcmpCreateFile@0 referenced in function "public: int __thiscall CPing::PingThis(class ATL::CStringT<wchar_t,class StrTraitMFC<wchar_t,class ATL::ChTraitsCRT<wchar_t> > >)" (?PingThis@CPing@@QAEHV?$CStringT@_WV?$StrTraitMFC@_WV?$ChTraitsCRT@_W@ATL@@@@@ATL@@@Z) 1>F:\Manmohan\Visual C++\IPM\Debug\IPM.exe : fatal error LNK1120: 1 unresolved externals
// Ping.cpp
// This is a custom c++ class added to the project
#include "StdAfx.h"#include <IPHlpApi.h>
#include <IcmpAPI.h>
#include "Ping.h"CPing::CPing(void)
{
}CPing::~CPing(void)
{
}// Ping function
int CPing::PingThis(CString m_sAddress)
{
HANDLE hIcmpFile = IcmpCreateFile();
if (hIcmpFile == INVALID_HANDLE_VALUE)
{
return -1;
}return 0;
}
Future Lies in Present. Manmohan Bishnoi
Manmohan29 wrote:
1>Ping.obj : error LNK2019: unresolved external symbol _IcmpCreateFile@0
Does MSDN not work in your area? LNK2019 This is not the sort of question I'd expect from someone that is creating a multithreaded server application that uses sockets. :confused:
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
-
I got this error while building the project. I have included all header files but still this error remains???:confused:
1>Ping.obj : error LNK2019: unresolved external symbol _IcmpCreateFile@0 referenced in function "public: int __thiscall CPing::PingThis(class ATL::CStringT<wchar_t,class StrTraitMFC<wchar_t,class ATL::ChTraitsCRT<wchar_t> > >)" (?PingThis@CPing@@QAEHV?$CStringT@_WV?$StrTraitMFC@_WV?$ChTraitsCRT@_W@ATL@@@@@ATL@@@Z) 1>F:\Manmohan\Visual C++\IPM\Debug\IPM.exe : fatal error LNK1120: 1 unresolved externals
// Ping.cpp
// This is a custom c++ class added to the project
#include "StdAfx.h"#include <IPHlpApi.h>
#include <IcmpAPI.h>
#include "Ping.h"CPing::CPing(void)
{
}CPing::~CPing(void)
{
}// Ping function
int CPing::PingThis(CString m_sAddress)
{
HANDLE hIcmpFile = IcmpCreateFile();
if (hIcmpFile == INVALID_HANDLE_VALUE)
{
return -1;
}return 0;
}
Future Lies in Present. Manmohan Bishnoi
Manmohan29 wrote:
I have included all header files but still this error remains
Thats because some header files [^] may not contain any source code. If you would have read the documentation for the IcmpCreateFile Function[^] you might have noticed it mentioning a Iphlpapi.lib file. One way of fixing this linker error is adding:
#pragma comment(lib,"Iphlpapi.lib")
You could also add the library to the Additional Dependencies section of your project. Best Wishes, -David Delaune -
Manmohan29 wrote:
I have included all header files but still this error remains
Thats because some header files [^] may not contain any source code. If you would have read the documentation for the IcmpCreateFile Function[^] you might have noticed it mentioning a Iphlpapi.lib file. One way of fixing this linker error is adding:
#pragma comment(lib,"Iphlpapi.lib")
You could also add the library to the Additional Dependencies section of your project. Best Wishes, -David Delaunethanks.
Future Lies in Present. Manmohan Bishnoi
-
Manmohan29 wrote:
1>Ping.obj : error LNK2019: unresolved external symbol _IcmpCreateFile@0
Does MSDN not work in your area? LNK2019 This is not the sort of question I'd expect from someone that is creating a multithreaded server application that uses sockets. :confused:
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
I have been given a project from my HOD(Head of Dept.) for a software which will list all the computers which are switched ON during class' time, because guys leave their systems running for downloading. This software will ping all the IP's of students and anyone's IP found working during class's time will be blocked for 2 days as a punishment. This software will also be having a module for serving files(articles, minor projects,...) of Electronics Dept. to the students. This I will complete with IOCP server. I wanted to do it multithreaded way also.(just for trying)
Future Lies in Present. Manmohan Bishnoi
-
I have been given a project from my HOD(Head of Dept.) for a software which will list all the computers which are switched ON during class' time, because guys leave their systems running for downloading. This software will ping all the IP's of students and anyone's IP found working during class's time will be blocked for 2 days as a punishment. This software will also be having a module for serving files(articles, minor projects,...) of Electronics Dept. to the students. This I will complete with IOCP server. I wanted to do it multithreaded way also.(just for trying)
Future Lies in Present. Manmohan Bishnoi
Manmohan29 wrote:
...all the computers which are switched ON during class' time...
Are they connecting to a WAP that you have control over? If so, can you disable the WAP during class hours?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons