oledb32: GetConversionSize only returns a valid size of BSTR.
[wine.git] / dlls / ole2.dll16 / ole2.c
blob25fb14113029177d7e6f0f9918e7abba4b24e69f
2 /*
3 * OLE2 library - 16 bit only interfaces
5 * Copyright 1995 Martin von Loewis
6 * Copyright 1999 Francis Beaudet
7 * Copyright 1999 Noel Borthwick
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
24 #include "config.h"
26 #include <assert.h>
27 #include <stdlib.h>
28 #include <stdarg.h>
29 #include <stdio.h>
30 #include <string.h>
32 #define NONAMELESSUNION
33 #define NONAMELESSSTRUCT
34 #include "windef.h"
35 #include "winbase.h"
36 #include "wingdi.h"
37 #include "winuser.h"
38 #include "wownt32.h"
39 #include "ole2.h"
40 #include "winerror.h"
42 #include "wine/winbase16.h"
43 #include "wine/wingdi16.h"
44 #include "wine/winuser16.h"
45 #include "ifs.h"
47 #include "wine/debug.h"
49 WINE_DEFAULT_DEBUG_CHANNEL(ole);
52 static HICON convert_icon_to_32( HICON16 icon16 )
54 CURSORICONINFO *info = GlobalLock16( icon16 );
55 void *and_bits = info + 1;
56 void *xor_bits = (BYTE *)and_bits + info->nHeight * 2 * ((info->nWidth + 15) / 16);
57 HICON ret = CreateIcon( 0, info->nWidth, info->nHeight, info->bPlanes, info->bBitsPerPixel,
58 and_bits, xor_bits );
59 GlobalUnlock16( icon16 );
60 return ret;
63 /******************************************************************************
64 * OleBuildVersion (OLE2.1)
66 DWORD WINAPI OleBuildVersion16(void)
68 return OleBuildVersion();
71 /***********************************************************************
72 * OleInitialize (OLE2.2)
74 HRESULT WINAPI OleInitialize16(LPVOID reserved)
76 return OleInitialize( reserved );
79 /******************************************************************************
80 * OleUninitialize (OLE2.3)
82 void WINAPI OleUninitialize16(void)
84 OleUninitialize();
87 /***********************************************************************
88 * DllGetClassObject (OLE2.4)
90 HRESULT WINAPI DllGetClassObject16(REFCLSID rclsid, REFIID iid, LPVOID *ppv)
92 FIXME("(%s, %s, %p): stub\n", debugstr_guid(rclsid), debugstr_guid(iid), ppv);
93 return E_NOTIMPL;
96 /******************************************************************************
97 * GetRunningObjectTable (OLE2.30)
99 HRESULT WINAPI GetRunningObjectTable16(DWORD reserved, LPRUNNINGOBJECTTABLE *pprot)
101 FIXME("(%d,%p),stub!\n",reserved,pprot);
102 return E_NOTIMPL;
105 /***********************************************************************
106 * RegisterDragDrop (OLE2.35)
108 HRESULT WINAPI RegisterDragDrop16(
109 HWND16 hwnd,
110 LPDROPTARGET pDropTarget
112 FIXME("(0x%04x,%p),stub!\n",hwnd,pDropTarget);
113 return S_OK;
116 /***********************************************************************
117 * RevokeDragDrop (OLE2.36)
119 HRESULT WINAPI RevokeDragDrop16(
120 HWND16 hwnd
122 FIXME("(0x%04x),stub!\n",hwnd);
123 return S_OK;
126 /******************************************************************************
127 * OleMetaFilePictFromIconAndLabel (OLE2.56)
129 * Returns a global memory handle to a metafile which contains the icon and
130 * label given.
131 * I guess the result of that should look somehow like desktop icons.
132 * If no hIcon is given, we load the icon via lpszSourceFile and iIconIndex.
133 * This code might be wrong at some places.
135 HGLOBAL16 WINAPI OleMetafilePictFromIconAndLabel16(
136 HICON16 icon16,
137 LPCOLESTR16 lpszLabel,
138 LPCOLESTR16 lpszSourceFile,
139 UINT16 iIconIndex
141 METAFILEPICT *pict;
142 HGLOBAL hmf;
143 HGLOBAL16 hmf16;
144 LPWSTR label = NULL, source = NULL;
145 DWORD len;
146 HICON icon = convert_icon_to_32( icon16 );
148 if (lpszLabel)
150 len = MultiByteToWideChar( CP_ACP, 0, lpszLabel, -1, NULL, 0 );
151 label = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
152 MultiByteToWideChar( CP_ACP, 0, lpszLabel, -1, label, len );
154 if (lpszSourceFile)
156 len = MultiByteToWideChar( CP_ACP, 0, lpszSourceFile, -1, NULL, 0 );
157 source = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
158 MultiByteToWideChar( CP_ACP, 0, lpszSourceFile, -1, source, len );
160 hmf = OleMetafilePictFromIconAndLabel( icon, label, source, iIconIndex );
161 HeapFree( GetProcessHeap(), 0, label );
162 HeapFree( GetProcessHeap(), 0, source );
163 DestroyIcon( icon );
165 if (!hmf) return 0;
166 pict = GlobalLock( hmf );
168 hmf16 = GlobalAlloc16(0, sizeof(METAFILEPICT16));
169 if (hmf16)
171 METAFILEPICT16 *pict16 = GlobalLock16( hmf16 );
172 pict16->mm = pict->mm;
173 pict16->xExt = pict->xExt;
174 pict16->yExt = pict->yExt;
175 len = GetMetaFileBitsEx( pict->hMF, 0, 0 );
176 pict16->hMF = GlobalAlloc16( GMEM_MOVEABLE, len );
177 GetMetaFileBitsEx( pict->hMF, len, GlobalLock16( pict16->hMF) );
178 GlobalUnlock16( pict16->hMF );
179 GlobalUnlock16( hmf16 );
181 DeleteMetaFile( pict->hMF );
182 GlobalUnlock( hmf );
183 GlobalFree( hmf );
184 return hmf16;
188 /******************************************************************************
189 * CreateItemMoniker (OLE2.27)
191 HRESULT WINAPI CreateItemMoniker16(LPCOLESTR16 lpszDelim,LPCOLESTR16 lpszItem,LPMONIKER* ppmk)
193 FIXME("(%s,%p),stub!\n",lpszDelim,ppmk);
194 *ppmk = NULL;
195 return E_NOTIMPL;
199 /******************************************************************************
200 * CreateFileMoniker (OLE2.28)
202 HRESULT WINAPI CreateFileMoniker16(LPCOLESTR16 lpszPathName,LPMONIKER* ppmk)
204 FIXME("(%s,%p),stub!\n",lpszPathName,ppmk);
205 return E_NOTIMPL;
208 /******************************************************************************
209 * OleSetMenuDescriptor (OLE2.41)
211 * PARAMS
212 * hOleMenu FIXME: Should probably be an HOLEMENU16.
214 HRESULT WINAPI OleSetMenuDescriptor16(
215 HOLEMENU hOleMenu,
216 HWND16 hwndFrame,
217 HWND16 hwndActiveObject,
218 LPOLEINPLACEFRAME lpFrame,
219 LPOLEINPLACEACTIVEOBJECT lpActiveObject)
221 FIXME("(%p, %x, %x, %p, %p), stub!\n", hOleMenu, hwndFrame, hwndActiveObject, lpFrame, lpActiveObject);
222 return E_NOTIMPL;
225 /******************************************************************************
226 * OleLoad [OLE2.12]
228 * PARAMS
229 * pStg Segmented LPSTORAGE pointer.
230 * pClientSite Segmented LPOLECLIENTSITE pointer.
232 HRESULT WINAPI OleLoad16(
233 SEGPTR pStg,
234 REFIID riid,
235 SEGPTR pClientSite,
236 LPVOID* ppvObj)
238 FIXME("(%x,%s,%x,%p), stub!\n", pStg, debugstr_guid(riid), pClientSite, ppvObj);
239 return E_NOTIMPL;
242 /******************************************************************************
243 * OleDoAutoConvert [OLE2.79]
245 HRESULT WINAPI OleDoAutoConvert16(LPSTORAGE pStg, LPCLSID pClsidNew)
247 FIXME("(%p,%p) : stub\n",pStg,pClsidNew);
248 return E_NOTIMPL;
251 /***********************************************************************
252 * OleSetClipboard [OLE2.49]
254 HRESULT WINAPI OleSetClipboard16(IDataObject* pDataObj)
256 FIXME("(%p): stub\n", pDataObj);
257 return S_OK;
260 /***********************************************************************
261 * OleGetClipboard [OLE2.50]
263 HRESULT WINAPI OleGetClipboard16(IDataObject** ppDataObj)
265 FIXME("(%p): stub\n", ppDataObj);
266 return E_NOTIMPL;
269 /***********************************************************************
270 * OleFlushClipboard [OLE2.76]
273 HRESULT WINAPI OleFlushClipboard16(void)
275 return OleFlushClipboard();
278 /***********************************************************************
279 * ReadClassStg (OLE2.18)
281 * This method reads the CLSID previously written to a storage object with
282 * the WriteClassStg.
284 * PARAMS
285 * pstg [I] Segmented LPSTORAGE pointer.
286 * pclsid [O] Pointer to where the CLSID is written
288 * RETURNS
289 * Success: S_OK.
290 * Failure: HRESULT code.
292 HRESULT WINAPI ReadClassStg16(SEGPTR pstg, CLSID *pclsid)
294 STATSTG16 statstg;
295 HANDLE16 hstatstg;
296 HRESULT hres;
297 DWORD args[3];
299 TRACE("(%x, %p)\n", pstg, pclsid);
301 if(pclsid==NULL)
302 return E_POINTER;
304 * read a STATSTG structure (contains the clsid) from the storage
306 args[0] = (DWORD)pstg; /* iface */
307 args[1] = WOWGlobalAllocLock16( 0, sizeof(STATSTG16), &hstatstg );
308 args[2] = STATFLAG_DEFAULT;
310 if (!WOWCallback16Ex(
311 (DWORD)((const IStorage16Vtbl*)MapSL(
312 (SEGPTR)((LPSTORAGE16)MapSL(pstg))->lpVtbl)
313 )->Stat,
314 WCB16_PASCAL,
315 3*sizeof(DWORD),
316 (LPVOID)args,
317 (LPDWORD)&hres
318 )) {
319 WOWGlobalUnlockFree16(args[1]);
320 ERR("CallTo16 IStorage16::Stat() failed, hres %x\n",hres);
321 return hres;
323 memcpy(&statstg, MapSL(args[1]), sizeof(STATSTG16));
324 WOWGlobalUnlockFree16(args[1]);
326 if(SUCCEEDED(hres)) {
327 *pclsid=statstg.clsid;
328 TRACE("clsid is %s\n", debugstr_guid(&statstg.clsid));
330 return hres;
333 /***********************************************************************
334 * GetConvertStg (OLE2.82)
336 HRESULT WINAPI GetConvertStg16(LPSTORAGE stg)
338 FIXME("unimplemented stub!\n");
339 return E_FAIL;
342 /***********************************************************************
343 * ReleaseStgMedium (OLE2.32)
345 VOID WINAPI ReleaseStgMedium16(LPSTGMEDIUM medium)
347 FIXME("%p: unimplemented stub!\n", medium);