Leaked source code of windows server 2003
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.

171 lines
4.0 KiB

  1. #include "stdafx.h"
  2. #include <iadmw.h>
  3. #include <inetcom.h>
  4. #include <logtype.h>
  5. #include <ilogobj.hxx>
  6. #include "logui.h"
  7. #include "uimsft.h"
  8. #include "LogGenPg.h"
  9. #include "logtools.h"
  10. #define OLE_NAME _T("Msft_Logging_UI")
  11. static const DWORD BASED_CODE _dwOleMisc = OLEMISC_INSIDEOUT | OLEMISC_CANTLINKINSIDE;
  12. extern HINSTANCE g_hInstance;
  13. CFacMsftLogUI::CFacMsftLogUI() :
  14. COleObjectFactory( CLSID_ASCLOGUI, RUNTIME_CLASS(CMsftCreator), TRUE, OLE_NAME )
  15. {
  16. }
  17. static const LPCTSTR rglpszServerRegister[] =
  18. {
  19. _T("%2\\CLSID\0") _T("%1"),
  20. _T("%2\\NotInsertable\0") _T(""),
  21. _T("CLSID\\%1\0") _T("%5"),
  22. _T("CLSID\\%1\\Verb\\0\0") _T("&Edit,0,2"),
  23. _T("CLSID\\%1\\NotInsertable\0") _T(""),
  24. _T("CLSID\\%1\\AuxUserType\\2\0") _T("%4"),
  25. _T("CLSID\\%1\\AuxUserType\\3\0") _T("%6"),
  26. _T("CLSID\\%1\\MiscStatus\0") _T("32"),
  27. NULL
  28. };
  29. static const LPCTSTR rglpszServerOverwriteDLL[] =
  30. {
  31. _T("%2\\CLSID\0") _T("%1"),
  32. _T("CLSID\\%1\\ProgID\0") _T("%2"),
  33. _T("CLSID\\%1\\InProcServer32\0") _T("%3"),
  34. _T("CLSID\\%1\\DefaultIcon\0") _T("%3,%7"),
  35. NULL
  36. };
  37. BOOL CFacMsftLogUI::UpdateRegistry( BOOL bRegister )
  38. {
  39. if (bRegister)
  40. if ( AfxOleRegisterServerClass(
  41. CLSID_ASCLOGUI,
  42. OLE_NAME,
  43. _T("LogUI msft"),
  44. _T("LogUI msft"),
  45. OAT_SERVER,
  46. (LPCTSTR *)rglpszServerRegister,
  47. (LPCTSTR *)rglpszServerOverwriteDLL
  48. ) )
  49. {
  50. return FSetObjectApartmentModel( CLSID_ASCLOGUI );
  51. }
  52. else
  53. return AfxOleUnregisterClass(m_clsid, OLE_NAME);
  54. return FALSE;
  55. }
  56. IMPLEMENT_DYNCREATE(CMsftCreator, CCmdTarget)
  57. LPUNKNOWN CMsftCreator::GetInterfaceHook(const void* piid)
  58. {
  59. return new CImpMsftLogUI;
  60. }
  61. CImpMsftLogUI::CImpMsftLogUI():
  62. m_dwRefCount(0)
  63. {
  64. AfxOleLockApp();
  65. }
  66. CImpMsftLogUI::~CImpMsftLogUI()
  67. {
  68. AfxOleUnlockApp();
  69. }
  70. HRESULT
  71. CImpMsftLogUI::OnProperties(OLECHAR * pocMachineName, OLECHAR * pocMetabasePath)
  72. {
  73. return OnPropertiesEx(pocMachineName, pocMetabasePath, NULL, NULL);
  74. }
  75. HRESULT
  76. CImpMsftLogUI::OnPropertiesEx(
  77. OLECHAR * pocMachineName,
  78. OLECHAR * pocMetabasePath,
  79. OLECHAR * pocUserName,
  80. OLECHAR * pocPassword
  81. )
  82. {
  83. AFX_MANAGE_STATE(_afxModuleAddrThis);
  84. // specify the resources to use
  85. HINSTANCE hOldRes = AfxGetResourceHandle();
  86. AfxSetResourceHandle( g_hInstance );
  87. // prepare the help
  88. ((CLoguiApp*)AfxGetApp())->PrepHelp( pocMetabasePath );
  89. CLogGeneral pageLogGeneral;
  90. CPropertySheet propsheet( IDS_SHEET_MSFT_TITLE );
  91. try
  92. {
  93. // prepare the pages
  94. pageLogGeneral.m_szMeta = pocMetabasePath;
  95. pageLogGeneral.m_szServer = pocMachineName;
  96. pageLogGeneral.m_szUserName = pocUserName;
  97. pageLogGeneral.m_szPassword = pocPassword;
  98. pageLogGeneral.szPrefix.LoadString(IDS_LOG_MSFT_PREFIX);
  99. pageLogGeneral.szSizePrefix.LoadString(IDS_LOG_SIZE_MSFT_PREFIX);
  100. pageLogGeneral.m_fLocalMachine = FIsLocalMachine(pocMachineName);
  101. propsheet.AddPage(&pageLogGeneral);
  102. propsheet.m_psh.dwFlags |= PSH_HASHELP;
  103. pageLogGeneral.m_psp.dwFlags |= PSP_HASHELP;
  104. propsheet.DoModal();
  105. }
  106. catch (CException * pException)
  107. {
  108. pException->Delete();
  109. }
  110. AfxSetResourceHandle(hOldRes);
  111. return NO_ERROR;
  112. }
  113. HRESULT CImpMsftLogUI::QueryInterface(REFIID riid, void **ppObject)
  114. {
  115. if ( riid==IID_IUnknown
  116. || riid==IID_LOGGINGUI
  117. || riid==IID_LOGGINGUI2
  118. || riid==CLSID_ASCLOGUI
  119. )
  120. {
  121. *ppObject = (ILogUIPlugin*) this;
  122. }
  123. else
  124. {
  125. return E_NOINTERFACE;
  126. }
  127. AddRef();
  128. return NO_ERROR;
  129. }
  130. ULONG CImpMsftLogUI::AddRef()
  131. {
  132. DWORD dwRefCount;
  133. dwRefCount = InterlockedIncrement((long *)&m_dwRefCount);
  134. return dwRefCount;
  135. }
  136. ULONG CImpMsftLogUI::Release()
  137. {
  138. DWORD dwRefCount;
  139. dwRefCount = InterlockedDecrement((long *)&m_dwRefCount);
  140. if (dwRefCount == 0)
  141. {
  142. delete this;
  143. }
  144. return dwRefCount;
  145. }