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 /***********************************************************************
276 * OleIsCurrentClipboard [OLE2.77]
278 HRESULT WINAPI
OleIsCurrentClipboard16(IDataObject
* pDataObj
)
280 FIXME("(%p): stub\n", pDataObj
);
284 #define GET_SEGPTR_METHOD_ADDR(ifacename,segptr,methodname) \
285 ((SEGPTR)((const ifacename##Vtbl*)MapSL((SEGPTR)((ifacename*)MapSL(segptr))->lpVtbl))->methodname)
287 /***********************************************************************
288 * ReadClassStg (OLE2.18)
290 * This method reads the CLSID previously written to a storage object with
294 * pstg [I] Segmented LPSTORAGE pointer.
295 * pclsid [O] Pointer to where the CLSID is written
299 * Failure: HRESULT code.
301 HRESULT WINAPI
ReadClassStg16(SEGPTR pstg
, CLSID
*pclsid
)
308 TRACE("(%x, %p)\n", pstg
, pclsid
);
311 return E_INVALIDARG16
;
313 memset(pclsid
, 0, sizeof(*pclsid
));
316 return E_INVALIDARG16
;
319 * read a STATSTG structure (contains the clsid) from the storage
321 args
[0] = pstg
; /* iface */
322 args
[1] = WOWGlobalAllocLock16( 0, sizeof(STATSTG16
), &hstatstg
);
323 args
[2] = STATFLAG_DEFAULT
;
325 if (!WOWCallback16Ex(
326 GET_SEGPTR_METHOD_ADDR(IStorage16
, pstg
, Stat
),
332 WOWGlobalUnlockFree16(args
[1]);
333 ERR("CallTo16 IStorage16::Stat() failed, hres %x\n",hres
);
336 memcpy(&statstg
, MapSL(args
[1]), sizeof(STATSTG16
));
337 WOWGlobalUnlockFree16(args
[1]);
339 if(SUCCEEDED(hres
)) {
340 *pclsid
=statstg
.clsid
;
341 TRACE("clsid is %s\n", debugstr_guid(&statstg
.clsid
));
346 /***********************************************************************
347 * ReadClassStm (OLE2.20)
349 HRESULT WINAPI
ReadClassStm16(SEGPTR stream
, CLSID
*clsid
)
351 HANDLE16 hclsid
, hread
;
355 TRACE("(0x%x, %p)\n", stream
, clsid
);
358 return E_INVALIDARG16
;
360 memset(clsid
, 0, sizeof(*clsid
));
363 return E_INVALIDARG16
;
365 args
[0] = stream
; /* iface */
366 args
[1] = WOWGlobalAllocLock16( 0, sizeof(CLSID
), &hclsid
);
367 args
[2] = sizeof(CLSID
);
368 args
[3] = WOWGlobalAllocLock16( 0, sizeof(ULONG
), &hread
);
371 GET_SEGPTR_METHOD_ADDR(IStream16
, stream
, Read
),
379 memcpy(&readlen
, MapSL(args
[3]), sizeof(readlen
));
380 if (readlen
== sizeof(CLSID
))
381 memcpy(clsid
, MapSL(args
[1]), sizeof(CLSID
));
383 hres
= STG_E_READFAULT
;
385 TRACE("clsid is %s\n", debugstr_guid(clsid
));
389 ERR("CallTo16 IStream16::Read() failed, hres %x\n", hres
);
392 WOWGlobalUnlockFree16(args
[1]);
393 WOWGlobalUnlockFree16(args
[3]);
398 /***********************************************************************
399 * GetConvertStg (OLE2.82)
401 HRESULT WINAPI
GetConvertStg16(LPSTORAGE stg
)
403 FIXME("unimplemented stub!\n");
407 /***********************************************************************
408 * ReleaseStgMedium (OLE2.32)
410 VOID WINAPI
ReleaseStgMedium16(LPSTGMEDIUM medium
)
412 FIXME("%p: unimplemented stub!\n", medium
);
415 /***********************************************************************
416 * WriteClassStg16 (OLE2.19)
418 HRESULT WINAPI
WriteClassStg16(IStorage
*stg
, REFCLSID clsid
)
420 FIXME("stub:%p %s\n", stg
, debugstr_guid(clsid
));
421 return STG_E_MEDIUMFULL
;