Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

158 lines
3.9 KiB

  1. #ifndef __FSP_H_
  2. #define __FSP_H_
  3. #include "resource.h"
  4. #include "atlsnap.h"
  5. #include <shlobj.h>
  6. #define LOGKEY TEXT("Software\\Microsoft\\Fax\\Device Providers\\Microsoft Modem Device Provider")
  7. #define LOGLEVEL TEXT("ModemLogLevel")
  8. #define LOGLOCATION TEXT("ModemLogLocation")
  9. #define LOGGING_NONE 0x0
  10. #define LOGGING_ERRORS 0x1
  11. #define LOGGING_ALL 0x100
  12. class CFSPPage : public CPropertyPageImpl<CFSPPage>
  13. {
  14. private:
  15. BOOL m_bChanged;
  16. DWORD m_LoggingLevel;
  17. LPWSTR m_LoggingDirectory;
  18. HKEY m_LogKey;
  19. public :
  20. CFSPPage(TCHAR* pTitle = NULL) : CPropertyPageImpl<CFSPPage> (pTitle)
  21. {
  22. m_bChanged = FALSE;
  23. m_LogKey = OpenRegistryKey(HKEY_LOCAL_MACHINE,LOGKEY,FALSE,0);
  24. if (!m_LogKey) {
  25. m_LoggingLevel = 0;
  26. m_LoggingDirectory = NULL;
  27. } else {
  28. m_LoggingLevel = GetRegistryDword(m_LogKey,LOGLEVEL);
  29. m_LoggingDirectory = GetRegistryString(m_LogKey,LOGLOCATION,TEXT(""));
  30. }
  31. }
  32. ~CFSPPage() {
  33. if (m_LoggingDirectory) {
  34. MemFree(m_LoggingDirectory);
  35. }
  36. if (m_LogKey) {
  37. RegCloseKey(m_LogKey);
  38. }
  39. }
  40. enum { IDD = IDD_FSP };
  41. BEGIN_MSG_MAP(CFSPPage)
  42. MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
  43. COMMAND_ID_HANDLER(IDC_LOG_NONE, DisableLogging);
  44. COMMAND_ID_HANDLER(IDC_LOG_ERRORS, EnableLogging);
  45. COMMAND_ID_HANDLER(IDC_LOG_ALL, EnableLogging);
  46. COMMAND_ID_HANDLER(IDC_LOGBROWSE, OnBrowseDir);
  47. CHAIN_MSG_MAP(CPropertyPageImpl<CFSPPage>)
  48. END_MSG_MAP()
  49. LRESULT DisableLogging(INT code, INT id, HWND hwnd, BOOL& bHandled);
  50. LRESULT EnableLogging(INT code, INT id, HWND hwnd, BOOL& bHandled);
  51. LRESULT OnBrowseDir(INT code, INT id, HWND hwnd, BOOL& bHandled);
  52. LRESULT OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
  53. VOID SetChangedFlag( BOOL Flag );
  54. BOOL OnApply();
  55. private:
  56. BOOL BrowseForDirectory();
  57. BOOL ValidateLogLocation();
  58. };
  59. class CFSPData : public CSnapInDataInterface< CFSPData, TRUE >
  60. {
  61. static const GUID* m_NODETYPE;
  62. static const TCHAR* m_SZNODETYPE;
  63. static const TCHAR* m_SZDISPLAY_NAME;
  64. static const CLSID* m_SNAPIN_CLASSID;
  65. public:
  66. static CComPtr<IControlbar> m_spControlBar;
  67. public:
  68. CFSPData()
  69. {
  70. }
  71. ~CFSPData()
  72. {
  73. }
  74. STDMETHOD(CreatePropertyPages)(LPPROPERTYSHEETCALLBACK lpProvider,
  75. long handle, IUnknown* pUnk)
  76. {
  77. TCHAR Title[MAX_TITLE_LEN];
  78. LoadString(_Module.GetModuleInstance(),IDS_TITLE,Title,sizeof(Title));
  79. CFSPPage* pPage = new CFSPPage(Title);
  80. lpProvider->AddPage(pPage->Create());
  81. return S_OK;
  82. }
  83. STDMETHOD(QueryPagesFor)(void)
  84. {
  85. return S_OK;
  86. }
  87. void* GetNodeType()
  88. {
  89. return (void*)m_NODETYPE;
  90. }
  91. void* GetSZNodeType()
  92. {
  93. return (void*)m_SZNODETYPE;
  94. }
  95. void* GetDisplayName()
  96. {
  97. return (void*)m_SZDISPLAY_NAME;
  98. }
  99. void* GetSnapInCLSID()
  100. {
  101. return (void*)m_SNAPIN_CLASSID;
  102. }
  103. IDataObject* m_pDataObject;
  104. BOOL InitDataClass(IDataObject* pDataObject)
  105. {
  106. m_pDataObject = pDataObject;
  107. // The default code stores off the pointer to the Dataobject the class is wrapping
  108. // at the time.
  109. // Alternatively you could convert the dataobject to the internal format
  110. // it represents and store that information
  111. return TRUE;
  112. }
  113. };
  114. class CFSP : public CSnapinObjectRootEx<CComSingleThreadModel>,
  115. public IExtendPropertySheetImpl<CFSP>,
  116. public CComCoClass<CFSP, &CLSID_FSP>
  117. {
  118. public:
  119. EXTENSION_SNAPIN_DATACLASS(CFSPData)
  120. BEGIN_EXTENSION_SNAPIN_NODEINFO_MAP(CFSP)
  121. EXTENSION_SNAPIN_NODEINFO_ENTRY(CFSPData)
  122. END_EXTENSION_SNAPIN_NODEINFO_MAP()
  123. BEGIN_COM_MAP(CFSP)
  124. COM_INTERFACE_ENTRY(IExtendPropertySheet)
  125. END_COM_MAP()
  126. DECLARE_REGISTRY_RESOURCEID(IDR_FSP)
  127. DECLARE_NOT_AGGREGATABLE(CFSP)
  128. };
  129. #endif