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.

52 lines
1.3 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1997.
  5. //
  6. // File: N C S T R I N G 2 . C P P
  7. //
  8. // Contents: Common string routines that deal with COM functions
  9. //
  10. // Notes: This is a separate file because some parts of UPnP do not
  11. // link with ole32 and so the COM functions give link errors.
  12. //
  13. // Author: danielwe 27 Sep 2000
  14. //
  15. //----------------------------------------------------------------------------
  16. #include <pch.h>
  17. #pragma hdrstop
  18. #include "ncdebug.h"
  19. #include "ncstring.h"
  20. //+---------------------------------------------------------------------------
  21. //
  22. // Function: COMSzFromWsz
  23. //
  24. // Purpose: Returns a string allocated with CoTaskMemAlloc(), containing
  25. // the same characters as an input string.
  26. //
  27. // Arguments:
  28. // szOld [in] String to duplicate
  29. //
  30. // Returns: Newly allocated copy
  31. //
  32. // Author: spather 26 Sep 2000
  33. //
  34. // Notes: Caller must free result with CoTaskMemFree
  35. //
  36. LPWSTR COMSzFromWsz(LPCWSTR szOld)
  37. {
  38. LPWSTR szNew;
  39. szNew = (LPWSTR) CoTaskMemAlloc((lstrlen(szOld) + 1) * sizeof(WCHAR));
  40. if (szNew)
  41. {
  42. lstrcpy(szNew, szOld);
  43. }
  44. return szNew;
  45. }