TESTING -- override pthreads to fix gstreamer v5
[wine/multimedia.git] / dlls / ole2.dll16 / ole2.c
blob0052142ef71d1aad240f16f844b99d9bca52c6be
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 #include "windef.h"
33 #include "winbase.h"
34 #include "wingdi.h"
35 #include "winuser.h"
36 #include "wownt32.h"
37 #include "ole2.h"
38 #include "winerror.h"
40 #include "wine/winbase16.h"
41 #include "wine/wingdi16.h"
42 #include "wine/winuser16.h"
43 #include "ifs.h"
45 #include "wine/debug.h"
47 WINE_DEFAULT_DEBUG_CHANNEL(ole);
50 static HICON convert_icon_to_32( HICON16 icon16 )
52 CURSORICONINFO *info = GlobalLock16( icon16 );
53 void *and_bits = info + 1;
54 void *xor_bits = (BYTE *)and_bits + info->nHeight * 2 * ((info->nWidth + 15) / 16);
55 HICON ret = CreateIcon( 0, info->nWidth, info->nHeight, info->bPlanes, info->bBitsPerPixel,
56 and_bits, xor_bits );
57 GlobalUnlock16( icon16 );
58 return ret;
61 /******************************************************************************
62 * OleBuildVersion (OLE2.1)
64 DWORD WINAPI OleBuildVersion16(void)
66 return OleBuildVersion();
69 /***********************************************************************
70 * OleInitialize (OLE2.2)
72 HRESULT WINAPI OleInitialize16(LPVOID reserved)
74 return OleInitialize( reserved );
77 /******************************************************************************
78 * OleUninitialize (OLE2.3)
80 void WINAPI OleUninitialize16(void)
82 OleUninitialize();
85 /***********************************************************************
86 * DllGetClassObject (OLE2.4)
88 HRESULT WINAPI DllGetClassObject16(REFCLSID rclsid, REFIID iid, LPVOID *ppv)
90 FIXME("(%s, %s, %p): stub\n", debugstr_guid(rclsid), debugstr_guid(iid), ppv);
91 return E_NOTIMPL;
94 /******************************************************************************
95 * GetRunningObjectTable (OLE2.30)
97 HRESULT WINAPI GetRunningObjectTable16(DWORD reserved, LPRUNNINGOBJECTTABLE *pprot)
99 FIXME("(%d,%p),stub!\n",reserved,pprot);
100 return E_NOTIMPL;
103 /***********************************************************************
104 * RegisterDragDrop (OLE2.35)
106 HRESULT WINAPI RegisterDragDrop16(
107 HWND16 hwnd,
108 LPDROPTARGET pDropTarget
110 FIXME("(0x%04x,%p),stub!\n",hwnd,pDropTarget);
111 return S_OK;
114 /***********************************************************************
115 * RevokeDragDrop (OLE2.36)
117 HRESULT WINAPI RevokeDragDrop16(
118 HWND16 hwnd
120 FIXME("(0x%04x),stub!\n",hwnd);
121 return S_OK;
124 /******************************************************************************
125 * OleMetaFilePictFromIconAndLabel (OLE2.56)
127 * Returns a global memory handle to a metafile which contains the icon and
128 * label given.
129 * I guess the result of that should look somehow like desktop icons.
130 * If no hIcon is given, we load the icon via lpszSourceFile and iIconIndex.
131 * This code might be wrong at some places.
133 HGLOBAL16 WINAPI OleMetafilePictFromIconAndLabel16(
134 HICON16 icon16,
135 LPCOLESTR16 lpszLabel,
136 LPCOLESTR16 lpszSourceFile,
137 UINT16 iIconIndex
139 METAFILEPICT *pict;
140 HGLOBAL hmf;
141 HGLOBAL16 hmf16;
142 LPWSTR label = NULL, source = NULL;
143 DWORD len;
144 HICON icon = convert_icon_to_32( icon16 );
146 if (lpszLabel)
148 len = MultiByteToWideChar( CP_ACP, 0, lpszLabel, -1, NULL, 0 );
149 label = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
150 MultiByteToWideChar( CP_ACP, 0, lpszLabel, -1, label, len );
152 if (lpszSourceFile)
154 len = MultiByteToWideChar( CP_ACP, 0, lpszSourceFile, -1, NULL, 0 );
155 source = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
156 MultiByteToWideChar( CP_ACP, 0, lpszSourceFile, -1, source, len );
158 hmf = OleMetafilePictFromIconAndLabel( icon, label, source, iIconIndex );
159 HeapFree( GetProcessHeap(), 0, label );
160 HeapFree( GetProcessHeap(), 0, source );
161 DestroyIcon( icon );
163 if (!hmf) return 0;
164 pict = GlobalLock( hmf );
166 hmf16 = GlobalAlloc16(0, sizeof(METAFILEPICT16));
167 if (hmf16)
169 METAFILEPICT16 *pict16 = GlobalLock16( hmf16 );
170 pict16->mm = pict->mm;
171 pict16->xExt = pict->xExt;
172 pict16->yExt = pict->yExt;
173 len = GetMetaFileBitsEx( pict->hMF, 0, 0 );
174 pict16->hMF = GlobalAlloc16( GMEM_MOVEABLE, len );
175 GetMetaFileBitsEx( pict->hMF, len, GlobalLock16( pict16->hMF) );
176 GlobalUnlock16( pict16->hMF );
177 GlobalUnlock16( hmf16 );
179 DeleteMetaFile( pict->hMF );
180 GlobalUnlock( hmf );
181 GlobalFree( hmf );
182 return hmf16;
186 /******************************************************************************
187 * CreateItemMoniker (OLE2.27)
189 HRESULT WINAPI CreateItemMoniker16(LPCOLESTR16 lpszDelim,LPCOLESTR16 lpszItem,LPMONIKER* ppmk)
191 FIXME("(%s,%p),stub!\n",lpszDelim,ppmk);
192 *ppmk = NULL;
193 return E_NOTIMPL;
197 /******************************************************************************
198 * CreateFileMoniker (OLE2.28)
200 HRESULT WINAPI CreateFileMoniker16(LPCOLESTR16 lpszPathName,LPMONIKER* ppmk)
202 FIXME("(%s,%p),stub!\n",lpszPathName,ppmk);
203 return E_NOTIMPL;
206 /******************************************************************************
207 * OleSetMenuDescriptor (OLE2.41)
209 * PARAMS
210 * hOleMenu FIXME: Should probably be an HOLEMENU16.
212 HRESULT WINAPI OleSetMenuDescriptor16(
213 HOLEMENU hOleMenu,
214 HWND16 hwndFrame,
215 HWND16 hwndActiveObject,
216 LPOLEINPLACEFRAME lpFrame,
217 LPOLEINPLACEACTIVEOBJECT lpActiveObject)
219 FIXME("(%p, %x, %x, %p, %p), stub!\n", hOleMenu, hwndFrame, hwndActiveObject, lpFrame, lpActiveObject);
220 return E_NOTIMPL;
223 /******************************************************************************
224 * OleLoad [OLE2.12]
226 * PARAMS
227 * pStg Segmented LPSTORAGE pointer.
228 * pClientSite Segmented LPOLECLIENTSITE pointer.
230 HRESULT WINAPI OleLoad16(
231 SEGPTR pStg,
232 REFIID riid,
233 SEGPTR pClientSite,
234 LPVOID* ppvObj)
236 FIXME("(%x,%s,%x,%p), stub!\n", pStg, debugstr_guid(riid), pClientSite, ppvObj);
237 return E_NOTIMPL;
240 /******************************************************************************
241 * OleDoAutoConvert [OLE2.79]
243 HRESULT WINAPI OleDoAutoConvert16(LPSTORAGE pStg, LPCLSID pClsidNew)
245 FIXME("(%p,%p) : stub\n",pStg,pClsidNew);
246 return E_NOTIMPL;
249 /***********************************************************************
250 * OleSetClipboard [OLE2.49]
252 HRESULT WINAPI OleSetClipboard16(IDataObject* pDataObj)
254 FIXME("(%p): stub\n", pDataObj);
255 return S_OK;
258 /***********************************************************************
259 * OleGetClipboard [OLE2.50]
261 HRESULT WINAPI OleGetClipboard16(IDataObject** ppDataObj)
263 FIXME("(%p): stub\n", ppDataObj);
264 return E_NOTIMPL;
267 /***********************************************************************
268 * OleFlushClipboard [OLE2.76]
271 HRESULT WINAPI OleFlushClipboard16(void)
273 return OleFlushClipboard();
276 /***********************************************************************
277 * ReadClassStg (OLE2.18)
279 * This method reads the CLSID previously written to a storage object with
280 * the WriteClassStg.
282 * PARAMS
283 * pstg [I] Segmented LPSTORAGE pointer.
284 * pclsid [O] Pointer to where the CLSID is written
286 * RETURNS
287 * Success: S_OK.
288 * Failure: HRESULT code.
290 HRESULT WINAPI ReadClassStg16(SEGPTR pstg, CLSID *pclsid)
292 STATSTG16 statstg;
293 HANDLE16 hstatstg;
294 HRESULT hres;
295 DWORD args[3];
297 TRACE("(%x, %p)\n", pstg, pclsid);
299 if(pclsid==NULL)
300 return E_POINTER;
302 * read a STATSTG structure (contains the clsid) from the storage
304 args[0] = (DWORD)pstg; /* iface */
305 args[1] = WOWGlobalAllocLock16( 0, sizeof(STATSTG16), &hstatstg );
306 args[2] = STATFLAG_DEFAULT;
308 if (!WOWCallback16Ex(
309 (DWORD)((const IStorage16Vtbl*)MapSL(
310 (SEGPTR)((LPSTORAGE16)MapSL(pstg))->lpVtbl)
311 )->Stat,
312 WCB16_PASCAL,
313 3*sizeof(DWORD),
314 (LPVOID)args,
315 (LPDWORD)&hres
316 )) {
317 WOWGlobalUnlockFree16(args[1]);
318 ERR("CallTo16 IStorage16::Stat() failed, hres %x\n",hres);
319 return hres;
321 memcpy(&statstg, MapSL(args[1]), sizeof(STATSTG16));
322 WOWGlobalUnlockFree16(args[1]);
324 if(SUCCEEDED(hres)) {
325 *pclsid=statstg.clsid;
326 TRACE("clsid is %s\n", debugstr_guid(&statstg.clsid));
328 return hres;
331 /***********************************************************************
332 * GetConvertStg (OLE2.82)
334 HRESULT WINAPI GetConvertStg16(LPSTORAGE stg)
336 FIXME("unimplemented stub!\n");
337 return E_FAIL;
340 /***********************************************************************
341 * ReleaseStgMedium (OLE2.32)
343 VOID WINAPI ReleaseStgMedium16(LPSTGMEDIUM medium)
345 FIXME("%p: unimplemented stub!\n", medium);
348 /***********************************************************************
349 * WriteClassStg16 (OLE2.19)
351 HRESULT WINAPI WriteClassStg16(IStorage *stg, REFCLSID clsid)
353 FIXME("stub:%p %s\n", stg, debugstr_guid(clsid));
354 return STG_E_MEDIUMFULL;