Folder.h
上传用户:hy_wanghao
上传日期:2007-01-08
资源大小:279k
文件大小:6k
- // Folder.h : Declaration of the CFolder
- //
- // Written by Bjarke Viksoe (bjarke@viksoe.dk)
- // Copyright (c) 2001 Bjarke Viksoe.
- //
- // This code may be used in compiled form in any way you desire. This
- // file may be redistributed by any means PROVIDING it is
- // not sold for profit without the authors written consent, and
- // providing that this notice and the authors name is included.
- //
- // This file is provided "as is" with no expressed or implied warranty.
- // The author accepts no liability if it causes any damage to you or your
- // computer whatsoever. It's free, so don't hassle me about it.
- //
- // Beware of bugs.
- #ifndef __FOLDER_H_
- #define __FOLDER_H_
- #include "resource.h" // main symbols
- /////////////////////////////////////////////////////////////////////////////
- // CFolder
- class ATL_NO_VTABLE CFolder :
- public CComObjectRootEx<CComSingleThreadModel>,
- public CComCoClass<CFolder, &CLSID_Folder>,
- public IShellFolderImpl<CFolder, PIDLDATA>,
- public IQueryInfo
- {
- public:
- HRESULT FinalConstruct();
- void FinalRelease();
- DECLARE_NOT_AGGREGATABLE(CFolder)
- DECLARE_PROTECT_FINAL_CONSTRUCT()
- BEGIN_COM_MAP(CFolder)
- COM_INTERFACE_ENTRY_IID(IID_IShellFolder,IShellFolder)
- COM_INTERFACE_ENTRY_IID(IID_IPersistFolder,IPersistFolder)
- COM_INTERFACE_ENTRY_IID(IID_IQueryInfo,IQueryInfo)
- COM_INTERFACE_ENTRY(IPersist)
- END_COM_MAP()
- // CFolder
- public:
- static HRESULT WINAPI UpdateRegistry(BOOL bRegister);
- private:
- static BOOL _FindAmigaDrive(LPTSTR pstrDevice);
- static HRESULT _RegisterObject(CLSID clsid, UINT id, BOOL bRegister, _ATL_REGMAP_ENTRY *rm, LPCTSTR pstrDeviceName);
- // IShellFolder
- public:
- STDMETHOD(CompareIDs)(LPARAM lParam, LPCITEMIDLIST, LPCITEMIDLIST);
- STDMETHOD(GetDisplayNameOf)(LPCITEMIDLIST pidl, DWORD dwReserved, LPSTRRET lpName);
- STDMETHOD(GetAttributesOf)(UINT, LPCITEMIDLIST*, LPDWORD rgfInOut);
- STDMETHOD(EnumObjects)(HWND hWnd, DWORD dw, LPENUMIDLIST* ppRetVal);
- STDMETHOD(BindToObject)(LPCITEMIDLIST pidl, LPBC, REFIID riid, LPVOID* ppvOut);
- STDMETHOD(GetUIObjectOf)(HWND, UINT, LPCITEMIDLIST*, REFIID, LPUINT, LPVOID*);
- STDMETHOD(CreateViewObject)(HWND hwndOwner, REFIID riid, LPVOID* ppvOut);
- STDMETHOD(SetNameOf)(HWND, LPCITEMIDLIST, LPCOLESTR, DWORD, LPITEMIDLIST*);
- // IQueryInfo
- public:
- STDMETHOD(GetInfoTip)(DWORD dwFlags,LPWSTR *ppwszTip);
- STDMETHOD(GetInfoFlags)(DWORD *pdwFlags);
- // Implementation
- public:
- HRESULT _CreateShellFolderView(LPVOID *ppvObj);
- public:
- HRESULT _Init(LPCITEMIDLIST Master, LPCITEMIDLIST Custom, LPCITEMIDLIST pidl);
- HRESULT _BindToObject(LPCITEMIDLIST pidl, CComObject<CFolder> **pFolder);
- HRESULT _BindToParent(CComObject<CFolder> **pFolder);
- private:
- LPITEMIDLIST _CreateItem(LPCTSTR pstrName,
- LPCTSTR pstrComment,
- PIDLTYPE pidlType,
- int DosType,
- DWORD dwSize,
- SYSTEMTIME ftTime,
- DWORD dwAccess,
- DWORD dwEntryFlags);
- void _AddFolderToEnum(CPidl &pidl, List *cell, DWORD dwFlags, DWORD dwEntryFlags);
- void _AddDeletedToEnum(CPidl &pidl, List *cell, SECTNUM nDirSector, DWORD dwFlags, DWORD dwEntryFlags);
- //
- public:
- static short _CompareItems(short iColumn, LPCPIDLDATA pData1, LPCPIDLDATA pData2);
- //
- HRESULT _OpenAmigaDevice(LPCITEMIDLIST pidlPath,
- BOOL bReadOnly,
- LPCITEMIDLIST pidlStartFolder,
- CAdfDevice &dev,
- CAdfVolume &vol);
- //
- BOOL _IsDroppedPathSame(LPDATAOBJECT pDataObj);
- BOOL _IsViewWindow(HWND hWnd);
- BOOL _SendViewMessage(HWND hWnd, UINT iMsg, WPARAM wParam=0, LPARAM lParam=0);
- HRESULT _DoDrop(LPDATAOBJECT pDataObject, DWORD dwDropEffect);
- HRESULT _DoDrop_HDROP(HGLOBAL hMem, DWORD dwDropEffect);
- HRESULT _DoDrop_FILEDESCRIPTOR(HGLOBAL hMem, IDataObject *pDataObject, DWORD dwDropEffect);
- public:
- typedef enum {
- FILEOP_CANCEL = 1,
- FILEOP_YESTOALL = 2,
- FILEOP_UNIQUENAME = 4,
- FILEOP_DONTTRUNCATE = 8,
- FILEOP_SILENT = 16,
- };
- HRESULT _MoveFile(LPCTSTR pstrSource, LPCTSTR pstrDestPath, LPCTSTR pstrDestName, LPDWORD pdwFileOpFlags);
- HRESULT _CopyFile(LPCTSTR pstrSource, LPCTSTR pstrDestPath, LPCTSTR pstrDestName, LPDWORD pdwFileOpFlags);
- HRESULT _CreateFolder(LPTSTR pstrDestName, LPDWORD pdwFileOpFlags);
- HRESULT _RemoveDirectory(CAdfVolume &vol, LPCTSTR pstrPath);
- HRESULT _DeleteFiles(LPCITEMIDLIST *pidls, UINT nCount);
- HRESULT _UnDeleteFiles(LPCITEMIDLIST *pidls, UINT nCount);
- HRESULT _RenameFile(LPCITEMIDLIST pidlOld, LPCITEMIDLIST pidlNew);
- UINT _ConfirmDelete(LPCITEMIDLIST *pidls, UINT nCount, LPDWORD pdwFileOpFlags);
- private:
- UINT _CheckFileCollision(CAdfVolume &vol, LPCTSTR pstrFileName, LPDWORD pdwCopyOpFlags, BOOL *pbIsDuplicate);
- BOOL _CheckForDiskExchaustion(CAdfVolume &vol, DWORD dwFileSize, LPDWORD pdwFileOpFlags);
- BOOL _FindUniqueFileName(CAdfVolume &vol, LPTSTR pstrName);
- BOOL _ValidateFileName(LPTSTR pstrFileName, LPDWORD pdwFileOpFlags);
- SYSTEMTIME _ConvertEntryTime(Entry *entry);
- // Attributes
- public:
- CPidl m_pidlPath;
- DWORD m_dwFolderID;
- bool m_bErrorShown;
- static DWORD m_dwShellAttributes;
- };
- // Specify which options the namespace supports
- __declspec(selectany) DWORD CFolder::m_dwShellAttributes =
- SFGAO_FOLDER |
- SFGAO_HASSUBFOLDER |
- SFGAO_FILESYSTEM |
- SFGAO_DROPTARGET |
- SFGAO_BROWSABLE;
- #endif //__FOLDER_H_