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.

145 lines
4.6 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, 0, 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. if (MultiByteToWideChar(CP_ACP, 0,
  66. lpszCmdLine, -1,
  67. lpwszCmdLine, iLen))
  68. {
  69. SHHelpShortcuts_RunDLL_Common( hwndStub,
  70. hAppInstance,
  71. lpwszCmdLine,
  72. nCmdShow );
  73. }
  74. LocalFree(lpwszCmdLine);
  75. }
  76. }
  77. VOID WINAPI SHHelpShortcuts_RunDLLW(HWND hwndStub, HINSTANCE hAppInstance, LPCWSTR lpwszCmdLine, int nCmdShow)
  78. {
  79. SHHelpShortcuts_RunDLL_Common(hwndStub,hAppInstance,lpwszCmdLine,nCmdShow);
  80. }
  81. //
  82. // SHObjectProperties is an easy way to call the verb "properties" on an object.
  83. // It's easy because the caller doesn't have to deal with LPITEMIDLISTs.
  84. // Note: SHExecuteEx(SEE_MASK_INVOKEIDLIST) works for the SHOP_FILEPATH case,
  85. // but msshrui needs an easy way to do this for printers. Bummer.
  86. //
  87. STDAPI_(BOOL) SHObjectProperties(HWND hwndOwner, DWORD dwType, LPCTSTR pszItem, LPCTSTR pszPage)
  88. {
  89. LPITEMIDLIST pidl = NULL;
  90. switch (dwType & SHOP_TYPEMASK)
  91. {
  92. case SHOP_PRINTERNAME:
  93. ParsePrinterName(pszItem, &pidl);
  94. break;
  95. case SHOP_FILEPATH:
  96. //
  97. // NTRAID#NTBUG9-271529-2001/02/08-jeffreys
  98. //
  99. // Existing callers rely on ILCFP_FLAG_NO_MAP_ALIAS behavior.
  100. //
  101. ILCreateFromPathEx(pszItem, NULL, ILCFP_FLAG_NO_MAP_ALIAS, &pidl, NULL);
  102. break;
  103. case SHOP_VOLUMEGUID:
  104. return ShowMountedVolumeProperties(pszItem, hwndOwner);
  105. }
  106. if (pidl)
  107. {
  108. SHELLEXECUTEINFO sei =
  109. {
  110. sizeof(sei),
  111. SEE_MASK_INVOKEIDLIST, // fMask
  112. hwndOwner, // hwnd
  113. c_szProperties, // lpVerb
  114. NULL, // lpFile
  115. pszPage, // lpParameters
  116. NULL, // lpDirectory
  117. SW_SHOWNORMAL, // nShow
  118. NULL, // hInstApp
  119. pidl, // lpIDList
  120. NULL, // lpClass
  121. 0, // hkeyClass
  122. 0, // dwHotKey
  123. NULL // hIcon
  124. };
  125. BOOL bRet = ShellExecuteEx(&sei);
  126. ILFree(pidl);
  127. return bRet;
  128. }
  129. return FALSE;
  130. }