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.

201 lines
7.3 KiB

  1. /******************************************************************************
  2. Source File: Shell Extension Classes.H
  3. This file defines the Shell extension classes. Since the ICM UI is a shell
  4. extension, these are essential. Rather than slavishly including sample code,
  5. this has been written as much as possible from scratch.
  6. If you're not familiar with OLE, then this is going to be a bit difficult
  7. going.
  8. Copyright (c) 1996 by Microsoft Corporation
  9. A Pretty Penny Enterprises Production
  10. Change History:
  11. 10-28-96 A-RobKj (Pretty Penny Enterprises) began coding
  12. 12-03-96 A-RobKj moved the CGlobals class to the pre-comp header file.
  13. 01-07-97 KjelgaardR@acm.org Stubbed IContextMenu interface for profile
  14. management in favor of shell association which uses a RunDLL
  15. Entry point- this allows invocation via Enter, and double-click
  16. ******************************************************************************/
  17. // The class ID of this Shell extension is taken from the one used on Win95.
  18. // This was a deliberate decision, to ease the upgrade process.
  19. //
  20. // class id: dbce2480-c732-101b-be72-ba78e9ad5b27
  21. //
  22. DEFINE_GUID(CLSID_ICM, 0xDBCE2480L, 0xC732, 0x101B, 0xBE, 0x72, 0xBA, 0x78,
  23. 0xE9, 0xAD, 0x5B, 0x27);
  24. // This class ID is for the printer profile management UI. It is implemented
  25. // within the same module, for now, but having a separate GUID makes it
  26. // easier to implement separately later, if so desired. It also simplifies
  27. // implementation.
  28. // Class ID: 675f097e-4c4d-11d0-b6c1-0800091aa605
  29. DEFINE_GUID(CLSID_PRINTERUI, 0x675F097EL, 0x4C4D, 0x11D0, 0xB6, 0xC1, 0x08,
  30. 0x00, 0x09, 0x1A, 0xA6, 0x05);
  31. // This class ID is used (at least temporarily) for the display profile
  32. // management UI. If I wind up not needing it, I will convert it to a
  33. // different class (such as scanners or cameras)
  34. // Class ID: 5db2625a-54df-11d0-b6c4-0800091aa605
  35. DEFINE_GUID(CLSID_MONITORUI, 0x5db2625a, 0x54df, 0x11d0, 0xb6, 0xc4, 0x08,
  36. 0x00, 0x09, 0x1a, 0xa6, 0x05);
  37. // This class ID is used (at least temporarily) for the scanner/camera profile
  38. // management UI.
  39. // Class ID: 176d6597-26d3-11d1-b350-080036a75b03
  40. DEFINE_GUID(CLSID_SCANNERUI, 0x176d6597, 0x26d3, 0x11d1, 0xb3, 0x50, 0x08,
  41. 0x00, 0x36, 0xa7, 0x5b, 0x03);
  42. typedef enum {IsProfile, IsPrinter, IsScanner, IsMonitor} UITYPE;
  43. // First of all, we're going to need a class factory. The shell uses this
  44. // factory to create instances of the objects which implement the interfaces
  45. // it needs.
  46. class CIcmUiFactory : public IClassFactory
  47. {
  48. ULONG m_ulcReferences;
  49. UITYPE m_utThis;
  50. public:
  51. CIcmUiFactory(REFCLSID rclsid);
  52. ~CIcmUiFactory() { CGlobals::Detach(); }
  53. //IUnknown interface
  54. STDMETHODIMP QueryInterface(REFIID riid, void **ppvObject);
  55. STDMETHODIMP_(ULONG) AddRef() { return ++m_ulcReferences; }
  56. STDMETHODIMP_(ULONG) Release() {
  57. if (--m_ulcReferences)
  58. return m_ulcReferences;
  59. delete this;
  60. return 0L;
  61. }
  62. //IClassFactory interface
  63. STDMETHODIMP CreateInstance(LPUNKNOWN punk, REFIID riid,
  64. void **ppvObject);
  65. STDMETHODIMP LockServer(BOOL) { return NOERROR; }
  66. static SCODE KeyToTheFactory(REFCLSID rclsid, REFIID riid,
  67. void **ppvObject);
  68. };
  69. // This class implements the entire extension- it includes a context menu
  70. // handler, and Icon handler, and a property sheet extension.
  71. class CICMUserInterface : public IContextMenu, IShellExtInit, IExtractIcon,
  72. IPersistFile, IShellPropSheetExt
  73. {
  74. ULONG m_ulcReferences;
  75. LPDATAOBJECT m_lpdoTarget;
  76. CString m_csFile; // Profile for icon extraction
  77. //check this - m_acWork doesn't appear to be referenced anywhere.
  78. TCHAR m_acWork[80]; // A little work buffer
  79. UITYPE m_utThis;
  80. BOOL m_bInstalledContext, // 'True' when every selected file(s) are installed
  81. m_bMultiSelection;
  82. HRESULT AddPrinterTab(LPFNADDPROPSHEETPAGE lpfnAddPage,
  83. LPARAM lParam);
  84. HRESULT AddAssociateTab(LPFNADDPROPSHEETPAGE lpfnAddPage,
  85. LPARAM lParam);
  86. HRESULT AddProfileTab(LPFNADDPROPSHEETPAGE lpfnAddPage,
  87. LPARAM lParam);
  88. HRESULT AddScannerTab(LPFNADDPROPSHEETPAGE lpfnAddPage,
  89. LPARAM lParam);
  90. HRESULT AddMonitorTab(LPFNADDPROPSHEETPAGE lpfnAddPage,
  91. LPARAM lParam);
  92. public:
  93. CICMUserInterface(UITYPE utThis);
  94. ~CICMUserInterface() {
  95. if (m_lpdoTarget)
  96. m_lpdoTarget -> Release();
  97. CGlobals::Detach();
  98. }
  99. //IUnknown members
  100. STDMETHODIMP QueryInterface(REFIID, LPVOID FAR *);
  101. STDMETHODIMP_(ULONG) AddRef() { return ++m_ulcReferences; }
  102. STDMETHODIMP_(ULONG) Release() {
  103. if (--m_ulcReferences)
  104. return m_ulcReferences;
  105. delete this;
  106. return 0L;
  107. }
  108. // IContextMenu methods
  109. STDMETHODIMP QueryContextMenu(HMENU hMenu, UINT indexMenu,
  110. UINT idCmdFirst, UINT idCmdLast,
  111. UINT uFlags);
  112. STDMETHODIMP InvokeCommand(LPCMINVOKECOMMANDINFO lpcmi);
  113. STDMETHODIMP GetCommandString(UINT_PTR idCmd, UINT uFlags,
  114. UINT FAR *reserved, LPSTR pszName,
  115. UINT cchMax);
  116. // IShellExtInit methods
  117. STDMETHODIMP Initialize(LPCITEMIDLIST pIDFolder, LPDATAOBJECT pDataObj,
  118. HKEY hKeyID);
  119. // IExtractIcon methods
  120. STDMETHODIMP GetIconLocation(UINT uFlags, LPTSTR szIconFile, UINT cchMax,
  121. int *piIndex, UINT *pwFlags);
  122. STDMETHODIMP Extract(LPCTSTR pszFile, UINT nIconIndex,
  123. HICON *phiconLarge, HICON *phiconSmall,
  124. UINT nIconSize);
  125. // IPersistFile methods- note that (as the OLE documentation says) only
  126. // Load ever gets used. GetClassID is from IPersist, from which
  127. // IPersistFile is derived. We fail everything we don't expect to see
  128. // called.
  129. STDMETHODIMP GetClassID(LPCLSID lpClassID) { return E_FAIL; }
  130. STDMETHODIMP IsDirty() { return S_FALSE; }
  131. STDMETHODIMP Load(LPCOLESTR lpszFileName, DWORD grfMode);
  132. STDMETHODIMP Save(LPCOLESTR lpszFileName, BOOL fRemember) {
  133. return E_FAIL;
  134. }
  135. STDMETHODIMP SaveCompleted(LPCOLESTR lpszFileName) { return E_FAIL; }
  136. STDMETHODIMP GetCurFile(LPOLESTR FAR* lplpszFileName) {
  137. return E_FAIL;
  138. }
  139. // IShellPropSheetExt methods
  140. STDMETHODIMP AddPages(LPFNADDPROPSHEETPAGE lpfnAddPage, LPARAM lParam);
  141. STDMETHODIMP ReplacePage(UINT uPageID,
  142. LPFNADDPROPSHEETPAGE lpfnReplaceWith,
  143. LPARAM lParam) { return E_FAIL; }
  144. };