shell32/tests: Fix remaining failures on WinMe.
[wine] / dlls / propsys / propvar.c
CommitLineData
47120f50
JH
1/*
2 * PropVariant implementation
3 *
4 * Copyright 2008 James Hawkins for CodeWeavers
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 */
20
21#include <stdarg.h>
22#include <stdio.h>
23
24#define NONAMELESSUNION
25
26#include "windef.h"
27#include "winbase.h"
28#include "winerror.h"
29#include "winreg.h"
30#include "winuser.h"
31#include "shlobj.h"
32#include "propvarutil.h"
33
34#include "wine/debug.h"
35
36WINE_DEFAULT_DEBUG_CHANNEL(propsys);
37
38static HRESULT PROPVAR_ConvertFILETIME(PROPVARIANT *ppropvarDest,
39 REFPROPVARIANT propvarSrc, VARTYPE vt)
40{
41 SYSTEMTIME time;
42
43 FileTimeToSystemTime(&propvarSrc->u.filetime, &time);
44
45 switch (vt)
46 {
47 case VT_LPSTR:
48 {
49 static const char format[] = "%04d/%02d/%02d:%02d:%02d:%02d.%03d";
50
51 ppropvarDest->u.pszVal = HeapAlloc(GetProcessHeap(), 0,
52 lstrlenA(format) + 1);
53 if (!ppropvarDest->u.pszVal)
54 return E_OUTOFMEMORY;
55
56 sprintf(ppropvarDest->u.pszVal, format, time.wYear, time.wMonth,
57 time.wDay, time.wHour, time.wMinute,
58 time.wSecond, time.wMilliseconds);
59
60 return S_OK;
61 }
62
63 default:
64 FIXME("Unhandled target type: %d\n", vt);
65 }
66
67 return E_FAIL;
68}
69
70/******************************************************************
71 * PropVariantChangeType (PROPSYS.@)
72 */
73HRESULT WINAPI PropVariantChangeType(PROPVARIANT *ppropvarDest, REFPROPVARIANT propvarSrc,
74 PROPVAR_CHANGE_FLAGS flags, VARTYPE vt)
75{
76 FIXME("(%p, %p, %d, %d, %d): semi-stub!\n", ppropvarDest, propvarSrc,
77 propvarSrc->vt, flags, vt);
78
79 switch (propvarSrc->vt)
80 {
81 case VT_FILETIME:
82 return PROPVAR_ConvertFILETIME(ppropvarDest, propvarSrc, vt);
83 default:
84 FIXME("Unhandled source type: %d\n", propvarSrc->vt);
85 }
86
87 return E_FAIL;
88}