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
38 #include "wine/winbase16.h"
39 #include "wine/wingdi16.h"
40 #include "wine/winuser16.h"
43 #include "wine/debug.h"
45 WINE_DEFAULT_DEBUG_CHANNEL(ole
);
47 #define E_INVALIDARG16 MAKE_SCODE(SEVERITY_ERROR, FACILITY_NULL, 3)
49 static HICON
convert_icon_to_32( HICON16 icon16
)
51 CURSORICONINFO
*info
= GlobalLock16( icon16
);
52 void *and_bits
= info
+ 1;
53 void *xor_bits
= (BYTE
*)and_bits
+ info
->nHeight
* 2 * ((info
->nWidth
+ 15) / 16);
54 HICON ret
= CreateIcon( 0, info
->nWidth
, info
->nHeight
, info
->bPlanes
, info
->bBitsPerPixel
,
56 GlobalUnlock16( icon16
);
60 /******************************************************************************
61 * OleBuildVersion (OLE2.1)
63 DWORD WINAPI
OleBuildVersion16(void)
65 return OleBuildVersion();
68 /***********************************************************************
69 * OleInitialize (OLE2.2)
71 HRESULT WINAPI
OleInitialize16(LPVOID reserved
)
73 return OleInitialize( reserved
);
76 /******************************************************************************
77 * OleUninitialize (OLE2.3)
79 void WINAPI
OleUninitialize16(void)
84 /***********************************************************************
85 * DllGetClassObject (OLE2.4)
87 HRESULT WINAPI
DllGetClassObject16(REFCLSID rclsid
, REFIID iid
, LPVOID
*ppv
)
89 FIXME("(%s, %s, %p): stub\n", debugstr_guid(rclsid
), debugstr_guid(iid
), ppv
);
93 /******************************************************************************
94 * GetRunningObjectTable (OLE2.30)
96 HRESULT WINAPI
GetRunningObjectTable16(DWORD reserved
, LPRUNNINGOBJECTTABLE
*pprot
)
98 FIXME("(%d,%p),stub!\n",reserved
,pprot
);
102 /***********************************************************************
103 * RegisterDragDrop (OLE2.35)
105 HRESULT WINAPI
RegisterDragDrop16(
107 LPDROPTARGET pDropTarget
109 FIXME("(0x%04x,%p),stub!\n",hwnd
,pDropTarget
);
113 /***********************************************************************
114 * RevokeDragDrop (OLE2.36)
116 HRESULT WINAPI
RevokeDragDrop16(
119 FIXME("(0x%04x),stub!\n",hwnd
);
123 /******************************************************************************
124 * OleMetaFilePictFromIconAndLabel (OLE2.56)
126 * Returns a global memory handle to a metafile which contains the icon and
128 * I guess the result of that should look somehow like desktop icons.
129 * If no hIcon is given, we load the icon via lpszSourceFile and iIconIndex.
130 * This code might be wrong at some places.
132 HGLOBAL16 WINAPI
OleMetafilePictFromIconAndLabel16(
134 LPCOLESTR16 lpszLabel
,
135 LPCOLESTR16 lpszSourceFile
,
141 LPWSTR label
= NULL
, source
= NULL
;
143 HICON icon
= convert_icon_to_32( icon16
);
147 len
= MultiByteToWideChar( CP_ACP
, 0, lpszLabel
, -1, NULL
, 0 );
148 label
= HeapAlloc( GetProcessHeap(), 0, len
* sizeof(WCHAR
) );
149 MultiByteToWideChar( CP_ACP
, 0, lpszLabel
, -1, label
, len
);
153 len
= MultiByteToWideChar( CP_ACP
, 0, lpszSourceFile
, -1, NULL
, 0 );
154 source
= HeapAlloc( GetProcessHeap(), 0, len
* sizeof(WCHAR
) );
155 MultiByteToWideChar( CP_ACP
, 0, lpszSourceFile
, -1, source
, len
);
157 hmf
= OleMetafilePictFromIconAndLabel( icon
, label
, source
, iIconIndex
);
158 HeapFree( GetProcessHeap(), 0, label
);
159 HeapFree( GetProcessHeap(), 0, source
);
163 pict
= GlobalLock( hmf
);
165 hmf16
= GlobalAlloc16(0, sizeof(METAFILEPICT16
));
168 METAFILEPICT16
*pict16
= GlobalLock16( hmf16
);
169 pict16
->mm
= pict
->mm
;
170 pict16
->xExt
= pict
->xExt
;
171 pict16
->yExt
= pict
->yExt
;
172 len
= GetMetaFileBitsEx( pict
->hMF
, 0, 0 );
173 pict16
->hMF
= GlobalAlloc16( GMEM_MOVEABLE
, len
);
174 GetMetaFileBitsEx( pict
->hMF
, len
, GlobalLock16( pict16
->hMF
) );
175 GlobalUnlock16( pict16
->hMF
);
176 GlobalUnlock16( hmf16
);
178 DeleteMetaFile( pict
->hMF
);
185 /******************************************************************************
186 * CreateItemMoniker (OLE2.27)
188 HRESULT WINAPI
CreateItemMoniker16(LPCOLESTR16 lpszDelim
,LPCOLESTR16 lpszItem
,LPMONIKER
* ppmk
)
190 FIXME("(%s,%p),stub!\n",lpszDelim
,ppmk
);
196 /******************************************************************************
197 * CreateFileMoniker (OLE2.28)
199 HRESULT WINAPI
CreateFileMoniker16(LPCOLESTR16 lpszPathName
,LPMONIKER
* ppmk
)
201 FIXME("(%s,%p),stub!\n",lpszPathName
,ppmk
);
205 /******************************************************************************
206 * OleSetMenuDescriptor (OLE2.41)
209 * hOleMenu FIXME: Should probably be an HOLEMENU16.
211 HRESULT WINAPI
OleSetMenuDescriptor16(
214 HWND16 hwndActiveObject
,
215 LPOLEINPLACEFRAME lpFrame
,
216 LPOLEINPLACEACTIVEOBJECT lpActiveObject
)
218 FIXME("(%p, %x, %x, %p, %p), stub!\n", hOleMenu
, hwndFrame
, hwndActiveObject
, lpFrame
, lpActiveObject
);
222 /******************************************************************************
226 * pStg Segmented LPSTORAGE pointer.
227 * pClientSite Segmented LPOLECLIENTSITE pointer.
229 HRESULT WINAPI
OleLoad16(
235 FIXME("(%x,%s,%x,%p), stub!\n", pStg
, debugstr_guid(riid
), pClientSite
, ppvObj
);
239 /******************************************************************************
240 * OleDoAutoConvert [OLE2.79]
242 HRESULT WINAPI
OleDoAutoConvert16(LPSTORAGE pStg
, LPCLSID pClsidNew
)
244 FIXME("(%p,%p) : stub\n",pStg
,pClsidNew
);
248 /***********************************************************************
249 * OleSetClipboard [OLE2.49]
251 HRESULT WINAPI
OleSetClipboard16(IDataObject
* pDataObj
)
253 FIXME("(%p): stub\n", pDataObj
);
257 /***********************************************************************
258 * OleGetClipboard [OLE2.50]
260 HRESULT WINAPI
OleGetClipboard16(IDataObject
** ppDataObj
)
262 FIXME("(%p): stub\n", ppDataObj
);
266 /***********************************************************************
267 * OleFlushClipboard [OLE2.76]
270 HRESULT WINAPI
OleFlushClipboard16(void)
272 return OleFlushClipboard();
275 #define GET_SEGPTR_METHOD_ADDR(ifacename,segptr,methodname) \
276 ((SEGPTR)((const ifacename##Vtbl*)MapSL((SEGPTR)((ifacename*)MapSL(segptr))->lpVtbl))->methodname)
278 /***********************************************************************
279 * ReadClassStg (OLE2.18)
281 * This method reads the CLSID previously written to a storage object with
285 * pstg [I] Segmented LPSTORAGE pointer.
286 * pclsid [O] Pointer to where the CLSID is written
290 * Failure: HRESULT code.
292 HRESULT WINAPI
ReadClassStg16(SEGPTR pstg
, CLSID
*pclsid
)
299 TRACE("(%x, %p)\n", pstg
, pclsid
);
302 return E_INVALIDARG16
;
304 memset(pclsid
, 0, sizeof(*pclsid
));
307 return E_INVALIDARG16
;
310 * read a STATSTG structure (contains the clsid) from the storage
312 args
[0] = pstg
; /* iface */
313 args
[1] = WOWGlobalAllocLock16( 0, sizeof(STATSTG16
), &hstatstg
);
314 args
[2] = STATFLAG_DEFAULT
;
316 if (!WOWCallback16Ex(
317 GET_SEGPTR_METHOD_ADDR(IStorage16
, pstg
, Stat
),
323 WOWGlobalUnlockFree16(args
[1]);
324 ERR("CallTo16 IStorage16::Stat() failed, hres %x\n",hres
);
327 memcpy(&statstg
, MapSL(args
[1]), sizeof(STATSTG16
));
328 WOWGlobalUnlockFree16(args
[1]);
330 if(SUCCEEDED(hres
)) {
331 *pclsid
=statstg
.clsid
;
332 TRACE("clsid is %s\n", debugstr_guid(&statstg
.clsid
));
337 /***********************************************************************
338 * ReadClassStm (OLE2.20)
340 HRESULT WINAPI
ReadClassStm16(SEGPTR stream
, CLSID
*clsid
)
342 HANDLE16 hclsid
, hread
;
346 TRACE("(0x%x, %p)\n", stream
, clsid
);
349 return E_INVALIDARG16
;
351 memset(clsid
, 0, sizeof(*clsid
));
354 return E_INVALIDARG16
;
356 args
[0] = stream
; /* iface */
357 args
[1] = WOWGlobalAllocLock16( 0, sizeof(CLSID
), &hclsid
);
358 args
[2] = sizeof(CLSID
);
359 args
[3] = WOWGlobalAllocLock16( 0, sizeof(ULONG
), &hread
);
362 GET_SEGPTR_METHOD_ADDR(IStream16
, stream
, Read
),
370 memcpy(&readlen
, MapSL(args
[3]), sizeof(readlen
));
371 if (readlen
== sizeof(CLSID
))
372 memcpy(clsid
, MapSL(args
[1]), sizeof(CLSID
));
374 hres
= STG_E_READFAULT
;
376 TRACE("clsid is %s\n", debugstr_guid(clsid
));
380 ERR("CallTo16 IStream16::Read() failed, hres %x\n", hres
);
383 WOWGlobalUnlockFree16(args
[1]);
384 WOWGlobalUnlockFree16(args
[3]);
389 /***********************************************************************
390 * GetConvertStg (OLE2.82)
392 HRESULT WINAPI
GetConvertStg16(LPSTORAGE stg
)
394 FIXME("unimplemented stub!\n");
398 /***********************************************************************
399 * ReleaseStgMedium (OLE2.32)
401 VOID WINAPI
ReleaseStgMedium16(LPSTGMEDIUM medium
)
403 FIXME("%p: unimplemented stub!\n", medium
);
406 /***********************************************************************
407 * WriteClassStg16 (OLE2.19)
409 HRESULT WINAPI
WriteClassStg16(IStorage
*stg
, REFCLSID clsid
)
411 FIXME("stub:%p %s\n", stg
, debugstr_guid(clsid
));
412 return STG_E_MEDIUMFULL
;