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.

101 lines
1.7 KiB

  1. // ShareInfo.cpp : Implementation of CShareInfo
  2. #include "stdafx.h"
  3. #include "openfiles.h"
  4. #include "ShareInfo.h"
  5. #include <Lm.h>
  6. #include <lmapibuf.h>
  7. #define SA_CIFS_CACHE_DISABLE 0x00000030
  8. #define SA_CIFS_CACHE_MANUAL_DOCS 0x00000000
  9. #define SA_CIFS_CACHE_AUTO_PROGRAMS 0x00000020
  10. #define SA_CIFS_CACHE_AUTO_DOCS 0x00000010
  11. /////////////////////////////////////////////////////////////////////////////
  12. // CShareInfo
  13. STDMETHODIMP CShareInfo::InterfaceSupportsErrorInfo(REFIID riid)
  14. {
  15. static const IID* arr[] =
  16. {
  17. &IID_IShareInfo
  18. };
  19. for (int i=0; i < sizeof(arr) / sizeof(arr[0]); i++)
  20. {
  21. if (InlineIsEqualGUID(*arr[i],riid))
  22. return S_OK;
  23. }
  24. return S_FALSE;
  25. }
  26. STDMETHODIMP CShareInfo::SetShareInfo( BSTR bstrShareName, DWORD dwCache )
  27. {
  28. HRESULT hr = S_OK;
  29. try
  30. {
  31. if ( !bstrShareName )
  32. {
  33. hr = E_FAIL;
  34. throw hr;
  35. }
  36. if (! ( dwCache == SA_CIFS_CACHE_DISABLE ||
  37. dwCache == SA_CIFS_CACHE_MANUAL_DOCS ||
  38. dwCache == SA_CIFS_CACHE_AUTO_PROGRAMS ||
  39. dwCache == SA_CIFS_CACHE_AUTO_DOCS ))
  40. {
  41. hr = E_FAIL;
  42. throw hr;
  43. }
  44. TCHAR FAR * pBuffer;
  45. DWORD cacheable;
  46. PSHARE_INFO_1005 s1005;
  47. USHORT maxLen;
  48. ZeroMemory( &s1005, sizeof(s1005) );
  49. if( NetShareGetInfo(NULL,
  50. bstrShareName,
  51. 1005,
  52. (LPBYTE*)&s1005))
  53. {
  54. hr = E_FAIL;
  55. throw hr;
  56. }
  57. s1005->shi1005_flags = dwCache;
  58. if( (USHORT)NetShareSetInfo( NULL,
  59. bstrShareName,
  60. 1005,
  61. (LPBYTE)s1005,
  62. NULL ))
  63. {
  64. hr = E_FAIL;
  65. throw hr;
  66. }
  67. NetApiBufferFree( s1005 );
  68. }
  69. catch(...)
  70. {
  71. }
  72. return S_OK;
  73. }