我被告知要写一个C++程序,它在后台运行,并记录访问过的网站或从计算机上传/下载到互联网的文件。将来,它将需要扩展,以便程序可以从我办公室局域网中的任何计算机跟踪互联网使用情况。
该程序将在各种Windows操作系统上运行,从Windows 2000到Windows 7。
有人能帮帮我吗?
发布于 2011-07-08 19:56:48
您需要编写一个数据包嗅探器。如果你想写一个好的包嗅探器,这是一个非常实用的项目。在网上搜索一下。了解C/C++套接字库以开始使用。下面是一些网站。here和here
发布于 2011-07-08 19:59:06
嗯……在公司的网络代理服务器上执行这个功能不是更容易吗?他们中的大多数甚至都有插件来执行这个确切的功能,所以实际上不需要编写任何代码。
发布于 2017-08-29 16:56:55
您可以使用以下代码,其优点是它还将捕获私密浏览。
CoInitialize(NULL);
LHook = SetWinEventHook(EVENT_OBJECT_FOCUS, EVENT_OBJECT_VALUECHANGE, 0, RT_Browsing_WinEventProc, 0, 0, WINEVENT_OUTOFCONTEXT | WINEVENT_SKIPOWNPROCESS);那么回调函数将是:
void CALLBACK RT_Browsing_WinEventProc(HWINEVENTHOOK hWinEventHook, DWORD event, HWND hwnd, LONG idObject, LONG idChild, DWORD dwEventThread, DWORD dwmsEventTime)
{
IAccessible* pAcc = NULL;
VARIANT varChild;
HRESULT hr = AccessibleObjectFromEvent(hwnd, idObject, idChild, &pAcc, &varChild);
if ((hr == S_OK) && (pAcc != NULL))
{
BSTR bstrName, bstrValue;
pAcc->get_accValue(varChild, &bstrValue);
pAcc->get_accName(varChild, &bstrName);
char className[50];
GetClassNameA(hwnd, className, 50);
if (bstrName && bstrValue)
{
if ((strcmp(className, "Internet Explorer_Server") == 0))
{
if (IsValidURL(NULL, bstrValue, NULL) == S_OK)
{
if (bstrValue != E_LastURL)
{
// bstrValue will hold the new URL (Internet Explorer)
E_LastURL = bstrValue;
}
}
}
if ((strcmp(className, "Chrome_WidgetWin_1") == 0) && (wcscmp(bstrName, L"Address and search bar") == 0))
{
if (IsValidURL(NULL, bstrValue, NULL) == S_OK)
{
if (bstrValue != C_LastURL && bstrValue != L"")
{
// bstrValue will hold the new URL (Chrome)
C_LastURL = bstrValue;
}
}
}
}
pAcc->Release();
}
}https://stackoverflow.com/questions/6624007
复制相似问题