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.

175 lines
4.6 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1997.
  5. //
  6. // File: O P E N F O L D . C P P
  7. //
  8. // Contents: Folder launching code for the connections folder
  9. //
  10. // Notes:
  11. //
  12. // Author: jeffspr 12 Jan 1998
  13. //
  14. //----------------------------------------------------------------------------
  15. #include "pch.h"
  16. #pragma hdrstop
  17. // Undocument shell32 stuff. Sigh.
  18. #define DONT_WANT_SHELLDEBUG 1
  19. #define NO_SHIDLIST 1
  20. #define USE_SHLWAPI_IDLIST
  21. #include "pidlutil.h"
  22. #include <ncdebug.h>
  23. #define AVOID_NET_CONFIG_DUPLICATES
  24. #include "nsbase.h"
  25. #include "nsres.h"
  26. #include <ncdebug.h>
  27. #include <ncreg.h>
  28. #include <netshell.h>
  29. #include <netconp.h>
  30. #include <ncui.h>
  31. #include "cfpidl.h"
  32. #include "openfold.h"
  33. // Note -- Don't convert this to a constant. We need copies of it within the
  34. // functions because ParseDisplayName actually mangles the string.
  35. //
  36. // CLSID_MyComputer
  37. // CLSID_ControlPanel
  38. // CLSID_NetworkConnections
  39. #define NETCON_FOLDER_PATH L"::{20D04FE0-3AEA-1069-A2D8-08002B30309D}\\" \
  40. L"::{21EC2020-3AEA-1069-A2DD-08002B30309D}\\" \
  41. L"::{7007ACC7-3202-11D1-AAD2-00805FC1270E}";
  42. //+---------------------------------------------------------------------------
  43. //
  44. // Function: HrGetConnectionsFolderPidl
  45. //
  46. // Purpose: Get the connections folder pidl. Used in places where we're
  47. // not folder specific, but we still need to update folder
  48. // entries.
  49. //
  50. // Arguments:
  51. // ppidlFolder [out] Return parameter for the folder pidl
  52. //
  53. // Returns:
  54. //
  55. // Author: jeffspr 13 Jun 1998
  56. //
  57. // Notes:
  58. //
  59. HRESULT HrGetConnectionsFolderPidl(OUT PCONFOLDPIDLFOLDER& ppidlFolder)
  60. {
  61. HRESULT hr = S_OK;
  62. LPSHELLFOLDER pshf = NULL;
  63. LPITEMIDLIST pidlFolder = NULL;
  64. // "::CLSID_MyComputer\\::CLSID_ControlPanel\\::CLSID_ConnectionsFolder"
  65. WCHAR szNetConFoldPath[] = NETCON_FOLDER_PATH;
  66. // Get the desktop folder, so we can parse the display name and get
  67. // the UI object of the connections folder
  68. //
  69. hr = SHGetDesktopFolder(&pshf);
  70. if (SUCCEEDED(hr))
  71. {
  72. ULONG chEaten;
  73. pidlFolder = NULL;
  74. hr = pshf->ParseDisplayName(NULL, 0, (WCHAR *) szNetConFoldPath,
  75. &chEaten, &pidlFolder, NULL);
  76. ReleaseObj(pshf);
  77. }
  78. // If succeeded, fill in the return param.
  79. //
  80. if (SUCCEEDED(hr))
  81. {
  82. hr = ppidlFolder.InitializeFromItemIDList(pidlFolder);
  83. SHFree(pidlFolder); // ISSUE: Why can't we free regardless?
  84. }
  85. TraceHr(ttidShellFolder, FAL, hr, FALSE, "HrGetConnectionsFolderPidl");
  86. return hr;
  87. }
  88. //+---------------------------------------------------------------------------
  89. //
  90. // Function: HrOpenConnectionsFolder
  91. //
  92. // Purpose: Open the connections folder in explorer.
  93. //
  94. // Arguments:
  95. // (none)
  96. //
  97. // Returns:
  98. //
  99. // Author: jeffspr 16 Apr 1998
  100. //
  101. // Notes:
  102. //
  103. HRESULT HrOpenConnectionsFolder()
  104. {
  105. HRESULT hr = S_OK;
  106. HCURSOR hcWait = SetCursor(LoadCursor(NULL, IDC_WAIT));
  107. PCONFOLDPIDLFOLDER pidlFolder;
  108. hr = HrGetConnectionsFolderPidl(pidlFolder);
  109. if (SUCCEEDED(hr))
  110. {
  111. Assert(!pidlFolder.empty());
  112. SHELLEXECUTEINFO shei = { 0 };
  113. shei.cbSize = sizeof(shei);
  114. shei.fMask = SEE_MASK_IDLIST | SEE_MASK_INVOKEIDLIST | SEE_MASK_FLAG_DDEWAIT;
  115. shei.nShow = SW_SHOW; // used to be SW_SHOWNORMAL
  116. shei.lpIDList = const_cast<LPITEMIDLIST>(pidlFolder.GetItemIdList());
  117. ShellExecuteEx(&shei);
  118. }
  119. if (hcWait)
  120. {
  121. SetCursor(hcWait);
  122. }
  123. TraceHr(ttidError, FAL, hr, FALSE, "HrOpenConnectionsFolder");
  124. return hr;
  125. }
  126. HRESULT HrGetConnectionsIShellFolder(
  127. const PCONFOLDPIDLFOLDER& pidlFolder,
  128. LPSHELLFOLDER * ppsf)
  129. {
  130. HRESULT hr = S_OK;
  131. LPSHELLFOLDER psfDesktop = NULL;
  132. Assert(ppsf);
  133. *ppsf = NULL;
  134. // Get the desktop folder so we can use it to retrieve the
  135. // connections folder
  136. //
  137. hr = SHGetDesktopFolder(&psfDesktop);
  138. if (SUCCEEDED(hr))
  139. {
  140. Assert(psfDesktop);
  141. hr = psfDesktop->BindToObject(pidlFolder.GetItemIdList(), NULL, IID_IShellFolder,
  142. (LPVOID*) ppsf);
  143. }
  144. TraceHr(ttidShellFolder, FAL, hr, FALSE, "HrGetConnectionsIShellFolder");
  145. return hr;
  146. }