1
0

ConfigCOM.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #ifndef NULLSOFT_NU_CONFIGCOMH
  2. #define NULLSOFT_NU_CONFIGCOMH
  3. #include <ocidl.h>
  4. #include <map>
  5. class ConfigCOM : public IDispatch
  6. {
  7. protected:
  8. ConfigCOM();
  9. ~ConfigCOM();
  10. public:
  11. static HRESULT CreateInstanceW(const wchar_t *pszName, const char *pszPath, ConfigCOM **config);
  12. static HRESULT CreateInstanceA(const char *pszName, const char *pszPath, ConfigCOM **config);
  13. public:
  14. /* IUnknown */
  15. STDMETHOD(QueryInterface)(REFIID riid, PVOID *ppvObject);
  16. STDMETHOD_(ULONG, AddRef)(void);
  17. STDMETHOD_(ULONG, Release)(void);
  18. /* IDispatch */
  19. STDMETHOD (GetIDsOfNames)(REFIID riid, OLECHAR FAR* FAR* rgszNames, unsigned int cNames, LCID lcid, DISPID FAR* rgdispid);
  20. STDMETHOD (GetTypeInfo)(unsigned int itinfo, LCID lcid, ITypeInfo FAR* FAR* pptinfo);
  21. STDMETHOD (GetTypeInfoCount)(unsigned int FAR * pctinfo);
  22. STDMETHOD (Invoke)(DISPID dispid, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS FAR *pdispparams, VARIANT FAR *pvarResult, EXCEPINFO FAR * pexecinfo, unsigned int FAR *puArgErr);
  23. void SetPathA(const char *pszPath);
  24. BOOL IsEqual(const char *pszName);
  25. BOOL WriteStringAnsi(const char *key, const char *string);
  26. BOOL WriteString(const char *key, const wchar_t *string);
  27. BOOL WriteBool(const char *key, BOOL value);
  28. BOOL WriteLong(const char *key, long value);
  29. DWORD ReadString(const char *key, const char *defaultVal, char *buffer, int bufferMax);
  30. LONG ReadLong(const char *key, long defaultVal);
  31. BOOL ReadBool(const char *key, BOOL defaultVal);
  32. BSTR ReadBSTR(const char *key, const wchar_t *defaultVal);
  33. private:
  34. typedef std::map<long, char*> ConfigMap;
  35. ConfigMap config_map;
  36. long index;
  37. char *pathA;
  38. char *nameA;
  39. LONG ref;
  40. };
  41. #endif