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.

91 lines
3.1 KiB

  1. //+----------------------------------------------------------------------------
  2. //
  3. // File: inetopt.cpp
  4. //
  5. // Module: CMDL32.EXE and CMROUTE.DLL
  6. //
  7. // Synopsis: Source file for shared APIs to set WinInet options
  8. //
  9. // Copyright (c) 2001 Microsoft Corporation
  10. //
  11. // Author: quintinb Created 08/22/01
  12. //
  13. //+----------------------------------------------------------------------------
  14. #ifndef _INETOPT_CPP_
  15. #define _INETOPT_CPP_
  16. //+----------------------------------------------------------------------------
  17. //
  18. // Function: SuppressInetAutoDial
  19. //
  20. // Synopsis: Sets Inet Option to turn off auto-dial for requests made by this
  21. // process. This prevents multiple instances of CM popping up to
  22. // service CMDL initiated requests if the user disconnects CM
  23. // immediately after getting connected.
  24. //
  25. // Arguments: None
  26. //
  27. // Returns: Nothing
  28. //
  29. // History: nickball Created Header 6/3/99
  30. //
  31. //+----------------------------------------------------------------------------
  32. void SuppressInetAutoDial(HINTERNET hInternet)
  33. {
  34. DWORD dwTurnOff = 1;
  35. //
  36. // The flag only exists for IE5, this call
  37. // will have no effect if IE5 is not present.
  38. //
  39. BOOL bTmp = InternetSetOption(hInternet, INTERNET_OPTION_DISABLE_AUTODIAL, &dwTurnOff, sizeof(DWORD));
  40. MYDBGTST(FALSE == bTmp, ("InternetSetOption() returned %d, GLE=%u.", bTmp, GetLastError()));
  41. }
  42. //+----------------------------------------------------------------------------
  43. //
  44. // Function: SetInetStateConnected
  45. //
  46. // Synopsis: Sets the Inet Option to tell wininet that we are connected.
  47. // Normally this isn't an issue but if the user has IE set to offline
  48. // mode, then cmdl cannot get use the wininet APIs to make a
  49. // phonebook request. Thus, we will tell Wininet we are connected.
  50. //
  51. // Arguments: HINTERNET hInternet - inet handle to call InternetSetOption on.
  52. //
  53. // Returns: Nothing
  54. //
  55. // History: quintinb Created 08/21/01
  56. //
  57. //+----------------------------------------------------------------------------
  58. BOOL SetInetStateConnected(HINTERNET hInternet)
  59. {
  60. //
  61. // First query wininet to see if we are in offline mode
  62. //
  63. DWORD dwConnectedState = 0;
  64. DWORD dwSize = sizeof(dwConnectedState);
  65. BOOL bSuccess = InternetQueryOption(hInternet, INTERNET_OPTION_CONNECTED_STATE, &dwConnectedState, &dwSize);
  66. if (bSuccess)
  67. {
  68. if (INTERNET_STATE_DISCONNECTED_BY_USER & dwConnectedState)
  69. {
  70. //
  71. // Okay, we are in offline mode. Let's go ahead and set ourselves to connected.
  72. //
  73. INTERNET_CONNECTED_INFO ConnInfo = {0};
  74. ConnInfo.dwConnectedState = INTERNET_STATE_CONNECTED;
  75. dwSize = sizeof(ConnInfo);
  76. bSuccess = InternetSetOption(hInternet, INTERNET_OPTION_CONNECTED_STATE, &ConnInfo, dwSize);
  77. MYDBGTST(FALSE == bSuccess, ("InternetSetOption() returned %d, GLE=%u.", bSuccess, GetLastError()));
  78. }
  79. }
  80. return bSuccess;
  81. }
  82. #endif