Source code of Windows XP (NT5)
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.

106 lines
2.3 KiB

  1. /******************************************************************************
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. MPCConnection.cpp
  5. Abstract:
  6. This file contains the implementation of the CMPCConnection class, which is
  7. used as the entry point into the Upload Library.
  8. Revision History:
  9. Davide Massarenti (Dmassare) 04/15/99
  10. created
  11. ******************************************************************************/
  12. #include "stdafx.h"
  13. CMPCConnection::CMPCConnection()
  14. {
  15. __ULT_FUNC_ENTRY( "CMPCConnection::CMPCConnection" );
  16. }
  17. STDMETHODIMP CMPCConnection::get_Available( /*[out, retval]*/ VARIANT_BOOL *pfOnline )
  18. {
  19. __ULT_FUNC_ENTRY( "CMPCConnection::get_Available" );
  20. DWORD dwMode = 0;
  21. //
  22. // First of all, set the values to some meaningful default.
  23. //
  24. if(pfOnline) *pfOnline = VARIANT_FALSE;
  25. if(InternetGetConnectedState( &dwMode, 0 ) == TRUE)
  26. {
  27. if(pfOnline) *pfOnline = VARIANT_TRUE;
  28. }
  29. __ULT_FUNC_EXIT(S_OK);
  30. }
  31. STDMETHODIMP CMPCConnection::get_IsAModem( /*[out, retval]*/ VARIANT_BOOL *pfModem )
  32. {
  33. __ULT_FUNC_ENTRY( "CMPCConnection::get_IsAModem" );
  34. DWORD dwMode = 0;
  35. //
  36. // First of all, set the values to some meaningful default.
  37. //
  38. if(pfModem) *pfModem = VARIANT_TRUE;
  39. if(InternetGetConnectedState( &dwMode, 0 ) == TRUE)
  40. {
  41. if(pfModem)
  42. {
  43. if(dwMode & INTERNET_CONNECTION_MODEM) *pfModem = VARIANT_TRUE;
  44. if(dwMode & INTERNET_CONNECTION_LAN ) *pfModem = VARIANT_FALSE;
  45. }
  46. }
  47. __ULT_FUNC_EXIT(S_OK);
  48. }
  49. STDMETHODIMP CMPCConnection::get_Bandwidth( /*[out, retval]*/ long *plBandwidth )
  50. {
  51. __ULT_FUNC_ENTRY( "CMPCConnection::get_Bandwidth" );
  52. HRESULT hr;
  53. DWORD dwMode = 0;
  54. __MPC_SET_ERROR_AND_EXIT(hr, E_NOTIMPL);
  55. //
  56. // First of all, set the values to some meaningful default.
  57. //
  58. if(plBandwidth) *plBandwidth = 28800;
  59. if(InternetGetConnectedState( &dwMode, 0 ) == TRUE)
  60. {
  61. //
  62. // NOTICE: under Win9X it's not possible to know the actual connection speed...
  63. //
  64. if(plBandwidth)
  65. {
  66. if(dwMode & INTERNET_CONNECTION_MODEM) *plBandwidth = 28800;
  67. if(dwMode & INTERNET_CONNECTION_LAN ) *plBandwidth = 128000;
  68. }
  69. }
  70. hr = S_OK;
  71. __ULT_FUNC_CLEANUP;
  72. __ULT_FUNC_EXIT(hr);
  73. }