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.

97 lines
1.4 KiB

  1. //---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1995
  5. //
  6. // File: varconv.cxx
  7. //
  8. // Contents: Ansi to Unicode conversions
  9. //
  10. // History: KrishnaG Jan 22 1996
  11. //
  12. //----------------------------------------------------------------------------
  13. //
  14. // ********* System Includes
  15. //
  16. #define UNICODE
  17. #define _UNICODE
  18. #define INC_OLE2
  19. #include <windows.h>
  20. //
  21. // ********* CRunTime Includes
  22. //
  23. #include <stdlib.h>
  24. #include <limits.h>
  25. #include <io.h>
  26. #include <stdio.h>
  27. //
  28. // ********* Local Includes
  29. //
  30. #include "varconv.hxx"
  31. HRESULT
  32. PackString2Variant(
  33. LPWSTR lpszData,
  34. VARIANT * pvData
  35. )
  36. {
  37. BSTR bstrData = NULL;
  38. if (!lpszData || !*lpszData) {
  39. return(E_FAIL);
  40. }
  41. if (!pvData) {
  42. return(E_FAIL);
  43. }
  44. bstrData = SysAllocString(lpszData);
  45. if (!bstrData) {
  46. return(E_FAIL);
  47. }
  48. pvData->vt = VT_BSTR;
  49. pvData->bstrVal = bstrData;
  50. return(S_OK);
  51. }
  52. HRESULT
  53. PackDWORD2Variant(
  54. DWORD dwData,
  55. VARIANT * pvData
  56. )
  57. {
  58. if (!pvData) {
  59. return(E_FAIL);
  60. }
  61. pvData->vt = VT_I4;
  62. pvData->lVal = dwData;
  63. return(S_OK);
  64. }
  65. HRESULT
  66. PackBOOL2Variant(
  67. BOOL fData,
  68. VARIANT * pvData
  69. )
  70. {
  71. pvData->vt = VT_BOOL;
  72. V_BOOL(pvData) = (VARIANT_BOOL) fData;
  73. return(S_OK);
  74. }