Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

54 lines
1.8 KiB

  1. /*
  2. * Dialmon.cpp
  3. *
  4. * Stuff to deal with the autodial monitor
  5. *
  6. * Copyright (c) 1996 Microsoft Corporation
  7. */
  8. #include "inspch.h"
  9. #include "util2.h"
  10. // class name for window to receive Winsock activity messages
  11. #define AUTODIAL_MONITOR_CLASS_NAME "MS_AutodialMonitor"
  12. #define WEBCHECK_MONITOR_CLASS_NAME "MS_WebcheckMonitor"
  13. static const CHAR szAutodialMonitorClass[] = AUTODIAL_MONITOR_CLASS_NAME;
  14. static const CHAR szWebcheckMonitorClass[] = WEBCHECK_MONITOR_CLASS_NAME;
  15. #define WM_DIALMON_FIRST WM_USER+100
  16. // message sent to dial monitor app window indicating that there has been
  17. // winsock activity and dial monitor should reset its idle timer
  18. #define WM_WINSOCK_ACTIVITY WM_DIALMON_FIRST + 0
  19. #define MIN_ACTIVITY_MSG_INTERVAL 15000
  20. VOID IndicateWinsockActivity(VOID)
  21. {
  22. // if there is an autodisconnect monitor, send it an activity message
  23. // so that we don't get disconnected during long downloads. For perf's sake,
  24. // don't send a message any more often than once every MIN_ACTIVITY_MSG_INTERVAL
  25. // milliseconds (15 seconds). Use GetTickCount to determine interval;
  26. // GetTickCount is very cheap.
  27. DWORD dwTickCount = GetTickCount();
  28. static DWORD dwLastActivityMsgTickCount = 0;
  29. DWORD dwElapsed = dwTickCount - dwLastActivityMsgTickCount;
  30. // have we sent an activity message recently?
  31. if (dwElapsed > MIN_ACTIVITY_MSG_INTERVAL)
  32. {
  33. HWND hwndMonitorApp = FindWindow(szAutodialMonitorClass,NULL);
  34. if(!hwndMonitorApp)
  35. hwndMonitorApp = FindWindow(szWebcheckMonitorClass,NULL);
  36. if (hwndMonitorApp)
  37. {
  38. SendNotifyMessage(hwndMonitorApp,WM_WINSOCK_ACTIVITY,0,0);
  39. }
  40. // record the tick count of the last time we sent an
  41. // activity message
  42. dwLastActivityMsgTickCount = dwTickCount;
  43. }
  44. }