home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / sdk / winui / shell / shellext / shellext.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-05-18  |  5.9 KB  |  165 lines

  1. //
  2. // The class ID of this Shell extension class.
  3. //
  4. // class id:  87b9bd00-c65c-11cd-a259-00dd010e8c28
  5. //
  6. //
  7. // NOTE!!!  If you use this shell extension as a starting point, 
  8. //          you MUST change the GUID below.  Simply run UUIDGEN.EXE
  9. //          to generate a new GUID.
  10. //
  11.                                   
  12. #define ODS(sz) OutputDebugString(sz)
  13.  
  14. #ifndef _SHELLEXT_H
  15. #define _SHELLEXT_H
  16.  
  17. DEFINE_GUID(CLSID_ShellExtension, 0x87b9bd00L, 0xc65c, 0x11cd, 0xa2, 0x59, 0x00, 0xdd, 0x01, 0x0e, 0x8c, 0x28 );
  18.  
  19. // this class factory object creates context menu handlers for Windows 95 shell
  20. class CShellExtClassFactory : public IClassFactory
  21. {
  22. protected:
  23.     ULONG    m_cRef;
  24.  
  25. public:
  26.     CShellExtClassFactory();
  27.     ~CShellExtClassFactory();
  28.  
  29.     //IUnknown members
  30.     STDMETHODIMP            QueryInterface(REFIID, LPVOID FAR *);
  31.     STDMETHODIMP_(ULONG)    AddRef();
  32.     STDMETHODIMP_(ULONG)    Release();
  33.  
  34.     //IClassFactory members
  35.     STDMETHODIMP        CreateInstance(LPUNKNOWN, REFIID, LPVOID FAR *);
  36.     STDMETHODIMP        LockServer(BOOL);
  37.  
  38. };
  39. typedef CShellExtClassFactory *LPCSHELLEXTCLASSFACTORY;
  40.  
  41. // this is the actual OLE Shell context menu handler
  42. class CShellExt : public IContextMenu, 
  43.                          IShellExtInit, 
  44.                          IExtractIcon, 
  45.                          IPersistFile, 
  46.                          IShellPropSheetExt,
  47.                          ICopyHook
  48. {
  49. public:
  50.     char         m_szPropSheetFileUserClickedOn[MAX_PATH];  //This will be the same as
  51.                                                             //m_szFileUserClickedOn but I include
  52.                                                             //here for demonstration.  That is,
  53.                                                             //m_szFileUserClickedOn gets filled in
  54.                                                             //as a result of this sample supporting
  55.                                                             //the IExtractIcon and IPersistFile
  56.                                                             //interface.  If this sample *only* showed
  57.                                                             //a Property Sheet extesion, you would
  58.                                                             //need to use the method I do here to find
  59.                                                             //the filename the user clicked on.
  60.  
  61.  
  62. protected:
  63.     ULONG        m_cRef;
  64.     LPDATAOBJECT m_pDataObj;
  65.     char         m_szFileUserClickedOn[MAX_PATH];
  66.  
  67.     STDMETHODIMP DoGAKMenu1(HWND hParent, 
  68.                             LPCSTR pszWorkingDir, 
  69.                             LPCSTR pszCmd,
  70.                             LPCSTR pszParam, 
  71.                             int iShowCmd);
  72.  
  73.     STDMETHODIMP DoGAKMenu2(HWND hParent, 
  74.                             LPCSTR pszWorkingDir, 
  75.                             LPCSTR pszCmd,
  76.                             LPCSTR pszParam, 
  77.                             int iShowCmd);
  78.  
  79.     STDMETHODIMP DoGAKMenu3(HWND hParent, 
  80.                             LPCSTR pszWorkingDir, 
  81.                             LPCSTR pszCmd,
  82.                             LPCSTR pszParam, 
  83.                             int iShowCmd);
  84.  
  85.     STDMETHODIMP DoGAKMenu4(HWND hParent, 
  86.                             LPCSTR pszWorkingDir, 
  87.                             LPCSTR pszCmd,
  88.                             LPCSTR pszParam, 
  89.                             int iShowCmd);
  90. public:
  91.     CShellExt();
  92.     ~CShellExt();
  93.  
  94.     //IUnknown members
  95.     STDMETHODIMP            QueryInterface(REFIID, LPVOID FAR *);
  96.     STDMETHODIMP_(ULONG)    AddRef();
  97.     STDMETHODIMP_(ULONG)    Release();
  98.  
  99.     //IShell members
  100.     STDMETHODIMP            QueryContextMenu(HMENU hMenu,
  101.                                              UINT indexMenu, 
  102.                                              UINT idCmdFirst,
  103.                                              UINT idCmdLast, 
  104.                                              UINT uFlags);
  105.  
  106.     STDMETHODIMP            InvokeCommand(LPCMINVOKECOMMANDINFO lpcmi);
  107.  
  108.     STDMETHODIMP            GetCommandString(UINT idCmd, 
  109.                                              UINT uFlags, 
  110.                                              UINT FAR *reserved, 
  111.                                              LPSTR pszName, 
  112.                                              UINT cchMax);
  113.  
  114.     //IShellExtInit methods
  115.     STDMETHODIMP            Initialize(LPCITEMIDLIST pIDFolder, 
  116.                                        LPDATAOBJECT pDataObj, 
  117.                                        HKEY hKeyID);
  118.  
  119.     //IExtractIcon methods
  120.     STDMETHODIMP GetIconLocation(UINT   uFlags,
  121.                                  LPSTR  szIconFile,
  122.                                  UINT   cchMax,
  123.                                  int   *piIndex,
  124.                                  UINT  *pwFlags);
  125.  
  126.     STDMETHODIMP Extract(LPCSTR pszFile,
  127.                          UINT   nIconIndex,
  128.                          HICON  *phiconLarge,
  129.                          HICON  *phiconSmall,
  130.                          UINT   nIconSize);
  131.  
  132.     //IPersistFile methods
  133.     STDMETHODIMP GetClassID(LPCLSID lpClassID);
  134.  
  135.     STDMETHODIMP IsDirty();
  136.  
  137.     STDMETHODIMP Load(LPCOLESTR lpszFileName, DWORD grfMode);
  138.  
  139.     STDMETHODIMP Save(LPCOLESTR lpszFileName, BOOL fRemember);
  140.  
  141.     STDMETHODIMP SaveCompleted(LPCOLESTR lpszFileName);
  142.  
  143.     STDMETHODIMP GetCurFile(LPOLESTR FAR* lplpszFileName);
  144.  
  145.     //IShellPropSheetExt methods
  146.     STDMETHODIMP AddPages(LPFNADDPROPSHEETPAGE lpfnAddPage, LPARAM lParam);
  147.     
  148.     STDMETHODIMP ReplacePage(UINT uPageID, 
  149.                              LPFNADDPROPSHEETPAGE lpfnReplaceWith, 
  150.                              LPARAM lParam);
  151.  
  152.     //ICopyHook method
  153.     STDMETHODIMP_(UINT) CopyCallback(HWND hwnd, 
  154.                                      UINT wFunc, 
  155.                                      UINT wFlags, 
  156.                                      LPCSTR pszSrcFile, 
  157.                                      DWORD dwSrcAttribs,
  158.                                      LPCSTR pszDestFile, 
  159.                                      DWORD dwDestAttribs);
  160.  
  161. };
  162. typedef CShellExt *LPCSHELLEXT;
  163.  
  164. #endif // _SHELLEXT_H
  165.