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.

74 lines
1.0 KiB

  1. #include "headers.hxx"
  2. #pragma hdrstop
  3. #include "nr.hxx"
  4. LPTSTR
  5. NewDup(
  6. IN const TCHAR* psz
  7. )
  8. {
  9. if (NULL == psz)
  10. {
  11. return NULL;
  12. }
  13. LPTSTR pszRet = new TCHAR[_tcslen(psz) + 1];
  14. if (NULL == pszRet)
  15. {
  16. return NULL;
  17. }
  18. _tcscpy(pszRet, psz);
  19. return pszRet;
  20. }
  21. CNetResource::CNetResource(LPNETRESOURCE pnr)
  22. {
  23. if (NULL == pnr)
  24. {
  25. _bValid = FALSE;
  26. }
  27. else
  28. {
  29. _bValid = TRUE;
  30. _nr = *pnr;
  31. // now copy strings
  32. _nr.lpLocalName = NewDup(pnr->lpLocalName);
  33. _nr.lpRemoteName = NewDup(pnr->lpRemoteName);
  34. _nr.lpComment = NewDup(pnr->lpComment);
  35. _nr.lpProvider = NewDup(pnr->lpProvider);
  36. }
  37. }
  38. CNetResource::~CNetResource()
  39. {
  40. if (_bValid)
  41. {
  42. delete[] _nr.lpLocalName;
  43. delete[] _nr.lpRemoteName;
  44. delete[] _nr.lpComment;
  45. delete[] _nr.lpProvider;
  46. }
  47. }
  48. LPNETRESOURCE
  49. CNetResource::GetNetResource(
  50. VOID
  51. )
  52. {
  53. if (_bValid)
  54. {
  55. return &_nr;
  56. }
  57. else
  58. {
  59. return NULL;
  60. }
  61. }