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.

69 lines
1.7 KiB

  1. // smb.cpp : Implementation of shares for Microsoft Windows
  2. #include "stdafx.h"
  3. #include <lm.h>
  4. BOOL
  5. SMBShareNameExists(
  6. IN LPCTSTR lpszServerName,
  7. IN LPCTSTR lpszShareName
  8. )
  9. {
  10. BOOL bReturn = FALSE;
  11. DWORD dwRet = NERR_Success;
  12. SHARE_INFO_0 *pInfo = NULL;
  13. dwRet = NetShareGetInfo(
  14. const_cast<LPTSTR>(lpszServerName),
  15. const_cast<LPTSTR>(lpszShareName),
  16. 0,
  17. (LPBYTE*)&pInfo);
  18. if (NERR_Success == dwRet)
  19. {
  20. bReturn = TRUE;
  21. NetApiBufferFree(pInfo);
  22. }
  23. return bReturn;
  24. }
  25. DWORD
  26. SMBCreateShare(
  27. IN LPCTSTR lpszServer,
  28. IN LPCTSTR lpszShareName,
  29. IN LPCTSTR lpszShareComment,
  30. IN LPCTSTR lpszSharePath,
  31. IN PSECURITY_DESCRIPTOR pSD
  32. )
  33. {
  34. SHARE_INFO_502 sInfo;
  35. ZeroMemory(&sInfo, sizeof(sInfo));
  36. sInfo.shi502_netname = const_cast<LPTSTR>(lpszShareName);
  37. sInfo.shi502_type = STYPE_DISKTREE;
  38. sInfo.shi502_remark = const_cast<LPTSTR>(lpszShareComment);
  39. sInfo.shi502_max_uses = -1;
  40. sInfo.shi502_path = const_cast<LPTSTR>(lpszSharePath);
  41. sInfo.shi502_security_descriptor = pSD;
  42. DWORD dwParamErr = 0;
  43. return NetShareAdd(const_cast<PTSTR>(lpszServer), 502, (LPBYTE)&sInfo, &dwParamErr);
  44. }
  45. DWORD
  46. SMBSetCSC(
  47. IN LPCTSTR lpszServer,
  48. IN LPCTSTR lpszShare,
  49. IN DWORD dwCSCFlag
  50. )
  51. {
  52. SHARE_INFO_1005 shi1005;
  53. ZeroMemory( &shi1005, sizeof(shi1005) );
  54. shi1005.shi1005_flags = dwCSCFlag;
  55. DWORD dwDummy = 0;
  56. return NetShareSetInfo(const_cast<LPTSTR>(lpszServer), const_cast<LPTSTR>(lpszShare),
  57. 1005, (LPBYTE)&shi1005, &dwDummy);
  58. }