1 #pragma once 2 class CRegFileRelate 3 { 4 public: 5 CRegFileRelate(); 6 ~CRegFileRelate(); 7 8 void SetModelPath(LPCTSTR model_path); 9 void SetAppName(LPCTSTR app_name); 10 11 //添加一个文件类型的关联 12 //file_ext: 要关联的文件扩展名 13 bool AddFileTypeRelate(LPCTSTR file_ext, LPCTSTR ico_path = nullptr, bool default_icon = false, LPCTSTR description = NULL); 14 bool AddFileTypeRelate(LPCTSTR file_ext, int ico_index, bool default_icon = false, LPCTSTR description = NULL); 15 //判断一个文件类型是否已关联 16 bool IsFileTypeRelated(LPCTSTR file_ext); 17 //删除一个文件类型的关联 18 bool DeleteFileTypeRelate(LPCTSTR file_ext); 19 20 //获取所有已关联的类型扩展名 21 bool GetAllRelatedExtensions(std::vector<wstring>& extensions); 22 23 private: 24 bool OpenItem(CRegKey& key, LPCTSTR item_str); 25 26 private: 27 CString m_model_path; 28 CString m_app_name = APP_NAME; 29 }; 30 31