IShellLink接口的MFC封装类

复制代码
//Class which contains all the parameters related to shortcut
class CShellLinkInfo : public CObject
{
public:
//Constructors / Destructors
  CShellLinkInfo();
  CShellLinkInfo(
const CShellLinkInfo& sli);
  
~CShellLinkInfo();

//Methods 
  CShellLinkInfo& operator=(const CShellLinkInfo& sli);

//Diagnostic support
#ifdef _DEBUG
  
virtual void Dump(CDumpContext& dc);
#endif

//Variables
  CString      m_sTarget;
  LPITEMIDLIST m_pidl;
  CString      m_sArguments;
  CString      m_sDescription;
  WORD         m_wHotkey;
  CString      m_sIconLocation;
  
int          m_nIconIndex;
  
int          m_nShowCmd;
  CString      m_sWorkingDirectory;
}
;


//Class which wraps standard shortcuts i.e. IShellLink
class CShellLink
{
public:
//Constructors / Destructors
  CShellLink();
  
virtual ~CShellLink();

//Methods
  BOOL Create(const CShellLinkInfo& sli);
  BOOL Load(
const CString& sFilename);
  BOOL Save(
const CString& sFilename);
  BOOL Resolve(CWnd
* pParentWnd, DWORD dwFlags);

//Accessors
  CString      GetPath() const;
  LPITEMIDLIST GetPathIDList() 
const;
  CString      GetArguments() 
const;
  CString      GetDescription() 
const;
  WORD         GetHotKey() 
const;
  CString      GetIconLocation() 
const;
  
int          GetIconLocationIndex() const;
  
int          GetShowCommand() const;
  CString      GetWorkingDirectory() 
const;

//Mutators
  void SetPath(const CString& sPath);
  
void SetPathIDList(LPITEMIDLIST pidl);
  
void SetArguments(const CString& sArguments);
  
void SetDescription(const CString& sDescription);
  
void SetHotKey(WORD wHotkey);
  
void SetIconLocation(const CString& sIconLocation);
  
void SetIconLocationIndex(int nIconIndex);
  
void SetShowCommand(int nShowCmd);
  
void SetWorkingDirectory(const CString& sWorkingDirectory);

protected:
  BOOL Initialise();
  CShellLinkInfo m_sli;
  IShellLink
*    m_psl;
  IPersistFile
*  m_ppf;
  BOOL           m_bAttemptedInitialise;
}
;


//Class which wraps internet shortcuts i.e. IUniformResourceLocator
class CUrlShellLink : public CShellLink
{
public:
//Constructors / Destructors
  CUrlShellLink();
  
virtual ~CUrlShellLink();

//Methods
  BOOL Create(const CShellLinkInfo& sli);
  BOOL Load(
const CString& sFilename);
  BOOL Save(
const CString& sFilename);
  BOOL Invoke(CWnd
* pParentWnd, DWORD dwFlags, const CString& sVerb);

//Following 4 functions just ASSERT if called
  CString GetArguments() const;
  LPITEMIDLIST GetPathIDList() 
const;
  
void SetArguments(const CString& sArguments);
  
void SetPathIDList(LPITEMIDLIST pidl);

protected:
  BOOL Initialise();
  IUniformResourceLocator
* m_pURL;
}
;
复制代码

实现文件

posted on   Phinecos(洞庭散人)  阅读(2463)  评论(0编辑  收藏  举报

编辑推荐:
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
阅读排行:
· 周边上新:园子的第一款马克杯温暖上架
· Open-Sora 2.0 重磅开源!
· .NET周刊【3月第1期 2025-03-02】
· 分享 3 个 .NET 开源的文件压缩处理库,助力快速实现文件压缩解压功能!
· [AI/GPT/综述] AI Agent的设计模式综述
历史上的今天:
2007-07-06 SWT Designer 6.0安装小记

导航

统计

点击右上角即可分享
微信分享提示