oleaut32: Add some additional tests for QueryPathOfRegTypeLib, make them pass under...
[wine/multimedia.git] / dlls / ole2.dll16 / ole2.c
blobab0439032d8f67b02836cb342f50d68456a005ed
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);
51 #define HICON_16(h32) (LOWORD(h32))
52 #define HICON_32(h16) ((HICON)(ULONG_PTR)(h16))
53 #define HINSTANCE_32(h16) ((HINSTANCE)(ULONG_PTR)(h16))
55 /******************************************************************************
56 * OleBuildVersion (OLE2.1)
58 DWORD WINAPI OleBuildVersion16(void)
60 return OleBuildVersion();
63 /***********************************************************************
64 * OleInitialize (OLE2.2)
66 HRESULT WINAPI OleInitialize16(LPVOID reserved)
68 return OleInitialize( reserved );
71 /******************************************************************************
72 * OleUninitialize (OLE2.3)
74 void WINAPI OleUninitialize16(void)
76 return OleUninitialize();
79 /***********************************************************************
80 * DllGetClassObject (OLE2.4)
82 HRESULT WINAPI DllGetClassObject16(REFCLSID rclsid, REFIID iid, LPVOID *ppv)
84 FIXME("(%s, %s, %p): stub\n", debugstr_guid(rclsid), debugstr_guid(iid), ppv);
85 return E_NOTIMPL;
88 /******************************************************************************
89 * GetRunningObjectTable (OLE2.30)
91 HRESULT WINAPI GetRunningObjectTable16(DWORD reserved, LPRUNNINGOBJECTTABLE *pprot)
93 FIXME("(%d,%p),stub!\n",reserved,pprot);
94 return E_NOTIMPL;
97 /***********************************************************************
98 * RegisterDragDrop (OLE2.35)
100 HRESULT WINAPI RegisterDragDrop16(
101 HWND16 hwnd,
102 LPDROPTARGET pDropTarget
104 FIXME("(0x%04x,%p),stub!\n",hwnd,pDropTarget);
105 return S_OK;
108 /***********************************************************************
109 * RevokeDragDrop (OLE2.36)
111 HRESULT WINAPI RevokeDragDrop16(
112 HWND16 hwnd
114 FIXME("(0x%04x),stub!\n",hwnd);
115 return S_OK;
118 /******************************************************************************
119 * OleMetaFilePictFromIconAndLabel (OLE2.56)
121 * Returns a global memory handle to a metafile which contains the icon and
122 * label given.
123 * I guess the result of that should look somehow like desktop icons.
124 * If no hIcon is given, we load the icon via lpszSourceFile and iIconIndex.
125 * This code might be wrong at some places.
127 HGLOBAL16 WINAPI OleMetaFilePictFromIconAndLabel16(
128 HICON16 hIcon,
129 LPCOLESTR16 lpszLabel,
130 LPCOLESTR16 lpszSourceFile,
131 UINT16 iIconIndex
133 METAFILEPICT16 *mf16;
134 HGLOBAL16 hmf16;
135 HMETAFILE hmf;
136 INT mfSize;
137 HDC hdc;
139 if (!hIcon) {
140 if (lpszSourceFile) {
141 HINSTANCE16 hInstance = LoadLibrary16(lpszSourceFile);
143 /* load the icon at index from lpszSourceFile */
144 hIcon = HICON_16(LoadIconA(HINSTANCE_32(hInstance), (LPCSTR)(DWORD)iIconIndex));
145 FreeLibrary16(hInstance);
146 } else
147 return 0;
150 FIXME("(%04x, '%s', '%s', %d): incorrect metrics, please try to correct them !\n",
151 hIcon, lpszLabel, lpszSourceFile, iIconIndex);
153 hdc = CreateMetaFileW(NULL);
154 DrawIcon(hdc, 0, 0, HICON_32(hIcon)); /* FIXME */
155 TextOutA(hdc, 0, 0, lpszLabel, 1); /* FIXME */
156 hmf = CloseMetaFile(hdc);
158 hmf16 = GlobalAlloc16(0, sizeof(METAFILEPICT16));
159 mf16 = GlobalLock16(hmf16);
160 mf16->mm = MM_ANISOTROPIC;
161 mf16->xExt = 20; /* FIXME: bogus */
162 mf16->yExt = 20; /* ditto */
163 mfSize = GetMetaFileBitsEx(hmf, 0, 0);
164 mf16->hMF = GlobalAlloc16(GMEM_MOVEABLE, mfSize);
165 if(mf16->hMF)
167 GetMetaFileBitsEx(hmf, mfSize, GlobalLock16(mf16->hMF));
168 GlobalUnlock16(mf16->hMF);
170 return hmf16;
174 /******************************************************************************
175 * CreateItemMoniker (OLE2.27)
177 HRESULT WINAPI CreateItemMoniker16(LPCOLESTR16 lpszDelim,LPCOLESTR16 lpszItem,LPMONIKER* ppmk)
179 FIXME("(%s,%p),stub!\n",lpszDelim,ppmk);
180 *ppmk = NULL;
181 return E_NOTIMPL;
185 /******************************************************************************
186 * CreateFileMoniker (OLE2.28)
188 HRESULT WINAPI CreateFileMoniker16(LPCOLESTR16 lpszPathName,LPMONIKER* ppmk)
190 FIXME("(%s,%p),stub!\n",lpszPathName,ppmk);
191 return E_NOTIMPL;
194 /******************************************************************************
195 * OleSetMenuDescriptor (OLE2.41)
197 * PARAMS
198 * hOleMenu FIXME: Should probably be an HOLEMENU16.
200 HRESULT WINAPI OleSetMenuDescriptor16(
201 HOLEMENU hOleMenu,
202 HWND16 hwndFrame,
203 HWND16 hwndActiveObject,
204 LPOLEINPLACEFRAME lpFrame,
205 LPOLEINPLACEACTIVEOBJECT lpActiveObject)
207 FIXME("(%p, %x, %x, %p, %p), stub!\n", hOleMenu, hwndFrame, hwndActiveObject, lpFrame, lpActiveObject);
208 return E_NOTIMPL;
211 /******************************************************************************
212 * OleLoad [OLE2.12]
214 * PARAMS
215 * pStg Segmented LPSTORAGE pointer.
216 * pClientSite Segmented LPOLECLIENTSITE pointer.
218 HRESULT WINAPI OleLoad16(
219 SEGPTR pStg,
220 REFIID riid,
221 SEGPTR pClientSite,
222 LPVOID* ppvObj)
224 FIXME("(%x,%s,%x,%p), stub!\n", pStg, debugstr_guid(riid), pClientSite, ppvObj);
225 return E_NOTIMPL;
228 /******************************************************************************
229 * OleDoAutoConvert [OLE2.79]
231 HRESULT WINAPI OleDoAutoConvert16(LPSTORAGE pStg, LPCLSID pClsidNew)
233 FIXME("(%p,%p) : stub\n",pStg,pClsidNew);
234 return E_NOTIMPL;
237 /***********************************************************************
238 * OleSetClipboard [OLE2.49]
240 HRESULT WINAPI OleSetClipboard16(IDataObject* pDataObj)
242 FIXME("(%p): stub\n", pDataObj);
243 return S_OK;
246 /***********************************************************************
247 * OleGetClipboard [OLE2.50]
249 HRESULT WINAPI OleGetClipboard16(IDataObject** ppDataObj)
251 FIXME("(%p): stub\n", ppDataObj);
252 return E_NOTIMPL;
255 /***********************************************************************
256 * OleFlushClipboard [OLE2.76]
259 HRESULT WINAPI OleFlushClipboard16(void)
261 return OleFlushClipboard();
264 /***********************************************************************
265 * ReadClassStg (OLE2.18)
267 * This method reads the CLSID previously written to a storage object with
268 * the WriteClassStg.
270 * PARAMS
271 * pstg [I] Segmented LPSTORAGE pointer.
272 * pclsid [O] Pointer to where the CLSID is written
274 * RETURNS
275 * Success: S_OK.
276 * Failure: HRESULT code.
278 HRESULT WINAPI ReadClassStg16(SEGPTR pstg, CLSID *pclsid)
280 STATSTG16 statstg;
281 HANDLE16 hstatstg;
282 HRESULT hres;
283 DWORD args[3];
285 TRACE("(%x, %p)\n", pstg, pclsid);
287 if(pclsid==NULL)
288 return E_POINTER;
290 * read a STATSTG structure (contains the clsid) from the storage
292 args[0] = (DWORD)pstg; /* iface */
293 args[1] = WOWGlobalAllocLock16( 0, sizeof(STATSTG16), &hstatstg );
294 args[2] = STATFLAG_DEFAULT;
296 if (!WOWCallback16Ex(
297 (DWORD)((const IStorage16Vtbl*)MapSL(
298 (SEGPTR)((LPSTORAGE16)MapSL(pstg))->lpVtbl)
299 )->Stat,
300 WCB16_PASCAL,
301 3*sizeof(DWORD),
302 (LPVOID)args,
303 (LPDWORD)&hres
304 )) {
305 WOWGlobalUnlockFree16(args[1]);
306 ERR("CallTo16 IStorage16::Stat() failed, hres %x\n",hres);
307 return hres;
309 memcpy(&statstg, MapSL(args[1]), sizeof(STATSTG16));
310 WOWGlobalUnlockFree16(args[1]);
312 if(SUCCEEDED(hres)) {
313 *pclsid=statstg.clsid;
314 TRACE("clsid is %s\n", debugstr_guid(&statstg.clsid));
316 return hres;
319 /***********************************************************************
320 * GetConvertStg (OLE2.82)
322 HRESULT WINAPI GetConvertStg16(LPSTORAGE stg) {
323 FIXME("unimplemented stub!\n");
324 return E_FAIL;