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.

143 lines
4.4 KiB

  1. //---------------------------------------------------------------------------
  2. //
  3. // Copyright (c) Microsoft Corporation 1991-1992
  4. //
  5. // File: help.c
  6. //
  7. // History:
  8. // 6 Apr 94 MikeSh Created
  9. //
  10. //---------------------------------------------------------------------------
  11. #include "shellprv.h"
  12. #pragma hdrstop
  13. #include "printer.h"
  14. #include "drives.h" // for ShowMountedVolumeProperties
  15. //
  16. // (internal) entry point for Help "Shortcuts".
  17. //
  18. STDAPI_(void) SHHelpShortcuts_RunDLL_Common(HWND hwndStub, HINSTANCE hAppInstance, LPCTSTR pszCmdLine, int nCmdShow)
  19. {
  20. if (!lstrcmp(pszCmdLine, TEXT("AddPrinter")))
  21. {
  22. // install a new printer
  23. LPITEMIDLIST pidl = Printers_PrinterSetup(hwndStub, MSP_NEWPRINTER, (LPTSTR)c_szNewObject, NULL);
  24. ILFree(pidl);
  25. }
  26. else if (!lstrcmp(pszCmdLine, TEXT("PrintersFolder")))
  27. {
  28. // bring up the printers folder
  29. InvokeFolderPidl(MAKEINTIDLIST(CSIDL_PRINTERS), SW_SHOWNORMAL);
  30. }
  31. else if (!lstrcmp(pszCmdLine, TEXT("FontsFolder")))
  32. {
  33. // bring up the printers folder
  34. InvokeFolderPidl(MAKEINTIDLIST(CSIDL_FONTS), SW_SHOWNORMAL);
  35. }
  36. else if (!lstrcmp(pszCmdLine, TEXT("Connect")))
  37. {
  38. SHNetConnectionDialog(hwndStub, NULL, RESOURCETYPE_DISK);
  39. goto FlushDisconnect;
  40. }
  41. else if (!lstrcmp(pszCmdLine, TEXT("Disconnect")))
  42. {
  43. WNetDisconnectDialog(hwndStub, RESOURCETYPE_DISK);
  44. FlushDisconnect:
  45. SHChangeNotifyHandleEvents(); // flush any drive notifications
  46. }
  47. #ifdef DEBUG
  48. else if (!StrCmpN(pszCmdLine, TEXT("PrtProp "), 8))
  49. {
  50. SHObjectProperties(hwndStub, SHOP_PRINTERNAME, &(pszCmdLine[8]), TEXT("Sharing"));
  51. }
  52. else if (!StrCmpN(pszCmdLine, TEXT("FileProp "), 9))
  53. {
  54. SHObjectProperties(hwndStub, SHOP_FILEPATH, &(pszCmdLine[9]), TEXT("Sharing"));
  55. }
  56. #endif
  57. }
  58. VOID WINAPI SHHelpShortcuts_RunDLL(HWND hwndStub, HINSTANCE hAppInstance, LPCSTR lpszCmdLine, int nCmdShow)
  59. {
  60. UINT iLen = lstrlenA(lpszCmdLine)+1;
  61. LPWSTR lpwszCmdLine;
  62. lpwszCmdLine = (LPWSTR)LocalAlloc(LPTR,iLen*sizeof(WCHAR));
  63. if (lpwszCmdLine)
  64. {
  65. MultiByteToWideChar(CP_ACP, 0,
  66. lpszCmdLine, -1,
  67. lpwszCmdLine, iLen);
  68. SHHelpShortcuts_RunDLL_Common( hwndStub,
  69. hAppInstance,
  70. lpwszCmdLine,
  71. nCmdShow );
  72. LocalFree(lpwszCmdLine);
  73. }
  74. }
  75. VOID WINAPI SHHelpShortcuts_RunDLLW(HWND hwndStub, HINSTANCE hAppInstance, LPCWSTR lpwszCmdLine, int nCmdShow)
  76. {
  77. SHHelpShortcuts_RunDLL_Common(hwndStub,hAppInstance,lpwszCmdLine,nCmdShow);
  78. }
  79. //
  80. // SHObjectProperties is an easy way to call the verb "properties" on an object.
  81. // It's easy because the caller doesn't have to deal with LPITEMIDLISTs.
  82. // Note: SHExecuteEx(SEE_MASK_INVOKEIDLIST) works for the SHOP_FILEPATH case,
  83. // but msshrui needs an easy way to do this for printers. Bummer.
  84. //
  85. STDAPI_(BOOL) SHObjectProperties(HWND hwndOwner, DWORD dwType, LPCTSTR pszItem, LPCTSTR pszPage)
  86. {
  87. LPITEMIDLIST pidl = NULL;
  88. switch (dwType & SHOP_TYPEMASK)
  89. {
  90. case SHOP_PRINTERNAME:
  91. ParsePrinterName(pszItem, &pidl);
  92. break;
  93. case SHOP_FILEPATH:
  94. //
  95. // NTRAID#NTBUG9-271529-2001/02/08-jeffreys
  96. //
  97. // Existing callers rely on ILCFP_FLAG_NO_MAP_ALIAS behavior.
  98. //
  99. ILCreateFromPathEx(pszItem, NULL, ILCFP_FLAG_NO_MAP_ALIAS, &pidl, NULL);
  100. break;
  101. case SHOP_VOLUMEGUID:
  102. return ShowMountedVolumeProperties(pszItem, hwndOwner);
  103. }
  104. if (pidl)
  105. {
  106. SHELLEXECUTEINFO sei =
  107. {
  108. sizeof(sei),
  109. SEE_MASK_INVOKEIDLIST, // fMask
  110. hwndOwner, // hwnd
  111. c_szProperties, // lpVerb
  112. NULL, // lpFile
  113. pszPage, // lpParameters
  114. NULL, // lpDirectory
  115. SW_SHOWNORMAL, // nShow
  116. NULL, // hInstApp
  117. pidl, // lpIDList
  118. NULL, // lpClass
  119. 0, // hkeyClass
  120. 0, // dwHotKey
  121. NULL // hIcon
  122. };
  123. BOOL bRet = ShellExecuteEx(&sei);
  124. ILFree(pidl);
  125. return bRet;
  126. }
  127. return FALSE;
  128. }