Source code of Windows XP (NT5)
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.

53 lines
1.3 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. }