test: shellext.h Source File

Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

# shellext.h

Go to the documentation of this file.

    00001 /******************************************************************************
    00002
    00003   Source File:  Shell Extension Classes.H
    00004
    00005   This file defines the Shell extension classes.  Since the ICM UI is a shell
    00006   extension, these are essential.  Rather than slavishly including sample code,
    00007   this has been written as much as possible from scratch.
    00008
    00009   If you're not familiar with OLE, then this is going to be a bit difficult
    00010   going.
    00011
    00012   Copyright (c) 1996 by Microsoft Corporation
    00013
    00014   A Pretty Penny Enterprises Production
    00015
    00016   Change History:
    00017
    00018   10-28-96 A-RobKj (Pretty Penny Enterprises) began coding
    00019   12-03-96 A-RobKj moved the CGlobals class to the pre-comp header file.
    00020   01-07-97 KjelgaardR@acm.org   Stubbed IContextMenu interface for profile
    00021             management in favor of shell association which uses a RunDLL
    00022             Entry point- this allows invocation via Enter, and double-click
    00023
    00024 ******************************************************************************/
    00025
    00026 // The class ID of this Shell extension is taken from the one used on Win95.
    00027
    00028 //  This was a deliberate decision, to ease the upgrade process.
    00029 //
    00030 // class id:  dbce2480-c732-101b-be72-ba78e9ad5b27
    00031 //
    00032
    00033 DEFINE_GUID(CLSID_ICM, 0xDBCE2480L, 0xC732, 0x101B, 0xBE, 0x72, 0xBA, 0x78,
    00034             0xE9, 0xAD, 0x5B, 0x27);
    00035
    00036 //  This class ID is for the printer profile management UI.  It is implemented
    00037 //  within the same module, for now, but having a separate GUID makes it
    00038 //  easier to implement separately later, if so desired.  It also simplifies
    00039 //  implementation.
    00040
    00041 //  Class ID:  675f097e-4c4d-11d0-b6c1-0800091aa605
    00042
    00043 DEFINE_GUID(CLSID_PRINTERUI, 0x675F097EL, 0x4C4D, 0x11D0, 0xB6, 0xC1, 0x08,
    00044              0x00, 0x09, 0x1A, 0xA6, 0x05);
    00045
    00046 //  This class ID is used (at least temporarily) for the display profile
    00047 //  management UI.  If I wind up not needing it, I will convert it to a
    00048 //  different class (such as scanners or cameras)
    00049
    00050 //  Class ID: 5db2625a-54df-11d0-b6c4-0800091aa605
    00051
    00052 DEFINE_GUID(CLSID_MONITORUI, 0x5db2625a, 0x54df, 0x11d0, 0xb6, 0xc4, 0x08,
    00053             0x00, 0x09, 0x1a, 0xa6, 0x05);
    00054
    00055 //  This class ID is used (at least temporarily) for the scanner/camera profile
    00056 //  management UI.
    00057
    00058 //  Class ID: 176d6597-26d3-11d1-b350-080036a75b03
    00059
    00060 DEFINE_GUID(CLSID_SCANNERUI, 0x176d6597, 0x26d3, 0x11d1, 0xb3, 0x50, 0x08,
    00061             0x00, 0x36, 0xa7, 0x5b, 0x03);
    00062
    00063 typedef enum    {IsProfile, IsPrinter, IsScanner, IsMonitor} UITYPE;
    00064
    00065 //  First of all, we're going to need a class factory.  The shell uses this
    00066 //  factory to create instances of the objects which implement the interfaces
    00067 //  it needs.
    00068
    00069 class CIcmUiFactory : public IClassFactory
    00070 {
    00071     ULONG   m_ulcReferences;
    00072     UITYPE  m_utThis;
    00073
    00074 public:
    00075     CIcmUiFactory(REFCLSID rclsid);
    00076     ~CIcmUiFactory() { CGlobals::Detach(); }
    00077
    00078     //IUnknown interface
    00079     STDMETHODIMP            QueryInterface(REFIID riid, void **ppvObject);
    00080     STDMETHODIMP_(ULONG)    AddRef() { return ++m_ulcReferences; }
    00081     STDMETHODIMP_(ULONG)    Release() {
    00082         if  (--m_ulcReferences)
    00083             return  m_ulcReferences;
    00084
    00085         delete  this;
    00086         return  0L;
    00087     }
    00088
    00089     //IClassFactory interface
    00090     STDMETHODIMP    CreateInstance(LPUNKNOWN punk, REFIID riid,
    00091                                    void **ppvObject);
    00092     STDMETHODIMP    LockServer(BOOL) { return NOERROR; }
    00093
    00094     static SCODE    KeyToTheFactory(REFCLSID rclsid, REFIID riid,
    00095                                     void **ppvObject);
    00096 };
    00097
    00098 //  This class implements the entire extension- it includes a context menu
    00099 //  handler, and Icon handler, and a property sheet extension.
    00100
    00101 class CICMUserInterface : public IContextMenu, IShellExtInit, IExtractIcon,
    00102                                     IPersistFile, IShellPropSheetExt
    00103 {
    00104     ULONG           m_ulcReferences;
    00105     LPDATAOBJECT    m_lpdoTarget;
    00106     CString         m_csFile;         //  Profile for icon extraction
    00107     //check this - m_acWork doesn't appear to be referenced anywhere.
    00108     TCHAR           m_acWork[80];     //  A little work buffer
    00109     UITYPE          m_utThis;
    00110     BOOL            m_bInstalledContext, // 'True' when every selected file(s) are installed
    00111                     m_bMultiSelection;
    00112
    00113     HRESULT         AddPrinterTab(LPFNADDPROPSHEETPAGE lpfnAddPage,
    00114                                   LPARAM lParam);
    00115
    00116     HRESULT         AddAssociateTab(LPFNADDPROPSHEETPAGE lpfnAddPage,
    00117                                     LPARAM lParam);
    00118
    00119     HRESULT         AddProfileTab(LPFNADDPROPSHEETPAGE lpfnAddPage,
    00120                                   LPARAM lParam);
    00121
    00122     HRESULT         AddScannerTab(LPFNADDPROPSHEETPAGE lpfnAddPage,
    00123                                   LPARAM lParam);
    00124
    00125     HRESULT         AddMonitorTab(LPFNADDPROPSHEETPAGE lpfnAddPage,
    00126                                   LPARAM lParam);
    00127
    00128 public:
    00129     CICMUserInterface(UITYPE utThis);
    00130
    00131     ~CICMUserInterface() {
    00132
    00133         if  (m_lpdoTarget)
    00134             m_lpdoTarget -> Release();
    00135         CGlobals::Detach();
    00136     }
    00137
    00138     //IUnknown members
    00139     STDMETHODIMP            QueryInterface(REFIID, LPVOID FAR *);
    00140     STDMETHODIMP_(ULONG)    AddRef() { return ++m_ulcReferences; }
    00141     STDMETHODIMP_(ULONG)    Release() {
    00142         if  (--m_ulcReferences)
    00143             return  m_ulcReferences;
    00144
    00145         delete  this;
    00146         return  0L;
    00147     }
    00148
    00149     //  IContextMenu methods
    00150     STDMETHODIMP    QueryContextMenu(HMENU hMenu, UINT indexMenu,
    00151                                      UINT idCmdFirst, UINT idCmdLast,
    00152                                      UINT uFlags);
    00153
    00154     STDMETHODIMP    InvokeCommand(LPCMINVOKECOMMANDINFO lpcmi);
    00155
    00156     STDMETHODIMP    GetCommandString(UINT_PTR idCmd, UINT uFlags,
    00157                                      UINT FAR *reserved, LPSTR pszName,
    00158                                      UINT cchMax);
    00159
    00160     //  IShellExtInit methods
    00161     STDMETHODIMP    Initialize(LPCITEMIDLIST pIDFolder, LPDATAOBJECT pDataObj,
    00162                                HKEY hKeyID);
    00163
    00164     //  IExtractIcon methods
    00165     STDMETHODIMP    GetIconLocation(UINT uFlags, LPTSTR szIconFile, UINT cchMax,
    00166                                     int *piIndex, UINT *pwFlags);
    00167
    00168     STDMETHODIMP    Extract(LPCTSTR pszFile, UINT nIconIndex,
    00169                             HICON *phiconLarge, HICON *phiconSmall,
    00170                             UINT nIconSize);
    00171
    00172     //  IPersistFile methods- note that (as the OLE documentation says) only
    00173     //  Load ever gets used.  GetClassID is from IPersist, from which
    00174     //  IPersistFile is derived.  We fail everything we don't expect to see
    00175     //  called.
    00176
    00177     STDMETHODIMP    GetClassID(LPCLSID lpClassID) { return E_FAIL; }
    00178
    00179     STDMETHODIMP    IsDirty() { return S_FALSE; }
    00180
    00181     STDMETHODIMP    Load(LPCOLESTR lpszFileName, DWORD grfMode);
    00182
    00183     STDMETHODIMP    Save(LPCOLESTR lpszFileName, BOOL fRemember) {
    00184         return  E_FAIL;
    00185     }
    00186
    00187     STDMETHODIMP    SaveCompleted(LPCOLESTR lpszFileName) { return E_FAIL; }
    00188
    00189     STDMETHODIMP    GetCurFile(LPOLESTR FAR* lplpszFileName) {
    00190         return  E_FAIL;
    00191     }
    00192
    00193     //  IShellPropSheetExt methods
    00194     STDMETHODIMP    AddPages(LPFNADDPROPSHEETPAGE lpfnAddPage, LPARAM lParam);
    00195
    00196     STDMETHODIMP    ReplacePage(UINT uPageID,
    00197                                 LPFNADDPROPSHEETPAGE lpfnReplaceWith,
    00198                                 LPARAM lParam) { return E_FAIL; }
    00199
    00200 };
    00201