|
Just look the error up in the SDK include file "winerror.h". Here it is:
//
// MessageId: ERROR_INVALID_PARAMETER
//
// MessageText:
//
// The parameter is incorrect.
//
#define ERROR_INVALID_PARAMETER 87L // dderror
Also debug through the code to see where the code is failing.
|
|
|
|
|
i want to retrieve the IP address of the machine using VC++
calls
|
|
|
|
|
Not that it is related to my ping class, but just use gethostname followed by gethostbyname
|
|
|
|
|
When the packet size set to 1024 bytes the defined maximum size, there are an error occurred with lack of recv buffer.
I think the meaning of packet size makes confused. The packet size should be included the ICMP header, so the code of buffer allocation might be as follows,
CPing:Ping2(....)
{
....
//Allocate the ICMP packet
char* pICMP = new char[nPacketSize];
FillIcmpData((LPICMP_HEADER) pICMP, nPacketSize);
......
//allocate the recv buffer
int nRecvBuf = nPacketSize + sizeof(IP_HEADER);
char* pRecvBuf = new char[nRecvBuf];
......
nRead = recvfrom(sockRaw, pRecvBuf, nRecvBuf, 0, (sockaddr*)&from,
&nFromlen);
.....
}
=======================================================================
When the packet size set to 8 the defined minimum size, there is also an error occurred. Because the sizeof(ICMP_HEADER) is 12 not 8.(because of the non standard field ULONG timestamp;) So the FillIcmpData() will overwrite the buffer.
|
|
|
|
|
The 'IP VERSION' and 'IP HEADER LENGTH' should be 4 bits not 4 bytes.
typedef struct tagIP_HEADER
{
unsigned char h_len:4; // length of the header
unsigned char version:4; // Version of IP
....
}
|
|
|
|
|
They are. Make sure you have the latest version from my web site at www.naughter.com
|
|
|
|
|
Hi,there
How to change the time interval?
I find a sentence : sleep(1000); Is this one?
I hope to change to 10 minutes as the time interval.
And when I build the ping.exe,one error occured:
_beginthreadex undeclaired identifier
How to correct it?
Thanks a lot!
XYZ
|
|
|
|
|
Looked at the code and there is no sleep calls in it. Make sure you have the latest version from my web site. As for the _beginthreadex, you need to add MFC to your app.
|
|
|
|
|
Friend,
How to get ws2_32.lib for win9x. With out this my project is also not working under win9x. So please give some link from where i can find ws2_32.lib
|
|
|
|
|
The LIB file is part of your development environment and not the OS. Install the latest Platform SDK to get this
|
|
|
|
|
I'm pretty sure that most lib files from the Platform SDK are not legally distributable, so the only legit way of getting this file is to install the Platform SDK. Being a professional developer, downloading a file like this from this type of web site is just asking for trouble.
|
|
|
|
|
// Seems to work on all Windows platforms:
bool CSETINetDlg::Ping(LPCTSTR szServer)
{
char szCommandLine[1024];
sprintf(szCommandLine, "ping.exe -n 1 %s", strServer);
STARTUPINFO StartupInfo;
ZeroMemory(&StartupInfo, sizeof(STARTUPINFO));
StartupInfo.cb = sizeof(STARTUPINFO);
StartupInfo.dwFlags = STARTF_USESHOWWINDOW;
StartupInfo.wShowWindow = SW_HIDE;
PROCESS_INFORMATION ProcessInfo;
DWORD dwExitCode;
if (CreateProcess(NULL, szCommandLine, 0, 0, FALSE, CREATE_NO_WINDOW, 0, 0, &StartupInfo, &ProcessInfo))
{
WaitForSingleObject(ProcessInfo.hProcess, 1000);
GetExitCodeProcess(ProcessInfo.hProcess, &dwExitCode);
return dwExitCode == 0;
}
return false;
}
Joep Oude Veldhuis
|
|
|
|
|
What can I say? Maybe it's easier for you to open a dos box and type the ping command. The whole idea is to show how to write a ping program, not how to call a ping program that someone else wrote.
|
|
|
|
|
yeah..
but i always struggled with the problem that i didn't get this (and all other ping - classes) running on win2000 (if not beeing administrator).
yeah.. and with one easy functin everything worked fine..
"I'm from the South Bronx, and I don't care what you say: those cows look dangerous." U.S. Secretary of State Colin Powell at George Bush's ranch in Texas
|
|
|
|
|
Hello.
This class can report wrong time when using Windows Sockets2 (Ping2) .
When sending ping's repeatdly, it doesn't recoginzes difference between
packets sent previously and next packet, because all ICMP packets have
same ID.
Cheers,
Magomed G. Abdurakhmanov
|
|
|
|
|
The latest version on my web site (www.naughter.com) has a fix for this
|
|
|
|
|
Hi all,
CPing works fine as long as I'm administrator. However, Ping2 fails when loged in as non-admin!!! GetLastError returns "Control ID not found".
Does somebody know how to get around that or can explain me this error?
Thanks a lot,
Stefan
|
|
|
|
|
Sorry the "Control ID not found" error is a remnant of a previous prog. Instead, the WSASocket(AF_INET, SOCK_RAW, IPPROTO_ICMP, NULL, 0, 0) call returns INVALID_SOCKET. WSAGetLastError returns WSAEACCES ("An attempt was made to access a socket in a way forbidden by its access permissions").
Nevertheless, where can I grant the missing permissions for non-admins???
Thanks,
Stefan
|
|
|
|
|
Solution see Kb article Q195445 (http://support.microsoft.com/support/kb/articles/q195/4/45.asp)
However, this is actually only for NT, but not W2K
|
|
|
|
|
Article is now updated for W2000
|
|
|
|
|
I know this is an old thread but wanted to reply anyway. I hope this helps someone...
You can also use the RunAs service under W2K. By default the service is running. There's several ways to use it. The 1st is to shift+right.click an executable in explorer and you will see an extra menu item called "runas...". This should be self-explanatory. Also you can right click on a shortcut or desktop icon and click properties and enable the "runas” box. I also recall a CreateProcessAsUser API function and also there is a batch command called "runas".
Ed
|
|
|
|
|
and does not respect the timeout...
|
|
|
|
|
If you are really really worried about this then do a timed out DNS lookup outside of the ping class and only send in an IP address to this class.
|
|
|
|
|
When I run the program compiled with CPING_USE_ICMP I get
"Failed in call to ping, GetLastError returns: 11010"
I need to do this cause I need to run it on win95. Am I doing something wrong?
Thanks
|
|
|
|
|
The error is:
#define WSA_QOS_ADMISSION_FAILURE (WSABASEERR + 1010)
/* error due to lack of resources */
You will have to look up on the MSDN why this is occurring. Perhaps you need to install the Winsock2 update for Win95.
|
|
|
|