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.

135 lines
3.1 KiB

  1. //
  2. // Microsoft Windows Media Technologies
  3. // � 1999 Microsoft Corporation. All rights reserved.
  4. //
  5. // Refer to your End User License Agreement for details on your rights/restrictions to use these sample files.
  6. //
  7. // MSHDSP.DLL is a sample WMDM Service Provider(SP) that enumerates fixed drives.
  8. // This sample shows you how to implement an SP according to the WMDM documentation.
  9. // This sample uses fixed drives on your PC to emulate portable media, and
  10. // shows the relationship between different interfaces and objects. Each hard disk
  11. // volume is enumerated as a device and directories and files are enumerated as
  12. // Storage objects under respective devices. You can copy non-SDMI compliant content
  13. // to any device that this SP enumerates. To copy an SDMI compliant content to a
  14. // device, the device must be able to report a hardware embedded serial number.
  15. // Hard disks do not have such serial numbers.
  16. //
  17. // To build this SP, you are recommended to use the MSHDSP.DSP file under Microsoft
  18. // Visual C++ 6.0 and run REGSVR32.EXE to register the resulting MSHDSP.DLL. You can
  19. // then build the sample application from the WMDMAPP directory to see how it gets
  20. // loaded by the application. However, you need to obtain a certificate from
  21. // Microsoft to actually run this SP. This certificate would be in the KEY.C file
  22. // under the INCLUDE directory for one level up.
  23. #include "hdspPCH.h"
  24. #include "wmdmlog_i.c"
  25. BOOL fIsLoggingEnabled( VOID )
  26. {
  27. static BOOL fEnabled = FALSE;
  28. HRESULT hr;
  29. IWMDMLogger *pLogger = NULL;
  30. static BOOL fChecked = FALSE;
  31. if( !fChecked )
  32. {
  33. fChecked = TRUE;
  34. hr = CoCreateInstance(
  35. CLSID_WMDMLogger,
  36. NULL,
  37. CLSCTX_INPROC_SERVER,
  38. IID_IWMDMLogger,
  39. (void**)&pLogger
  40. );
  41. CORg( hr );
  42. hr = pLogger->IsEnabled( &fEnabled );
  43. CORg( hr );
  44. }
  45. Error:
  46. if( NULL != pLogger )
  47. {
  48. pLogger->Release();
  49. pLogger = NULL;
  50. }
  51. return fEnabled;
  52. }
  53. HRESULT hrLogString(LPSTR pszMessage, HRESULT hrSev)
  54. {
  55. HRESULT hr=S_OK;
  56. IWMDMLogger *pLogger = NULL;
  57. if( !fIsLoggingEnabled() )
  58. {
  59. return S_FALSE;
  60. }
  61. hr = CoCreateInstance(
  62. CLSID_WMDMLogger,
  63. NULL,
  64. CLSCTX_INPROC_SERVER,
  65. IID_IWMDMLogger,
  66. (void**)&pLogger
  67. );
  68. CORg( hr );
  69. hr = pLogger->LogString(
  70. ( FAILED(hrSev) ? WMDM_LOG_SEV_ERROR : WMDM_LOG_SEV_INFO ),
  71. "LyraSP",
  72. pszMessage
  73. );
  74. CORg( hr );
  75. Error:
  76. if( pLogger )
  77. {
  78. pLogger->Release();
  79. }
  80. return hr;
  81. }
  82. HRESULT hrLogDWORD(LPSTR pszFormat, DWORD dwValue, HRESULT hrSev)
  83. {
  84. HRESULT hr=S_OK;
  85. IWMDMLogger *pLogger = NULL;
  86. if( !fIsLoggingEnabled() )
  87. {
  88. return S_FALSE;
  89. }
  90. hr = CoCreateInstance(
  91. CLSID_WMDMLogger,
  92. NULL,
  93. CLSCTX_INPROC_SERVER,
  94. IID_IWMDMLogger,
  95. (void**)&pLogger
  96. );
  97. CORg( hr );
  98. hr = pLogger->LogDword(
  99. ( FAILED(hrSev) ? WMDM_LOG_SEV_ERROR : WMDM_LOG_SEV_INFO ),
  100. "LyraSP",
  101. pszFormat,
  102. dwValue
  103. );
  104. CORg( hr );
  105. Error:
  106. if( pLogger )
  107. {
  108. pLogger->Release();
  109. }
  110. return hr;
  111. }