|
i want to know license of this project.
thanks.
|
|
|
|
|
Hi All, when I try to ping a paused VM, each pings the host sometimes (for each 3 tries, about 1 reachs the host).
I think VMWare keep the VM up regardless of it's either paused or not.
But is there some way to I work around that?
I mean, is there some different return of some function that I can look to figure out that?
Because using Windows Console Ping application it returns always "Destination host unreachable".
Thank you in advance.
|
|
|
|
|
In WinPingDlg.cpp::OnInitDialog. Changed this line:
#define PING_BITMAP_SIZE 16
m_img.Create(IDB_LOG, PING_BITMAP_SIZE, 1, RGB(255, 0, 255));
And then changed WinPingDlg.cpp::OnStatus:
LRESULT CWinPingDlg::OnStatus(WPARAM wParam, LPARAM lParam)
{
char* pMsg = (char*) lParam;
int nCnt = m_list.GetItemCount();
int i = m_list.InsertItem(nCnt,pMsg,wParam);
m_list.EnsureVisible(i,FALSE);
delete pMsg;
int iColWidth = m_list.GetColumnWidth(0);
CString str;
CSize sz;
int dx = 0;
TEXTMETRIC tm;
CDC* pDC = m_list.GetDC();
CFont* pFont = m_list.GetFont();
CFont* pOldFont = pDC->SelectObject(pFont);
pDC->GetTextMetrics(&tm);
for (int i = 0; i < m_list.GetItemCount(); i++)
{
str = m_list.GetItemText(i, 0);
sz = pDC->GetTextExtent(str);
sz.cx += tm.tmMaxCharWidth;
if (sz.cx > dx)
dx = sz.cx;
}
pDC->SelectObject(pOldFont);
m_list.ReleaseDC(pDC);
dx += PING_BITMAP_SIZE;
if (dx > iColWidth)
m_list.SetColumnWidth(0, dx);
return 0;
}
|
|
|
|
|
I've made the following updates to support building in vs2013. Since I can't upload files, I won't post the project files. But the project itself converts fine. Primarily I cleared compiler warnings. Then I added some code to display the error message string when the calls didn't work (usually because a 'user' account was running the app). Then I had to fix a problem that the H-scroll bar did not appear when the error text was longer than the control.
stdafx.h:
#if !defined(AFX_STDAFX_H__6609025C_5D2A_4866_A906_EECB83458979__INCLUDED_)
#define AFX_STDAFX_H__6609025C_5D2A_4866_A906_EECB83458979__INCLUDED_
#pragma once
#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
#define NO_WARN_MBCS_MFC_DEPRECATION // Eliminates: vs2013 warning C4996: 'MBCS_Support_Deprecated_In_MFC': MBCS support in MFC is deprecated and may be removed in a future version of MFC
#define _WINSOCK_DEPRECATED_NO_WARNINGS // Eliminates: vs2013 warning: 'Use getaddrinfo() or GetAddrInfoW() instead ... this is about old calls only supporting IPV4 and not IPV6
#if _MSC_VER > 1300
#pragma warning( disable : 4996 ) // VS .NET 2005 deprecation warning C4996: 'xxxx': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _xxxx
#define strcmpi _strcmpi // warning C4996: 'strcmpi': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _strcmpi.
#ifndef _CRT_SECURE_NO_WARNINGS
#undef _CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES
#define _CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES 1 // VS .NET 2005 Define safe prototype
#define _CRT_SECURE_NO_WARNINGS 1
#endif
#endif // _MSC_VER > 1300
#ifndef _WIN32_WINNT // Allow use of latest features
#define _WIN32_WINNT _WIN32_WINNT_MAXVER // This clears a warning and is the default
#endif
#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit
#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
#define NO_WARN_MBCS_MFC_DEPRECATION // Eliminates: vs2013 warning C4996: 'MBCS_Support_Deprecated_In_MFC': MBCS support in MFC is deprecated and may be removed in a future version of MFC
#define _AFX_ALL_WARNINGS
#include <afxwin.h> // MFC core and standard components
#include <afxext.h> // MFC extensions
#ifndef _AFX_NO_AFXCMN_SUPPORT
#include <afxcmn.h> // MFC support for Windows Common Controls
#endif // _AFX_NO_AFXCMN_SUPPORT
#include <afxsock.h> // MFC socket extensions
#define WM_MSG_STATUS WM_USER + 0x0100
#define WM_PING_END WM_USER + 0x0101
static char* AllocBuffer(CString strMsg)
{
int nLen = strMsg.GetLength();
char *pBuffer = new char[nLen+1];
strcpy(pBuffer,(const char*)strMsg);
ASSERT(pBuffer != NULL);
return pBuffer;
}
#endif // !defined(AFX_STDAFX_H__6609025C_5D2A_4866_A906_EECB83458979__INCLUDED_)
WinPing.cpp
#include "stdafx.h"
#include "WinPing.h"
#include "WinPingDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
BEGIN_MESSAGE_MAP(CWinPingApp, CWinApp)
ON_COMMAND(ID_HELP, CWinApp::OnHelp)
END_MESSAGE_MAP()
CWinPingApp::CWinPingApp()
{
}
CWinPingApp theApp;
BOOL CWinPingApp::InitInstance()
{
if (!AfxSocketInit())
{
AfxMessageBox(IDP_SOCKETS_INIT_FAILED);
return FALSE;
}
SetRegistryKey("FSWH");
CWinPingDlg dlg;
m_pMainWnd = &dlg;
int nResponse = dlg.DoModal();
if (nResponse == IDOK)
{
}
else if (nResponse == IDCANCEL)
{
}
return FALSE;
}
Added the following to Ping.h:
protected:
void WSAError(LPCSTR pstrFrom); CString GetLastErrorDescription(DWORD dwErrorCode);
Added / Modified in Ping.cpp :
CString CPing::GetLastErrorDescription(DWORD dwErrorCode)
{
CString csErrorDescription;
LPVOID lpMsgBuf;
if (FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
dwErrorCode,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR)&lpMsgBuf,
0,
NULL))
{
csErrorDescription.Format("WSAError[%d] : %s", dwErrorCode, (char *)lpMsgBuf);
LocalFree(lpMsgBuf);
}
return csErrorDescription;
}
void CPing::WSAError(LPCSTR lpMsg)
{
CString strMsg;
DWORD dwErrorCode = WSAGetLastError();
strMsg.Format("%s - %s", lpMsg, GetLastErrorDescription(dwErrorCode));
::PostMessage(m_hWnd,WM_MSG_STATUS, 0, (LPARAM) AllocBuffer(strMsg));
}
|
|
|
|
|
|
|
the author is really a hero !thank you so much .i love you you you
|
|
|
|
|
1. Does not compares the dest addr and answer addr
2. Does not checks the answer type and code. When router send awswer with error "Host unreachable error" (Type = 3 and Code = 1) the programm writes:
Reply[5] from: 192...... : bytes=32 time=118111079ms TTL=64 Ret =1
|
|
|
|
|
The code is nearly 10 years old, things can be done a whole lot differently.
Two heads are better than one.
|
|
|
|
|
Does any body knows how fix the code to run it with a non administrator account
Thanks....
AS
|
|
|
|
|
|
Dear Sir
look to the following part of ur code
void CPing::Ping(UINT nRetries,LPCSTR pstrHost,HWND hWnd)
{
...
for (nLoop = 0; nLoop < nRetries; nLoop++)
{
SendEchoRequest(rawSocket, &saDest);
....
}
so if i said ping 100 times , such 100 times will all done inside the ping func. itself which will be trigger by one thread
UINT CPingThread::ThreadProc(void* lpParam)
{
...
.
.
if (dwWait == WAIT_OBJECT_0 + 1)
pThis->m_ping.Ping(pThis->m_nRetries,pThis->m_strHost, pThis->m_hWnd);
.
.
the real mutli-thread we should have 100 thread each make one ping ??
am i right??
or there is misunderstanding
thanks
modified on Thursday, December 4, 2008 5:02 PM
|
|
|
|
|
Any ideas anyone?
Regards
|
|
|
|
|
working fine on my vista box.
|
|
|
|
|
Winping is not working on Vista.
Its giving error "Socket()-WSAError 10013"
|
|
|
|
|
"An attempt was made to access a socket in a way forbidden by its access permissions. "
Try running as administrator.
Also make sure you don't do a broadcast like 255.255.255.255
|
|
|
|
|
Why must be administrator?
|
|
|
|
|
|
|
Thanks very much i needed a code as yours ;D
---
|
|
|
|
|
Hi!
I making this program to an console app. Because of that I need to change the code. In debuging mode, after calling rawSocket = socket(AF_INET, SOCK_RAW, IPPROTO_ICMP);
The socket is SOCKET == ERROR and goes into Error mode instead of going to the OnPing as it does in the winapp.
Why does the compiler go to OnTimer after that the socket funktion is called?
Look here
Debug:
....
....
-> rawSocket = socket(AF_INET, SOCK_RAW, IPPROTO_ICMP);
-> void CWinPingDlg::OnTimer(UINT nIDEvent)
...
...
I am nott familiar with sockets!
Any suggestions?
GOgo
|
|
|
|
|
when my firewall is open this ping program cannot ping to the web server,please tell me how to change this program to ping to the web server when the firewall is open.
I appreciate your help.
|
|
|
|
|
Hey there,
Hope you still visit this article, as am having problems with ping application of mine which has similar logic as your app and some how windows firewall blocks ICMP packets, was wondering if there is a way around.
thanks
Rahul
|
|
|
|
|
hi!
good work!
i.m playing with it....
now it maintains an ip-ranges
like that: 192.168.*.*
good luck !
|
|
|
|
|