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.

103 lines
2.2 KiB

  1. //=======================================================================
  2. //
  3. // Copyright (C) Microsoft Corporation, 1998 - 1999 All Rights Reserved.
  4. //
  5. // File: WUpdMgr.cpp
  6. //
  7. // Description:
  8. // Executable launched from the Windows Update shortcut.
  9. //
  10. //=======================================================================
  11. #include <stdio.h>
  12. #include <tchar.h>
  13. #include <windows.h>
  14. #include <wininet.h> //INTERNET_MAX_URL_LENGTH
  15. #include <shellapi.h>
  16. #include <objbase.h>
  17. #include <shlobj.h>
  18. #include "sysinfo.h"
  19. #include "msg.h"
  20. #include <atlbase.h>
  21. #include <atlconv.cpp>
  22. const TCHAR HELPCENTER_WINUPD_URL[] = _T("hcp://system/updatectr/updatecenter.htm");
  23. /////////////////////////////////////////////////////////////////////////////
  24. // vShowMessageBox
  25. // Display an error in a message box.
  26. //
  27. // Parameters:
  28. //
  29. // Comments :
  30. /////////////////////////////////////////////////////////////////////////////
  31. void vShowMessageBox(DWORD dwMessageId)
  32. {
  33. LPTSTR tszMsg = _T("");
  34. DWORD dwResult =
  35. FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER |
  36. FORMAT_MESSAGE_FROM_HMODULE,
  37. NULL,
  38. dwMessageId,
  39. 0,
  40. (LPTSTR)&tszMsg,
  41. 0,
  42. NULL);
  43. // if we can't get the message, we don't do anything.
  44. if ( dwResult != 0 )
  45. {
  46. MessageBox(NULL,
  47. tszMsg,
  48. NULL,
  49. MB_OK | MB_ICONEXCLAMATION);
  50. LocalFree(tszMsg);
  51. }
  52. }
  53. /////////////////////////////////////////////////////////////////////////////
  54. // main
  55. // Entry point.
  56. //
  57. // Parameters:
  58. //
  59. // Comments :
  60. /////////////////////////////////////////////////////////////////////////////
  61. int __cdecl main(int argc, char **argv)
  62. {
  63. int nReturn = 0;
  64. if ( FWinUpdDisabled() )
  65. {
  66. vShowMessageBox(WU_E_DISABLED);
  67. nReturn = 1;
  68. }
  69. else
  70. {
  71. bool fConnected;
  72. // Determine if the internet connection wizard has run and we are
  73. // connected to the Internet
  74. VoidGetConnectionStatus(&fConnected);
  75. if ( fConnected )
  76. { // The user has an internet connection.
  77. // Launch IE to go to the site
  78. vLaunchIE(WINDOWS_UPDATE_URL);
  79. }
  80. else
  81. {
  82. //launch helpcenter version of WU
  83. ShellExecute(NULL, NULL, HELPCENTER_WINUPD_URL, NULL, NULL, SW_SHOWNORMAL);
  84. }
  85. }
  86. return nReturn;
  87. }