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.

38 lines
1.2 KiB

  1. //==============================================================;
  2. //
  3. // This source code is only intended as a supplement to existing Microsoft documentation.
  4. //
  5. // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
  6. // KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  7. // IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
  8. // PURPOSE.
  9. //
  10. // Copyright (C) 1999 Microsoft Corporation. All Rights Reserved.
  11. //==============================================================;
  12. #include "stdafx.h"
  13. #include <mmc.h>
  14. #include <winuser.h>
  15. #include <tchar.h>
  16. #include "globals.h"
  17. // this uses the ATL String Conversion Macros
  18. // for handling any necessary string conversion. Note that
  19. // the snap-in (callee) allocates the necessary memory,
  20. // and MMC (the caller) does the cleanup, as required by COM.
  21. HRESULT AllocOleStr(LPOLESTR *lpDest, _TCHAR *szBuffer)
  22. {
  23. USES_CONVERSION;
  24. *lpDest = static_cast<LPOLESTR>(CoTaskMemAlloc((_tcslen(szBuffer) + 1) *
  25. sizeof(WCHAR)));
  26. if (*lpDest == 0)
  27. return E_OUTOFMEMORY;
  28. LPOLESTR ptemp = T2OLE(szBuffer);
  29. wcscpy(*lpDest, ptemp);
  30. return S_OK;
  31. }