regedit: Make key names editable also with native comctl32.
[wine/multimedia.git] / dlls / oledb32 / convert.c
blob1691792a1ceb15d42892606fcd591fd02cb901d9
1 /* OLE DB Conversion library
3 * Copyright 2009 Huw Davies
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 #include <stdarg.h>
22 #define COBJMACROS
23 #define NONAMELESSUNION
24 #define NONAMELESSSTRUCT
26 #include "windef.h"
27 #include "winbase.h"
28 #include "winnls.h"
29 #include "ole2.h"
30 #include "msdadc.h"
31 #include "oledberr.h"
33 #include "oledb_private.h"
35 #include "wine/debug.h"
37 WINE_DEFAULT_DEBUG_CHANNEL(oledb);
39 typedef struct
41 IDataConvert IDataConvert_iface;
42 IDCInfo IDCInfo_iface;
44 LONG ref;
46 UINT version; /* Set by IDCInfo_SetInfo */
47 } convert;
49 static inline convert *impl_from_IDataConvert(IDataConvert *iface)
51 return CONTAINING_RECORD(iface, convert, IDataConvert_iface);
54 static inline convert *impl_from_IDCInfo(IDCInfo *iface)
56 return CONTAINING_RECORD(iface, convert, IDCInfo_iface);
59 static HRESULT WINAPI convert_QueryInterface(IDataConvert* iface,
60 REFIID riid,
61 void **obj)
63 convert *This = impl_from_IDataConvert(iface);
64 TRACE("(%p)->(%s, %p)\n", This, debugstr_guid(riid), obj);
66 *obj = NULL;
68 if(IsEqualIID(riid, &IID_IUnknown) ||
69 IsEqualIID(riid, &IID_IDataConvert))
71 *obj = iface;
73 else if(IsEqualIID(riid, &IID_IDCInfo))
75 *obj = &This->IDCInfo_iface;
77 else
79 FIXME("interface %s not implemented\n", debugstr_guid(riid));
80 return E_NOINTERFACE;
83 IDataConvert_AddRef(iface);
84 return S_OK;
88 static ULONG WINAPI convert_AddRef(IDataConvert* iface)
90 convert *This = impl_from_IDataConvert(iface);
91 TRACE("(%p)\n", This);
93 return InterlockedIncrement(&This->ref);
97 static ULONG WINAPI convert_Release(IDataConvert* iface)
99 convert *This = impl_from_IDataConvert(iface);
100 LONG ref;
102 TRACE("(%p)\n", This);
104 ref = InterlockedDecrement(&This->ref);
105 if(ref == 0)
107 HeapFree(GetProcessHeap(), 0, This);
110 return ref;
113 static int get_length(DBTYPE type)
115 switch(type)
117 case DBTYPE_I1:
118 case DBTYPE_UI1:
119 return 1;
120 case DBTYPE_I2:
121 case DBTYPE_UI2:
122 return 2;
123 case DBTYPE_BOOL:
124 return sizeof(VARIANT_BOOL);
125 case DBTYPE_I4:
126 case DBTYPE_UI4:
127 case DBTYPE_R4:
128 return 4;
129 case DBTYPE_I8:
130 case DBTYPE_UI8:
131 case DBTYPE_R8:
132 case DBTYPE_DATE:
133 return 8;
134 case DBTYPE_DBTIMESTAMP:
135 return sizeof(DBTIMESTAMP);
136 case DBTYPE_CY:
137 return sizeof(CY);
138 case DBTYPE_BSTR:
139 return sizeof(BSTR);
140 case DBTYPE_FILETIME:
141 return sizeof(FILETIME);
142 case DBTYPE_GUID:
143 return sizeof(GUID);
144 case DBTYPE_WSTR:
145 case DBTYPE_STR:
146 case DBTYPE_BYREF | DBTYPE_WSTR:
147 return 0;
148 default:
149 FIXME("Unhandled type %04x\n", type);
150 return 0;
154 static HRESULT WINAPI convert_DataConvert(IDataConvert* iface,
155 DBTYPE src_type, DBTYPE dst_type,
156 DBLENGTH src_len, DBLENGTH *dst_len,
157 void *src, void *dst,
158 DBLENGTH dst_max_len,
159 DBSTATUS src_status, DBSTATUS *dst_status,
160 BYTE precision, BYTE scale,
161 DBDATACONVERT flags)
163 convert *This = impl_from_IDataConvert(iface);
164 HRESULT hr;
166 TRACE("(%p)->(%d, %d, %ld, %p, %p, %p, %ld, %d, %p, %d, %d, %x)\n", This,
167 src_type, dst_type, src_len, dst_len, src, dst, dst_max_len,
168 src_status, dst_status, precision, scale, flags);
170 *dst_status = DBSTATUS_E_BADACCESSOR;
172 if(IDataConvert_CanConvert(iface, src_type, dst_type) != S_OK)
174 return DB_E_UNSUPPORTEDCONVERSION;
177 if(src_type == DBTYPE_STR)
179 BSTR b;
180 DWORD len;
182 if(flags & DBDATACONVERT_LENGTHFROMNTS)
183 len = MultiByteToWideChar(CP_ACP, 0, src, -1, NULL, 0) - 1;
184 else
185 len = MultiByteToWideChar(CP_ACP, 0, src, src_len, NULL, 0);
186 b = SysAllocStringLen(NULL, len);
187 if(!b) return E_OUTOFMEMORY;
188 if(flags & DBDATACONVERT_LENGTHFROMNTS)
189 MultiByteToWideChar(CP_ACP, 0, src, -1, b, len + 1);
190 else
191 MultiByteToWideChar(CP_ACP, 0, src, src_len, b, len);
193 hr = IDataConvert_DataConvert(iface, DBTYPE_BSTR, dst_type, 0, dst_len,
194 &b, dst, dst_max_len, src_status, dst_status,
195 precision, scale, flags);
197 SysFreeString(b);
198 return hr;
201 if(src_type == DBTYPE_WSTR)
203 BSTR b;
205 if(flags & DBDATACONVERT_LENGTHFROMNTS)
206 b = SysAllocString(src);
207 else
208 b = SysAllocStringLen(src, src_len / 2);
209 if(!b) return E_OUTOFMEMORY;
210 hr = IDataConvert_DataConvert(iface, DBTYPE_BSTR, dst_type, 0, dst_len,
211 &b, dst, dst_max_len, src_status, dst_status,
212 precision, scale, flags);
213 SysFreeString(b);
214 return hr;
217 switch(dst_type)
219 case DBTYPE_I2:
221 signed short *d = dst;
222 VARIANT tmp;
223 switch(src_type)
225 case DBTYPE_EMPTY: *d = 0; hr = S_OK; break;
226 case DBTYPE_I2: *d = *(signed short*)src; hr = S_OK; break;
227 case DBTYPE_I4: hr = VarI2FromI4(*(signed int*)src, d); break;
228 case DBTYPE_R4: hr = VarI2FromR4(*(FLOAT*)src, d); break;
229 case DBTYPE_R8: hr = VarI2FromR8(*(double*)src, d); break;
230 case DBTYPE_CY: hr = VarI2FromCy(*(CY*)src, d); break;
231 case DBTYPE_DATE: hr = VarI2FromDate(*(DATE*)src, d); break;
232 case DBTYPE_BSTR: hr = VarI2FromStr(*(WCHAR**)src, LOCALE_USER_DEFAULT, 0, d); break;
233 case DBTYPE_BOOL: hr = VarI2FromBool(*(VARIANT_BOOL*)src, d); break;
234 case DBTYPE_DECIMAL: hr = VarI2FromDec((DECIMAL*)src, d); break;
235 case DBTYPE_I1: hr = VarI2FromI1(*(signed char*)src, d); break;
236 case DBTYPE_UI1: hr = VarI2FromUI1(*(BYTE*)src, d); break;
237 case DBTYPE_UI2: hr = VarI2FromUI2(*(WORD*)src, d); break;
238 case DBTYPE_UI4: hr = VarI2FromUI4(*(DWORD*)src, d); break;
239 case DBTYPE_I8: hr = VarI2FromI8(*(LONGLONG*)src, d); break;
240 case DBTYPE_UI8: hr = VarI2FromUI8(*(ULONGLONG*)src, d); break;
241 case DBTYPE_VARIANT:
242 VariantInit(&tmp);
243 if ((hr = VariantChangeType(&tmp, (VARIANT*)src, 0, VT_I2)) == S_OK)
244 *d = V_I2(&tmp);
245 break;
246 default: FIXME("Unimplemented conversion %04x -> I2\n", src_type); return E_NOTIMPL;
248 break;
251 case DBTYPE_I4:
253 signed int *d = dst;
254 VARIANT tmp;
255 switch(src_type)
257 case DBTYPE_EMPTY: *d = 0; hr = S_OK; break;
258 case DBTYPE_I2: hr = VarI4FromI2(*(signed short*)src, d); break;
259 case DBTYPE_I4: *d = *(signed int*)src; hr = S_OK; break;
260 case DBTYPE_R4: hr = VarI4FromR4(*(FLOAT*)src, d); break;
261 case DBTYPE_R8: hr = VarI4FromR8(*(double*)src, d); break;
262 case DBTYPE_CY: hr = VarI4FromCy(*(CY*)src, d); break;
263 case DBTYPE_DATE: hr = VarI4FromDate(*(DATE*)src, d); break;
264 case DBTYPE_BSTR: hr = VarI4FromStr(*(WCHAR**)src, LOCALE_USER_DEFAULT, 0, d); break;
265 case DBTYPE_BOOL: hr = VarI4FromBool(*(VARIANT_BOOL*)src, d); break;
266 case DBTYPE_DECIMAL: hr = VarI4FromDec((DECIMAL*)src, d); break;
267 case DBTYPE_I1: hr = VarI4FromI1(*(signed char*)src, d); break;
268 case DBTYPE_UI1: hr = VarI4FromUI1(*(BYTE*)src, d); break;
269 case DBTYPE_UI2: hr = VarI4FromUI2(*(WORD*)src, d); break;
270 case DBTYPE_UI4: hr = VarI4FromUI4(*(DWORD*)src, d); break;
271 case DBTYPE_I8: hr = VarI4FromI8(*(LONGLONG*)src, d); break;
272 case DBTYPE_UI8: hr = VarI4FromUI8(*(ULONGLONG*)src, d); break;
273 case DBTYPE_VARIANT:
274 VariantInit(&tmp);
275 if ((hr = VariantChangeType(&tmp, (VARIANT*)src, 0, VT_I4)) == S_OK)
276 *d = V_I4(&tmp);
277 break;
278 default: FIXME("Unimplemented conversion %04x -> I4\n", src_type); return E_NOTIMPL;
280 break;
283 case DBTYPE_R4:
285 FLOAT *d = dst;
286 switch(src_type)
288 case DBTYPE_EMPTY: *d = 0; hr = S_OK; break;
289 case DBTYPE_I2: hr = VarR4FromI2(*(signed short*)src, d); break;
290 case DBTYPE_I4: hr = VarR4FromI4(*(signed int*)src, d); break;
291 case DBTYPE_R4: *d = *(FLOAT*)src; hr = S_OK; break;
292 case DBTYPE_R8: hr = VarR4FromR8(*(double*)src, d); break;
293 case DBTYPE_CY: hr = VarR4FromCy(*(CY*)src, d); break;
294 case DBTYPE_DATE: hr = VarR4FromDate(*(DATE*)src, d); break;
295 case DBTYPE_BSTR: hr = VarR4FromStr(*(WCHAR**)src, LOCALE_USER_DEFAULT, 0, d); break;
296 case DBTYPE_BOOL: hr = VarR4FromBool(*(VARIANT_BOOL*)src, d); break;
297 case DBTYPE_DECIMAL: hr = VarR4FromDec((DECIMAL*)src, d); break;
298 case DBTYPE_I1: hr = VarR4FromI1(*(signed char*)src, d); break;
299 case DBTYPE_UI1: hr = VarR4FromUI1(*(BYTE*)src, d); break;
300 case DBTYPE_UI2: hr = VarR4FromUI2(*(WORD*)src, d); break;
301 case DBTYPE_UI4: hr = VarR4FromUI4(*(DWORD*)src, d); break;
302 case DBTYPE_I8: hr = VarR4FromI8(*(LONGLONG*)src, d); break;
303 case DBTYPE_UI8: hr = VarR4FromUI8(*(ULONGLONG*)src, d); break;
304 default: FIXME("Unimplemented conversion %04x -> R4\n", src_type); return E_NOTIMPL;
306 break;
308 case DBTYPE_R8:
310 DOUBLE *d=dst;
311 switch (src_type)
313 case DBTYPE_EMPTY: *d = 0; hr = S_OK; break;
314 case DBTYPE_I1: hr = VarR8FromI1(*(signed char*)src, d); break;
315 case DBTYPE_I2: hr = VarR8FromI2(*(signed short*)src, d); break;
316 case DBTYPE_I4: hr = VarR8FromI4(*(signed int*)src, d); break;
317 case DBTYPE_I8: hr = VarR8FromI8(*(LONGLONG*)src, d); break;
318 case DBTYPE_UI1: hr = VarR8FromUI1(*(BYTE*)src, d); break;
319 case DBTYPE_UI2: hr = VarR8FromUI2(*(WORD*)src, d); break;
320 case DBTYPE_UI4: hr = VarR8FromUI4(*(DWORD*)src, d); break;
321 case DBTYPE_UI8: hr = VarR8FromUI8(*(ULONGLONG*)src, d); break;
322 case DBTYPE_R4: hr = VarR8FromR4(*(FLOAT*)src, d); break;
323 case DBTYPE_R8: *d = *(DOUBLE*)src; hr = S_OK; break;
324 case DBTYPE_CY: hr = VarR8FromCy(*(CY*)src, d); break;
325 case DBTYPE_DATE: hr = VarR8FromDate(*(DATE*)src, d); break;
326 case DBTYPE_BSTR: hr = VarR8FromStr(*(WCHAR**)src, LOCALE_USER_DEFAULT, 0, d); break;
327 case DBTYPE_BOOL: hr = VarR8FromBool(*(VARIANT_BOOL*)src, d); break;
328 case DBTYPE_DECIMAL: hr = VarR8FromDec((DECIMAL*)src, d); break;
329 default: FIXME("Unimplemented conversion %04x -> R8\n", src_type); return E_NOTIMPL;
331 break;
333 case DBTYPE_BOOL:
335 VARIANT_BOOL *d=dst;
336 switch (src_type)
338 case DBTYPE_EMPTY: *d = 0; hr = S_OK; break;
339 case DBTYPE_I1: hr = VarBoolFromI1(*(signed char*)src, d); break;
340 case DBTYPE_I2: hr = VarBoolFromI2(*(signed short*)src, d); break;
341 case DBTYPE_I4: hr = VarBoolFromI4(*(signed int*)src, d); break;
342 case DBTYPE_I8: hr = VarBoolFromI8(*(LONGLONG*)src, d); break;
343 case DBTYPE_UI1: hr = VarBoolFromUI1(*(BYTE*)src, d); break;
344 case DBTYPE_UI2: hr = VarBoolFromUI2(*(WORD*)src, d); break;
345 case DBTYPE_UI4: hr = VarBoolFromUI4(*(DWORD*)src, d); break;
346 case DBTYPE_UI8: hr = VarBoolFromUI8(*(ULONGLONG*)src, d); break;
347 case DBTYPE_R4: hr = VarBoolFromR4(*(FLOAT*)src, d); break;
348 case DBTYPE_R8: hr = VarBoolFromR8(*(DOUBLE*)src, d); break;
349 case DBTYPE_CY: hr = VarBoolFromCy(*(CY*)src, d); break;
350 case DBTYPE_DATE: hr = VarBoolFromDate(*(DATE*)src, d); break;
351 case DBTYPE_BSTR: hr = VarBoolFromStr(*(WCHAR**)src, LOCALE_USER_DEFAULT, 0, d); break;
352 case DBTYPE_BOOL: *d = *(VARIANT_BOOL*)src; hr = S_OK; break;
353 case DBTYPE_DECIMAL: hr = VarBoolFromDec((DECIMAL*)src, d); break;
354 default: FIXME("Unimplemented conversion %04x -> BOOL\n", src_type); return E_NOTIMPL;
356 break;
358 case DBTYPE_DATE:
360 DATE *d=dst;
361 switch (src_type)
363 case DBTYPE_EMPTY: *d = 0; hr = S_OK; break;
364 case DBTYPE_I1: hr = VarDateFromI1(*(signed char*)src, d); break;
365 case DBTYPE_I2: hr = VarDateFromI2(*(signed short*)src, d); break;
366 case DBTYPE_I4: hr = VarDateFromI4(*(signed int*)src, d); break;
367 case DBTYPE_I8: hr = VarDateFromI8(*(LONGLONG*)src, d); break;
368 case DBTYPE_UI1: hr = VarDateFromUI1(*(BYTE*)src, d); break;
369 case DBTYPE_UI2: hr = VarDateFromUI2(*(WORD*)src, d); break;
370 case DBTYPE_UI4: hr = VarDateFromUI4(*(DWORD*)src, d); break;
371 case DBTYPE_UI8: hr = VarDateFromUI8(*(ULONGLONG*)src, d); break;
372 case DBTYPE_R4: hr = VarDateFromR4(*(FLOAT*)src, d); break;
373 case DBTYPE_R8: hr = VarDateFromR8(*(DOUBLE*)src, d); break;
374 case DBTYPE_CY: hr = VarDateFromCy(*(CY*)src, d); break;
375 case DBTYPE_DATE: *d = *(DATE*)src; hr = S_OK; break;
376 case DBTYPE_BSTR: hr = VarDateFromStr(*(WCHAR**)src, LOCALE_USER_DEFAULT, 0, d); break;
377 case DBTYPE_BOOL: hr = VarDateFromBool(*(VARIANT_BOOL*)src, d); break;
378 case DBTYPE_DECIMAL: hr = VarDateFromDec((DECIMAL*)src, d); break;
379 case DBTYPE_DBTIMESTAMP:
381 SYSTEMTIME st;
382 DBTIMESTAMP *ts=(DBTIMESTAMP*)src;
384 st.wYear = ts->year;
385 st.wMonth = ts->month;
386 st.wDay = ts->day;
387 st.wHour = ts->hour;
388 st.wMinute = ts->minute;
389 st.wSecond = ts->second;
390 st.wMilliseconds = ts->fraction/1000000;
391 hr = (SystemTimeToVariantTime(&st, d) ? S_OK : E_FAIL);
392 break;
394 default: FIXME("Unimplemented conversion %04x -> DATE\n", src_type); return E_NOTIMPL;
396 break;
398 case DBTYPE_DBTIMESTAMP:
400 DBTIMESTAMP *d=dst;
401 switch (src_type)
403 case DBTYPE_EMPTY: memset(d, 0, sizeof(DBTIMESTAMP)); hr = S_OK; break;
404 case DBTYPE_DBTIMESTAMP: memcpy(d, src, sizeof(DBTIMESTAMP)); hr = S_OK; break;
405 case DBTYPE_DATE:
407 SYSTEMTIME st;
408 hr = (VariantTimeToSystemTime(*(double*)src, &st) ? S_OK : E_FAIL);
409 d->year = st.wYear;
410 d->month = st.wMonth;
411 d->day = st.wDay;
412 d->hour = st.wHour;
413 d->minute = st.wMinute;
414 d->second = st.wSecond;
415 d->fraction = st.wMilliseconds * 1000000;
416 break;
418 default: FIXME("Unimplemented conversion %04x -> DBTIMESTAMP\n", src_type); return E_NOTIMPL;
420 break;
423 case DBTYPE_CY:
425 CY *d = dst;
426 switch(src_type)
428 case DBTYPE_EMPTY: d->int64 = 0; hr = S_OK; break;
429 case DBTYPE_I2: hr = VarCyFromI2(*(signed short*)src, d); break;
430 case DBTYPE_I4: hr = VarCyFromI4(*(signed int*)src, d); break;
431 case DBTYPE_R4: hr = VarCyFromR4(*(FLOAT*)src, d); break;
432 case DBTYPE_R8: hr = VarCyFromR8(*(double*)src, d); break;
433 case DBTYPE_CY: *d = *(CY*)src; hr = S_OK; break;
434 case DBTYPE_DATE: hr = VarCyFromDate(*(DATE*)src, d); break;
435 case DBTYPE_BSTR: hr = VarCyFromStr(*(WCHAR**)src, LOCALE_USER_DEFAULT, 0, d); break;
436 case DBTYPE_BOOL: hr = VarCyFromBool(*(VARIANT_BOOL*)src, d); break;
437 case DBTYPE_DECIMAL: hr = VarCyFromDec((DECIMAL*)src, d); break;
438 case DBTYPE_I1: hr = VarCyFromI1(*(signed char*)src, d); break;
439 case DBTYPE_UI1: hr = VarCyFromUI1(*(BYTE*)src, d); break;
440 case DBTYPE_UI2: hr = VarCyFromUI2(*(WORD*)src, d); break;
441 case DBTYPE_UI4: hr = VarCyFromUI4(*(DWORD*)src, d); break;
442 case DBTYPE_I8: hr = VarCyFromI8(*(LONGLONG*)src, d); break;
443 case DBTYPE_UI8: hr = VarCyFromUI8(*(ULONGLONG*)src, d); break;
444 default: FIXME("Unimplemented conversion %04x -> CY\n", src_type); return E_NOTIMPL;
446 break;
449 case DBTYPE_BSTR:
451 BSTR *d = dst;
452 switch(src_type)
454 case DBTYPE_EMPTY: *d = SysAllocStringLen(NULL, 0); hr = *d ? S_OK : E_OUTOFMEMORY; break;
455 case DBTYPE_I2: hr = VarBstrFromI2(*(signed short*)src, LOCALE_USER_DEFAULT, 0, d); break;
456 case DBTYPE_I4: hr = VarBstrFromI4(*(signed int*)src, LOCALE_USER_DEFAULT, 0, d); break;
457 case DBTYPE_R4: hr = VarBstrFromR4(*(FLOAT*)src, LOCALE_USER_DEFAULT, 0, d); break;
458 case DBTYPE_R8: hr = VarBstrFromR8(*(double*)src, LOCALE_USER_DEFAULT, 0, d); break;
459 case DBTYPE_CY: hr = VarBstrFromCy(*(CY*)src, LOCALE_USER_DEFAULT, 0, d); break;
460 case DBTYPE_DATE: hr = VarBstrFromDate(*(DATE*)src, LOCALE_USER_DEFAULT, 0, d); break;
461 case DBTYPE_BSTR: *d = SysAllocStringLen(*(BSTR*)src, SysStringLen(*(BSTR*)src)); hr = *d ? S_OK : E_OUTOFMEMORY; break;
462 case DBTYPE_BOOL: hr = VarBstrFromBool(*(VARIANT_BOOL*)src, LOCALE_USER_DEFAULT, 0, d); break;
463 case DBTYPE_DECIMAL: hr = VarBstrFromDec((DECIMAL*)src, LOCALE_USER_DEFAULT, 0, d); break;
464 case DBTYPE_I1: hr = VarBstrFromI1(*(signed char*)src, LOCALE_USER_DEFAULT, 0, d); break;
465 case DBTYPE_UI1: hr = VarBstrFromUI1(*(BYTE*)src, LOCALE_USER_DEFAULT, 0, d); break;
466 case DBTYPE_UI2: hr = VarBstrFromUI2(*(WORD*)src, LOCALE_USER_DEFAULT, 0, d); break;
467 case DBTYPE_UI4: hr = VarBstrFromUI4(*(DWORD*)src, LOCALE_USER_DEFAULT, 0, d); break;
468 case DBTYPE_I8: hr = VarBstrFromI8(*(LONGLONG*)src, LOCALE_USER_DEFAULT, 0, d); break;
469 case DBTYPE_UI8: hr = VarBstrFromUI8(*(ULONGLONG*)src, LOCALE_USER_DEFAULT, 0, d); break;
470 case DBTYPE_GUID:
472 WCHAR szBuff[39];
473 const GUID *id = (const GUID *)src;
474 WCHAR format[] = {
475 '{','%','0','8','X','-','%','0','4','X','-','%','0','4','X','-',
476 '%','0','2','X','%','0','2','X','-',
477 '%','0','2','X','%','0','2','X','%','0','2','X','%','0','2','X','%','0','2','X','%','0','2','X','}',0};
478 wsprintfW(szBuff, format,
479 id->Data1, id->Data2, id->Data3,
480 id->Data4[0], id->Data4[1], id->Data4[2], id->Data4[3],
481 id->Data4[4], id->Data4[5], id->Data4[6], id->Data4[7] );
482 *d = SysAllocString(szBuff);
483 hr = *d ? S_OK : E_OUTOFMEMORY;
485 break;
486 case DBTYPE_BYTES:
488 *d = SysAllocStringLen(NULL, 2 * src_len);
489 if (*d == NULL)
490 hr = E_OUTOFMEMORY;
491 else
493 const char hexchars[] = "0123456789ABCDEF";
494 WCHAR *s = *d;
495 unsigned char *p = src;
496 while (src_len > 0)
498 *s++ = hexchars[(*p >> 4) & 0x0F];
499 *s++ = hexchars[(*p) & 0x0F];
500 src_len--; p++;
502 hr = S_OK;
505 break;
506 default: FIXME("Unimplemented conversion %04x -> BSTR\n", src_type); return E_NOTIMPL;
508 break;
511 case DBTYPE_UI1:
513 BYTE *d = dst;
514 switch(src_type)
516 case DBTYPE_EMPTY: *d = 0; hr = S_OK; break;
517 case DBTYPE_I2: hr = VarUI1FromI2(*(signed short*)src, d); break;
518 case DBTYPE_I4: hr = VarUI1FromI4(*(signed int*)src, d); break;
519 case DBTYPE_R4: hr = VarUI1FromR4(*(FLOAT*)src, d); break;
520 case DBTYPE_R8: hr = VarUI1FromR8(*(double*)src, d); break;
521 case DBTYPE_CY: hr = VarUI1FromCy(*(CY*)src, d); break;
522 case DBTYPE_DATE: hr = VarUI1FromDate(*(DATE*)src, d); break;
523 case DBTYPE_BSTR: hr = VarUI1FromStr(*(WCHAR**)src, LOCALE_USER_DEFAULT, 0, d); break;
524 case DBTYPE_BOOL: hr = VarUI1FromBool(*(VARIANT_BOOL*)src, d); break;
525 case DBTYPE_DECIMAL: hr = VarUI1FromDec((DECIMAL*)src, d); break;
526 case DBTYPE_I1: hr = VarUI1FromI1(*(signed char*)src, d); break;
527 case DBTYPE_UI1: *d = *(BYTE*)src; hr = S_OK; break;
528 case DBTYPE_UI2: hr = VarUI1FromUI2(*(WORD*)src, d); break;
529 case DBTYPE_UI4: hr = VarUI1FromUI4(*(DWORD*)src, d); break;
530 case DBTYPE_I8: hr = VarUI1FromI8(*(LONGLONG*)src, d); break;
531 case DBTYPE_UI8: hr = VarUI1FromUI8(*(ULONGLONG*)src, d); break;
532 default: FIXME("Unimplemented conversion %04x -> UI1\n", src_type); return E_NOTIMPL;
534 break;
536 case DBTYPE_UI2:
538 WORD *d = dst;
539 switch(src_type)
541 case DBTYPE_EMPTY: *d = 0; hr = S_OK; break;
542 case DBTYPE_I2: hr = VarUI2FromI2(*(signed short*)src, d); break;
543 case DBTYPE_I4: hr = VarUI2FromI4(*(signed int*)src, d); break;
544 case DBTYPE_R4: hr = VarUI2FromR4(*(FLOAT*)src, d); break;
545 case DBTYPE_R8: hr = VarUI2FromR8(*(double*)src, d); break;
546 case DBTYPE_CY: hr = VarUI2FromCy(*(CY*)src, d); break;
547 case DBTYPE_DATE: hr = VarUI2FromDate(*(DATE*)src, d); break;
548 case DBTYPE_BSTR: hr = VarUI2FromStr(*(WCHAR**)src, LOCALE_USER_DEFAULT, 0, d); break;
549 case DBTYPE_BOOL: hr = VarUI2FromBool(*(VARIANT_BOOL*)src, d); break;
550 case DBTYPE_DECIMAL: hr = VarUI2FromDec((DECIMAL*)src, d); break;
551 case DBTYPE_I1: hr = VarUI2FromI1(*(signed char*)src, d); break;
552 case DBTYPE_UI1: hr = VarUI2FromUI1(*(BYTE*)src, d); break;
553 case DBTYPE_UI2: *d = *(WORD*)src; hr = S_OK; break;
554 case DBTYPE_UI4: hr = VarUI2FromUI4(*(DWORD*)src, d); break;
555 case DBTYPE_I8: hr = VarUI2FromI8(*(LONGLONG*)src, d); break;
556 case DBTYPE_UI8: hr = VarUI2FromUI8(*(ULONGLONG*)src, d); break;
557 default: FIXME("Unimplemented conversion %04x -> UI2\n", src_type); return E_NOTIMPL;
559 break;
562 case DBTYPE_UI4:
564 DWORD *d = dst;
565 switch(src_type)
567 case DBTYPE_EMPTY: *d = 0; hr = S_OK; break;
568 case DBTYPE_I2: hr = VarUI4FromI2(*(signed short*)src, d); break;
569 case DBTYPE_I4: hr = VarUI4FromI4(*(signed int*)src, d); break;
570 case DBTYPE_R4: hr = VarUI4FromR4(*(FLOAT*)src, d); break;
571 case DBTYPE_R8: hr = VarUI4FromR8(*(double*)src, d); break;
572 case DBTYPE_CY: hr = VarUI4FromCy(*(CY*)src, d); break;
573 case DBTYPE_DATE: hr = VarUI4FromDate(*(DATE*)src, d); break;
574 case DBTYPE_BSTR: hr = VarUI4FromStr(*(WCHAR**)src, LOCALE_USER_DEFAULT, 0, d); break;
575 case DBTYPE_BOOL: hr = VarUI4FromBool(*(VARIANT_BOOL*)src, d); break;
576 case DBTYPE_DECIMAL: hr = VarUI4FromDec((DECIMAL*)src, d); break;
577 case DBTYPE_I1: hr = VarUI4FromI1(*(signed char*)src, d); break;
578 case DBTYPE_UI1: hr = VarUI4FromUI1(*(BYTE*)src, d); break;
579 case DBTYPE_UI2: hr = VarUI4FromUI2(*(WORD*)src, d); break;
580 case DBTYPE_UI4: *d = *(DWORD*)src; hr = S_OK; break;
581 case DBTYPE_I8: hr = VarUI4FromI8(*(LONGLONG*)src, d); break;
582 case DBTYPE_UI8: hr = VarUI4FromUI8(*(ULONGLONG*)src, d); break;
583 default: FIXME("Unimplemented conversion %04x -> UI4\n", src_type); return E_NOTIMPL;
585 break;
588 case DBTYPE_UI8:
590 ULONGLONG *d = dst;
591 switch(src_type)
593 case DBTYPE_EMPTY: *d = 0; hr = S_OK; break;
594 case DBTYPE_I2: hr = VarUI8FromI2(*(signed short*)src, d); break;
595 case DBTYPE_I4: {LONGLONG s = *(signed int*)src; hr = VarUI8FromI8(s, d); break;}
596 case DBTYPE_R4: hr = VarUI8FromR4(*(FLOAT*)src, d); break;
597 case DBTYPE_R8: hr = VarUI8FromR8(*(double*)src, d); break;
598 case DBTYPE_CY: hr = VarUI8FromCy(*(CY*)src, d); break;
599 case DBTYPE_DATE: hr = VarUI8FromDate(*(DATE*)src, d); break;
600 case DBTYPE_BSTR: hr = VarUI8FromStr(*(WCHAR**)src, LOCALE_USER_DEFAULT, 0, d); break;
601 case DBTYPE_BOOL: hr = VarUI8FromBool(*(VARIANT_BOOL*)src, d); break;
602 case DBTYPE_DECIMAL: hr = VarUI8FromDec((DECIMAL*)src, d); break;
603 case DBTYPE_I1: hr = VarUI8FromI1(*(signed char*)src, d); break;
604 case DBTYPE_UI1: hr = VarUI8FromUI1(*(BYTE*)src, d); break;
605 case DBTYPE_UI2: hr = VarUI8FromUI2(*(WORD*)src, d); break;
606 case DBTYPE_UI4: hr = VarUI8FromUI4(*(DWORD*)src, d); break;
607 case DBTYPE_I8: hr = VarUI8FromI8(*(LONGLONG*)src, d); break;
608 case DBTYPE_UI8: *d = *(ULONGLONG*)src; hr = S_OK; break;
609 default: FIXME("Unimplemented conversion %04x -> UI8\n", src_type); return E_NOTIMPL;
611 break;
614 case DBTYPE_FILETIME:
616 FILETIME *d = dst;
617 switch(src_type)
619 case DBTYPE_EMPTY: d->dwLowDateTime = d->dwHighDateTime = 0; hr = S_OK; break;
620 case DBTYPE_FILETIME: *d = *(FILETIME*)src; hr = S_OK; break;
621 default: FIXME("Unimplemented conversion %04x -> FILETIME\n", src_type); return E_NOTIMPL;
623 break;
626 case DBTYPE_GUID:
628 GUID *d = dst;
629 switch(src_type)
631 case DBTYPE_EMPTY: *d = GUID_NULL; hr = S_OK; break;
632 case DBTYPE_GUID: *d = *(GUID*)src; hr = S_OK; break;
633 default: FIXME("Unimplemented conversion %04x -> GUID\n", src_type); return E_NOTIMPL;
635 break;
638 case DBTYPE_WSTR:
640 BSTR b;
641 DBLENGTH bstr_len;
642 INT bytes_to_copy;
643 hr = IDataConvert_DataConvert(iface, src_type, DBTYPE_BSTR, src_len, &bstr_len,
644 src, &b, sizeof(BSTR), src_status, dst_status,
645 precision, scale, flags);
646 if(hr != S_OK) return hr;
647 bstr_len = SysStringLen(b);
648 *dst_len = bstr_len * sizeof(WCHAR); /* Doesn't include size for '\0' */
649 *dst_status = DBSTATUS_S_OK;
650 bytes_to_copy = min(*dst_len + sizeof(WCHAR), dst_max_len);
651 if(dst)
653 if(bytes_to_copy >= sizeof(WCHAR))
655 memcpy(dst, b, bytes_to_copy - sizeof(WCHAR));
656 *((WCHAR*)dst + bytes_to_copy / sizeof(WCHAR) - 1) = 0;
657 if(bytes_to_copy < *dst_len + sizeof(WCHAR))
658 *dst_status = DBSTATUS_S_TRUNCATED;
660 else
662 *dst_status = DBSTATUS_E_DATAOVERFLOW;
663 hr = DB_E_ERRORSOCCURRED;
666 SysFreeString(b);
667 return hr;
669 case DBTYPE_STR:
671 BSTR b;
672 DBLENGTH bstr_len;
673 INT bytes_to_copy;
674 hr = IDataConvert_DataConvert(iface, src_type, DBTYPE_BSTR, src_len, &bstr_len,
675 src, &b, sizeof(BSTR), src_status, dst_status,
676 precision, scale, flags);
677 if(hr != S_OK) return hr;
678 bstr_len = SysStringLen(b);
679 *dst_len = bstr_len * sizeof(char); /* Doesn't include size for '\0' */
680 *dst_status = DBSTATUS_S_OK;
681 bytes_to_copy = min(*dst_len + sizeof(char), dst_max_len);
682 if(dst)
684 if(bytes_to_copy >= sizeof(char))
686 WideCharToMultiByte(CP_ACP, 0, b, bytes_to_copy - sizeof(char), dst, dst_max_len, NULL, NULL);
687 *((char *)dst + bytes_to_copy / sizeof(char) - 1) = 0;
688 if(bytes_to_copy < *dst_len + sizeof(char))
689 *dst_status = DBSTATUS_S_TRUNCATED;
691 else
693 *dst_status = DBSTATUS_E_DATAOVERFLOW;
694 hr = DB_E_ERRORSOCCURRED;
697 SysFreeString(b);
698 return hr;
701 case DBTYPE_BYREF | DBTYPE_WSTR:
703 BSTR b;
704 WCHAR **d = dst;
705 DBLENGTH bstr_len;
706 hr = IDataConvert_DataConvert(iface, src_type, DBTYPE_BSTR, src_len, &bstr_len,
707 src, &b, sizeof(BSTR), src_status, dst_status,
708 precision, scale, flags);
709 if(hr != S_OK) return hr;
711 bstr_len = SysStringLen(b) * sizeof(WCHAR);
712 *dst_len = bstr_len; /* Doesn't include size for '\0' */
714 *d = CoTaskMemAlloc(bstr_len + sizeof(WCHAR));
715 if(*d) memcpy(*d, b, bstr_len + sizeof(WCHAR));
716 else hr = E_OUTOFMEMORY;
717 SysFreeString(b);
718 return hr;
721 default:
722 FIXME("Unimplemented conversion %04x -> %04x\n", src_type, dst_type);
723 return E_NOTIMPL;
727 if(hr == DISP_E_OVERFLOW)
729 *dst_status = DBSTATUS_E_DATAOVERFLOW;
730 *dst_len = get_length(dst_type);
731 hr = DB_E_ERRORSOCCURRED;
733 else if(hr == S_OK)
735 *dst_status = DBSTATUS_S_OK;
736 *dst_len = get_length(dst_type);
739 return hr;
742 static inline WORD get_dbtype_class(DBTYPE type)
744 switch(type)
746 case DBTYPE_I2:
747 case DBTYPE_R4:
748 case DBTYPE_R8:
749 case DBTYPE_I1:
750 case DBTYPE_UI1:
751 case DBTYPE_UI2:
752 return DBTYPE_I2;
754 case DBTYPE_I4:
755 case DBTYPE_UI4:
756 return DBTYPE_I4;
758 case DBTYPE_I8:
759 case DBTYPE_UI8:
760 return DBTYPE_I8;
762 case DBTYPE_BSTR:
763 case DBTYPE_STR:
764 case DBTYPE_WSTR:
765 return DBTYPE_BSTR;
767 case DBTYPE_DBDATE:
768 case DBTYPE_DBTIME:
769 case DBTYPE_DBTIMESTAMP:
770 return DBTYPE_DBDATE;
772 return type;
775 /* Many src types will convert to this group of dst types */
776 static inline BOOL common_class(WORD dst_class)
778 switch(dst_class)
780 case DBTYPE_EMPTY:
781 case DBTYPE_NULL:
782 case DBTYPE_I2:
783 case DBTYPE_I4:
784 case DBTYPE_BSTR:
785 case DBTYPE_BOOL:
786 case DBTYPE_VARIANT:
787 case DBTYPE_I8:
788 case DBTYPE_CY:
789 case DBTYPE_DECIMAL:
790 case DBTYPE_NUMERIC:
791 return TRUE;
793 return FALSE;
796 static inline BOOL array_type(DBTYPE type)
798 return (type >= DBTYPE_I2 && type <= DBTYPE_UI4);
801 static HRESULT WINAPI convert_CanConvert(IDataConvert* iface,
802 DBTYPE src_type, DBTYPE dst_type)
804 convert *This = impl_from_IDataConvert(iface);
805 DBTYPE src_base_type = src_type & 0x1ff;
806 DBTYPE dst_base_type = dst_type & 0x1ff;
807 WORD dst_class = get_dbtype_class(dst_base_type);
809 TRACE("(%p)->(%d, %d)\n", This, src_type, dst_type);
811 if(src_type & DBTYPE_VECTOR || dst_type & DBTYPE_VECTOR) return S_FALSE;
813 if(src_type & DBTYPE_ARRAY)
815 if(!array_type(src_base_type)) return S_FALSE;
816 if(dst_type & DBTYPE_ARRAY)
818 if(src_type == dst_type) return S_OK;
819 return S_FALSE;
821 if(dst_type == DBTYPE_VARIANT) return S_OK;
822 return S_FALSE;
825 if(dst_type & DBTYPE_ARRAY)
827 if(!array_type(dst_base_type)) return S_FALSE;
828 if(src_type == DBTYPE_IDISPATCH || src_type == DBTYPE_VARIANT) return S_OK;
829 return S_FALSE;
832 if(dst_type & DBTYPE_BYREF)
833 if(dst_base_type != DBTYPE_BYTES && dst_base_type != DBTYPE_STR && dst_base_type != DBTYPE_WSTR)
834 return S_FALSE;
836 switch(get_dbtype_class(src_base_type))
838 case DBTYPE_EMPTY:
839 if(common_class(dst_class)) return S_OK;
840 switch(dst_class)
842 case DBTYPE_DATE:
843 case DBTYPE_GUID:
844 case DBTYPE_FILETIME:
845 return S_OK;
846 default:
847 if(dst_base_type == DBTYPE_DBTIMESTAMP) return S_OK;
848 return S_FALSE;
851 case DBTYPE_NULL:
852 switch(dst_base_type)
854 case DBTYPE_NULL:
855 case DBTYPE_VARIANT:
856 case DBTYPE_FILETIME: return S_OK;
857 default: return S_FALSE;
860 case DBTYPE_I4:
861 if(dst_base_type == DBTYPE_BYTES) return S_OK;
862 /* fall through */
863 case DBTYPE_I2:
864 if(dst_base_type == DBTYPE_DATE) return S_OK;
865 /* fall through */
866 case DBTYPE_DECIMAL:
867 if(common_class(dst_class)) return S_OK;
868 if(dst_class == DBTYPE_DBDATE) return S_OK;
869 return S_FALSE;
871 case DBTYPE_BOOL:
872 if(dst_base_type == DBTYPE_DATE) return S_OK;
873 case DBTYPE_NUMERIC:
874 case DBTYPE_CY:
875 if(common_class(dst_class)) return S_OK;
876 return S_FALSE;
878 case DBTYPE_I8:
879 if(common_class(dst_class)) return S_OK;
880 switch(dst_base_type)
882 case DBTYPE_BYTES:
883 case DBTYPE_FILETIME: return S_OK;
884 default: return S_FALSE;
887 case DBTYPE_DATE:
888 switch(dst_class)
890 case DBTYPE_EMPTY:
891 case DBTYPE_NULL:
892 case DBTYPE_I2:
893 case DBTYPE_I4:
894 case DBTYPE_BSTR:
895 case DBTYPE_BOOL:
896 case DBTYPE_VARIANT:
897 case DBTYPE_I8:
898 case DBTYPE_DATE:
899 case DBTYPE_DBDATE:
900 case DBTYPE_FILETIME:
901 return S_OK;
902 default: return S_FALSE;
905 case DBTYPE_IDISPATCH:
906 case DBTYPE_VARIANT:
907 switch(dst_base_type)
909 case DBTYPE_IDISPATCH:
910 case DBTYPE_ERROR:
911 case DBTYPE_IUNKNOWN:
912 return S_OK;
914 /* fall through */
915 case DBTYPE_BSTR:
916 if(common_class(dst_class)) return S_OK;
917 switch(dst_class)
919 case DBTYPE_DATE:
920 case DBTYPE_GUID:
921 case DBTYPE_BYTES:
922 case DBTYPE_DBDATE:
923 case DBTYPE_FILETIME:
924 return S_OK;
925 default: return S_FALSE;
928 case DBTYPE_ERROR:
929 switch(dst_base_type)
931 case DBTYPE_BSTR:
932 case DBTYPE_ERROR:
933 case DBTYPE_VARIANT:
934 case DBTYPE_WSTR:
935 return S_OK;
936 default: return S_FALSE;
939 case DBTYPE_IUNKNOWN:
940 switch(dst_base_type)
942 case DBTYPE_EMPTY:
943 case DBTYPE_NULL:
944 case DBTYPE_IDISPATCH:
945 case DBTYPE_VARIANT:
946 case DBTYPE_IUNKNOWN:
947 return S_OK;
948 default: return S_FALSE;
951 case DBTYPE_BYTES:
952 if(dst_class == DBTYPE_I4 || dst_class == DBTYPE_I8) return S_OK;
953 /* fall through */
954 case DBTYPE_GUID:
955 switch(dst_class)
957 case DBTYPE_EMPTY:
958 case DBTYPE_NULL:
959 case DBTYPE_BSTR:
960 case DBTYPE_VARIANT:
961 case DBTYPE_GUID:
962 case DBTYPE_BYTES:
963 return S_OK;
964 default: return S_FALSE;
967 case DBTYPE_FILETIME:
968 if(dst_class == DBTYPE_I8) return S_OK;
969 /* fall through */
970 case DBTYPE_DBDATE:
971 switch(dst_class)
973 case DBTYPE_EMPTY:
974 case DBTYPE_NULL:
975 case DBTYPE_DATE:
976 case DBTYPE_BSTR:
977 case DBTYPE_VARIANT:
978 case DBTYPE_DBDATE:
979 case DBTYPE_FILETIME:
980 return S_OK;
981 default: return S_FALSE;
985 return S_FALSE;
988 static HRESULT WINAPI convert_GetConversionSize(IDataConvert* iface,
989 DBTYPE wSrcType, DBTYPE wDstType,
990 DBLENGTH *pcbSrcLength, DBLENGTH *pcbDstLength,
991 void *pSrc)
993 convert *This = impl_from_IDataConvert(iface);
994 FIXME("(%p)->(%d, %d, %p, %p, %p): stub\n", This, wSrcType, wDstType, pcbSrcLength, pcbDstLength, pSrc);
996 return E_NOTIMPL;
999 static const struct IDataConvertVtbl convert_vtbl =
1001 convert_QueryInterface,
1002 convert_AddRef,
1003 convert_Release,
1004 convert_DataConvert,
1005 convert_CanConvert,
1006 convert_GetConversionSize
1009 static HRESULT WINAPI dcinfo_QueryInterface(IDCInfo* iface, REFIID riid, void **obj)
1011 convert *This = impl_from_IDCInfo(iface);
1013 return IDataConvert_QueryInterface(&This->IDataConvert_iface, riid, obj);
1016 static ULONG WINAPI dcinfo_AddRef(IDCInfo* iface)
1018 convert *This = impl_from_IDCInfo(iface);
1020 return IDataConvert_AddRef(&This->IDataConvert_iface);
1023 static ULONG WINAPI dcinfo_Release(IDCInfo* iface)
1025 convert *This = impl_from_IDCInfo(iface);
1027 return IDataConvert_Release(&This->IDataConvert_iface);
1030 static HRESULT WINAPI dcinfo_GetInfo(IDCInfo *iface, ULONG num, DCINFOTYPE types[], DCINFO **info_ptr)
1032 convert *This = impl_from_IDCInfo(iface);
1033 ULONG i;
1034 DCINFO *infos;
1036 TRACE("(%p)->(%d, %p, %p)\n", This, num, types, info_ptr);
1038 *info_ptr = infos = CoTaskMemAlloc(num * sizeof(*infos));
1039 if(!infos) return E_OUTOFMEMORY;
1041 for(i = 0; i < num; i++)
1043 infos[i].eInfoType = types[i];
1044 VariantInit(&infos[i].vData);
1046 switch(types[i])
1048 case DCINFOTYPE_VERSION:
1049 V_VT(&infos[i].vData) = VT_UI4;
1050 V_UI4(&infos[i].vData) = This->version;
1051 break;
1055 return S_OK;
1058 static HRESULT WINAPI dcinfo_SetInfo(IDCInfo* iface, ULONG num, DCINFO info[])
1060 convert *This = impl_from_IDCInfo(iface);
1061 ULONG i;
1062 HRESULT hr = S_OK;
1064 TRACE("(%p)->(%d, %p)\n", This, num, info);
1066 for(i = 0; i < num; i++)
1068 switch(info[i].eInfoType)
1070 case DCINFOTYPE_VERSION:
1071 if(V_VT(&info[i].vData) != VT_UI4)
1073 FIXME("VERSION with vt %x\n", V_VT(&info[i].vData));
1074 hr = DB_S_ERRORSOCCURRED;
1075 break;
1077 This->version = V_UI4(&info[i].vData);
1078 break;
1080 default:
1081 FIXME("Unhandled info type %d (vt %x)\n", info[i].eInfoType, V_VT(&info[i].vData));
1084 return hr;
1087 static const struct IDCInfoVtbl dcinfo_vtbl =
1089 dcinfo_QueryInterface,
1090 dcinfo_AddRef,
1091 dcinfo_Release,
1092 dcinfo_GetInfo,
1093 dcinfo_SetInfo
1096 HRESULT create_oledb_convert(IUnknown *outer, void **obj)
1098 convert *This;
1100 TRACE("(%p, %p)\n", outer, obj);
1102 *obj = NULL;
1104 if(outer) return CLASS_E_NOAGGREGATION;
1106 This = HeapAlloc(GetProcessHeap(), 0, sizeof(*This));
1107 if(!This) return E_OUTOFMEMORY;
1109 This->IDataConvert_iface.lpVtbl = &convert_vtbl;
1110 This->IDCInfo_iface.lpVtbl = &dcinfo_vtbl;
1111 This->ref = 1;
1112 This->version = 0x110;
1114 *obj = &This->IDataConvert_iface;
1116 return S_OK;