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.

76 lines
2.2 KiB

  1. // fpnw.cpp : Implementation of shares for Novell NetWare
  2. #include "stdafx.h"
  3. #include <fpnwapi.h>
  4. #define FUNCNAME_FPNWVOLUMEGETINFO "FpnwVolumeGetInfo"
  5. #define FUNCNAME_FPNWVOLUMEADD "FpnwVolumeAdd"
  6. #define FUNCNAME_FPNWAPIBUFFERFREE "FpnwApiBufferFree"
  7. typedef DWORD (CALLBACK *PFPNWVOLUMEGETINFO) (LPWSTR, LPWSTR, DWORD, LPBYTE*);
  8. typedef DWORD (CALLBACK *PFPNWVOLUMEADD)(LPWSTR, DWORD, LPBYTE);
  9. typedef DWORD (CALLBACK *PFPNWAPIBUFFERFREE)(LPVOID);
  10. BOOL
  11. FPNWShareNameExists(
  12. IN LPCTSTR lpszServerName,
  13. IN LPCTSTR lpszShareName,
  14. IN HINSTANCE hLib
  15. )
  16. {
  17. BOOL bReturn = FALSE;
  18. DWORD dwRet = NERR_Success;
  19. PFPNWVOLUMEGETINFO pFPNWVolumeGetInfo = NULL;
  20. PFPNWAPIBUFFERFREE pFPNWApiBufferFree = NULL;
  21. if ((pFPNWVolumeGetInfo = (PFPNWVOLUMEGETINFO)GetProcAddress(hLib, FUNCNAME_FPNWVOLUMEGETINFO)) &&
  22. (pFPNWApiBufferFree = (PFPNWAPIBUFFERFREE)GetProcAddress(hLib, FUNCNAME_FPNWAPIBUFFERFREE)) )
  23. {
  24. FPNWVOLUMEINFO *pInfo = NULL;
  25. dwRet = (*pFPNWVolumeGetInfo)(
  26. const_cast<LPTSTR>(lpszServerName),
  27. const_cast<LPTSTR>(lpszShareName),
  28. 1,
  29. (LPBYTE*)&pInfo);
  30. if (NERR_Success == dwRet)
  31. {
  32. bReturn = TRUE;
  33. (*pFPNWApiBufferFree)(pInfo);
  34. }
  35. }
  36. return bReturn;
  37. }
  38. DWORD
  39. FPNWCreateShare(
  40. IN LPCTSTR lpszServer,
  41. IN LPCTSTR lpszShareName,
  42. IN LPCTSTR lpszSharePath,
  43. IN PSECURITY_DESCRIPTOR pSD,
  44. IN HINSTANCE hLib
  45. )
  46. {
  47. DWORD dwRet = NERR_Success;
  48. PFPNWVOLUMEADD pFPNWVolumeAdd = NULL;
  49. if (!(pFPNWVolumeAdd = (PFPNWVOLUMEADD)GetProcAddress(hLib, FUNCNAME_FPNWVOLUMEADD)))
  50. {
  51. dwRet = GetLastError();
  52. } else
  53. {
  54. FPNWVOLUMEINFO_2 VolumeInfo2;
  55. ZeroMemory(&VolumeInfo2, sizeof(VolumeInfo2));
  56. VolumeInfo2.lpVolumeName = const_cast<LPTSTR>(lpszShareName);
  57. VolumeInfo2.dwType = FPNWVOL_TYPE_DISKTREE;
  58. VolumeInfo2.dwMaxUses = -1; // unlimited
  59. VolumeInfo2.lpPath = const_cast<LPTSTR>(lpszSharePath);
  60. VolumeInfo2.FileSecurityDescriptor = pSD;
  61. dwRet = (*pFPNWVolumeAdd)(const_cast<LPTSTR>(lpszServer), 2, (LPBYTE)&VolumeInfo2);
  62. }
  63. return dwRet;
  64. }