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.

143 lines
3.8 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows NT Security
  4. // Copyright (C) Microsoft Corporation, 1992 - 1999
  5. //
  6. // File: util.cpp
  7. //
  8. // Contents: Miscellaneous utility functions
  9. //
  10. // History: 12-May-97 kirtd Created
  11. //
  12. //----------------------------------------------------------------------------
  13. #include <stdpch.h>
  14. #include <urlmon.h>
  15. #include <hlink.h>
  16. #include "unicode.h"
  17. //
  18. // The following are stolen from SOFTPUB
  19. //
  20. void TUIGoLink(HWND hwndParent, WCHAR *pszWhere)
  21. {
  22. HCURSOR hcursPrev;
  23. HMODULE hURLMon;
  24. //
  25. // since we're a model dialog box, we want to go behind IE once it comes up!!!
  26. //
  27. SetWindowPos(hwndParent, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE);
  28. hcursPrev = SetCursor(LoadCursor(NULL, IDC_WAIT));
  29. hURLMon = (HMODULE)LoadLibraryU(L"urlmon.dll");
  30. if (!(hURLMon))
  31. {
  32. //
  33. // The hyperlink module is unavailable, go to fallback plan
  34. //
  35. //
  36. // This works in test cases, but causes deadlock problems when used from withing
  37. // the Internet Explorer itself. The dialog box is up (that is, IE is in a modal
  38. // dialog loop) and in comes this DDE request...).
  39. //
  40. DWORD cb;
  41. LPSTR psz;
  42. cb = WideCharToMultiByte(
  43. 0,
  44. 0,
  45. pszWhere,
  46. -1,
  47. NULL,
  48. 0,
  49. NULL,
  50. NULL);
  51. if (NULL == (psz = new char[cb]))
  52. {
  53. return;
  54. }
  55. WideCharToMultiByte(
  56. 0,
  57. 0,
  58. pszWhere,
  59. -1,
  60. psz,
  61. cb,
  62. NULL,
  63. NULL);
  64. ShellExecute(hwndParent, "open", psz, NULL, NULL, SW_SHOWNORMAL);
  65. delete[] psz;
  66. }
  67. else
  68. {
  69. //
  70. // The hyperlink module is there. Use it
  71. //
  72. if (SUCCEEDED(CoInitialize(NULL))) // Init OLE if no one else has
  73. {
  74. //
  75. // allow com to fully init...
  76. //
  77. MSG msg;
  78. PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE); // peek but not remove
  79. typedef void (WINAPI *pfnHlinkSimpleNavigateToString)(LPCWSTR, LPCWSTR, LPCWSTR, IUnknown *,
  80. IBindCtx *, IBindStatusCallback *,
  81. DWORD, DWORD);
  82. pfnHlinkSimpleNavigateToString pProcAddr;
  83. pProcAddr = (pfnHlinkSimpleNavigateToString)GetProcAddress(hURLMon, TEXT("HlinkSimpleNavigateToString"));
  84. if (pProcAddr)
  85. {
  86. IBindCtx *pbc;
  87. pbc = NULL;
  88. CreateBindCtx( 0, &pbc );
  89. (*pProcAddr)(pszWhere, NULL, NULL, NULL, pbc, NULL, HLNF_OPENINNEWWINDOW, NULL);
  90. if (pbc)
  91. {
  92. pbc->Release();
  93. }
  94. }
  95. CoUninitialize();
  96. }
  97. FreeLibrary(hURLMon);
  98. }
  99. SetCursor(hcursPrev);
  100. }
  101. WCHAR *GetGoLink(SPC_LINK *psLink)
  102. {
  103. if (!(psLink))
  104. {
  105. return(NULL);
  106. }
  107. switch (psLink->dwLinkChoice)
  108. {
  109. case SPC_URL_LINK_CHOICE: return(psLink->pwszUrl);
  110. case SPC_FILE_LINK_CHOICE: return(psLink->pwszFile);
  111. case SPC_MONIKER_LINK_CHOICE: return(NULL); // TBDTBD!!!
  112. }
  113. return(NULL);
  114. }