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.

62 lines
1.6 KiB

  1. /************************************************************************************************
  2. Copyright (c) 2001 Microsoft Corporation
  3. Module Name: MetabaseUtil.h
  4. Notes:
  5. History:
  6. ************************************************************************************************/
  7. #ifndef __METABASEUTIL_H_
  8. #define __METABASEUTIL_H_
  9. #include <comdef.h>
  10. #include <Iads.h>
  11. #include <Adshlp.h>
  12. HRESULT GetDefaultMailRoot( LPWSTR psMailRoot, DWORD dwSize )
  13. {
  14. if ( NULL == psMailRoot )
  15. return E_INVALIDARG;
  16. if ( 0 == dwSize )
  17. return TYPE_E_BUFFERTOOSMALL;
  18. HRESULT hr;
  19. WCHAR sBuffer[MAX_PATH];
  20. _variant_t _v;
  21. CComPtr<IADs> spIADs;
  22. wcscpy( sBuffer, L"IIS://localhost/SMTPSVC/1" );
  23. hr = ADsGetObject( sBuffer, IID_IADs, reinterpret_cast<LPVOID*>( &spIADs ));
  24. if ( SUCCEEDED( hr ))
  25. {
  26. hr = spIADs->Get( L"PickupDirectory", &_v );
  27. if SUCCEEDED( hr )
  28. {
  29. if ( VT_BSTR == V_VT( &_v ))
  30. {
  31. if ( wcslen( V_BSTR( &_v )) + 9 < sizeof( sBuffer ) / sizeof( WCHAR ))
  32. {
  33. wcscpy( sBuffer, V_BSTR( &_v ));
  34. WCHAR *ps = wcsrchr( sBuffer, L'\\' );
  35. if ( NULL != ps )
  36. {
  37. *ps = 0x0;
  38. wcscat( sBuffer, L"\\Mailbox" );
  39. if ( wcslen( sBuffer ) < dwSize )
  40. wcscpy( psMailRoot, sBuffer );
  41. else
  42. hr = TYPE_E_BUFFERTOOSMALL;
  43. }
  44. else
  45. hr = E_UNEXPECTED;
  46. }
  47. else
  48. hr = DISP_E_BUFFERTOOSMALL;
  49. }
  50. }
  51. }
  52. return hr;
  53. }
  54. #endif //__METABASEUTIL_H_