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
40 #include "wine/winbase16.h"
41 #include "wine/wingdi16.h"
42 #include "wine/winuser16.h"
45 #include "wine/debug.h"
47 WINE_DEFAULT_DEBUG_CHANNEL(ole
);
49 #define E_INVALIDARG16 MAKE_SCODE(SEVERITY_ERROR, FACILITY_NULL, 3)
51 static HICON
convert_icon_to_32( HICON16 icon16
)
53 CURSORICONINFO
*info
= GlobalLock16( icon16
);
54 void *and_bits
= info
+ 1;
55 void *xor_bits
= (BYTE
*)and_bits
+ info
->nHeight
* 2 * ((info
->nWidth
+ 15) / 16);
56 HICON ret
= CreateIcon( 0, info
->nWidth
, info
->nHeight
, info
->bPlanes
, info
->bBitsPerPixel
,
58 GlobalUnlock16( icon16
);
62 /******************************************************************************
63 * OleBuildVersion (OLE2.1)
65 DWORD WINAPI
OleBuildVersion16(void)
67 return OleBuildVersion();
70 /***********************************************************************
71 * OleInitialize (OLE2.2)
73 HRESULT WINAPI
OleInitialize16(LPVOID reserved
)
75 return OleInitialize( reserved
);
78 /******************************************************************************
79 * OleUninitialize (OLE2.3)
81 void WINAPI
OleUninitialize16(void)
86 /***********************************************************************
87 * DllGetClassObject (OLE2.4)
89 HRESULT WINAPI
DllGetClassObject16(REFCLSID rclsid
, REFIID iid
, LPVOID
*ppv
)
91 FIXME("(%s, %s, %p): stub\n", debugstr_guid(rclsid
), debugstr_guid(iid
), ppv
);
95 /******************************************************************************
96 * GetRunningObjectTable (OLE2.30)
98 HRESULT WINAPI
GetRunningObjectTable16(DWORD reserved
, LPRUNNINGOBJECTTABLE
*pprot
)
100 FIXME("(%d,%p),stub!\n",reserved
,pprot
);
104 /***********************************************************************
105 * RegisterDragDrop (OLE2.35)
107 HRESULT WINAPI
RegisterDragDrop16(
109 LPDROPTARGET pDropTarget
111 FIXME("(0x%04x,%p),stub!\n",hwnd
,pDropTarget
);
115 /***********************************************************************
116 * RevokeDragDrop (OLE2.36)
118 HRESULT WINAPI
RevokeDragDrop16(
121 FIXME("(0x%04x),stub!\n",hwnd
);
125 /******************************************************************************
126 * OleMetaFilePictFromIconAndLabel (OLE2.56)
128 * Returns a global memory handle to a metafile which contains the icon and
130 * I guess the result of that should look somehow like desktop icons.
131 * If no hIcon is given, we load the icon via lpszSourceFile and iIconIndex.
132 * This code might be wrong at some places.
134 HGLOBAL16 WINAPI
OleMetafilePictFromIconAndLabel16(
136 LPCOLESTR16 lpszLabel
,
137 LPCOLESTR16 lpszSourceFile
,
143 LPWSTR label
= NULL
, source
= NULL
;
145 HICON icon
= convert_icon_to_32( icon16
);
149 len
= MultiByteToWideChar( CP_ACP
, 0, lpszLabel
, -1, NULL
, 0 );
150 label
= HeapAlloc( GetProcessHeap(), 0, len
* sizeof(WCHAR
) );
151 MultiByteToWideChar( CP_ACP
, 0, lpszLabel
, -1, label
, len
);
155 len
= MultiByteToWideChar( CP_ACP
, 0, lpszSourceFile
, -1, NULL
, 0 );
156 source
= HeapAlloc( GetProcessHeap(), 0, len
* sizeof(WCHAR
) );
157 MultiByteToWideChar( CP_ACP
, 0, lpszSourceFile
, -1, source
, len
);
159 hmf
= OleMetafilePictFromIconAndLabel( icon
, label
, source
, iIconIndex
);
160 HeapFree( GetProcessHeap(), 0, label
);
161 HeapFree( GetProcessHeap(), 0, source
);
165 pict
= GlobalLock( hmf
);
167 hmf16
= GlobalAlloc16(0, sizeof(METAFILEPICT16
));
170 METAFILEPICT16
*pict16
= GlobalLock16( hmf16
);
171 pict16
->mm
= pict
->mm
;
172 pict16
->xExt
= pict
->xExt
;
173 pict16
->yExt
= pict
->yExt
;
174 len
= GetMetaFileBitsEx( pict
->hMF
, 0, 0 );
175 pict16
->hMF
= GlobalAlloc16( GMEM_MOVEABLE
, len
);
176 GetMetaFileBitsEx( pict
->hMF
, len
, GlobalLock16( pict16
->hMF
) );
177 GlobalUnlock16( pict16
->hMF
);
178 GlobalUnlock16( hmf16
);
180 DeleteMetaFile( pict
->hMF
);
187 /******************************************************************************
188 * CreateItemMoniker (OLE2.27)
190 HRESULT WINAPI
CreateItemMoniker16(LPCOLESTR16 lpszDelim
,LPCOLESTR16 lpszItem
,LPMONIKER
* ppmk
)
192 FIXME("(%s,%p),stub!\n",lpszDelim
,ppmk
);
198 /******************************************************************************
199 * CreateFileMoniker (OLE2.28)
201 HRESULT WINAPI
CreateFileMoniker16(LPCOLESTR16 lpszPathName
,LPMONIKER
* ppmk
)
203 FIXME("(%s,%p),stub!\n",lpszPathName
,ppmk
);
207 /******************************************************************************
208 * OleSetMenuDescriptor (OLE2.41)
211 * hOleMenu FIXME: Should probably be an HOLEMENU16.
213 HRESULT WINAPI
OleSetMenuDescriptor16(
216 HWND16 hwndActiveObject
,
217 LPOLEINPLACEFRAME lpFrame
,
218 LPOLEINPLACEACTIVEOBJECT lpActiveObject
)
220 FIXME("(%p, %x, %x, %p, %p), stub!\n", hOleMenu
, hwndFrame
, hwndActiveObject
, lpFrame
, lpActiveObject
);
224 /******************************************************************************
228 * pStg Segmented LPSTORAGE pointer.
229 * pClientSite Segmented LPOLECLIENTSITE pointer.
231 HRESULT WINAPI
OleLoad16(
237 FIXME("(%x,%s,%x,%p), stub!\n", pStg
, debugstr_guid(riid
), pClientSite
, ppvObj
);
241 /******************************************************************************
242 * OleDoAutoConvert [OLE2.79]
244 HRESULT WINAPI
OleDoAutoConvert16(LPSTORAGE pStg
, LPCLSID pClsidNew
)
246 FIXME("(%p,%p) : stub\n",pStg
,pClsidNew
);
250 /***********************************************************************
251 * OleSetClipboard [OLE2.49]
253 HRESULT WINAPI
OleSetClipboard16(IDataObject
* pDataObj
)
255 FIXME("(%p): stub\n", pDataObj
);
259 /***********************************************************************
260 * OleGetClipboard [OLE2.50]
262 HRESULT WINAPI
OleGetClipboard16(IDataObject
** ppDataObj
)
264 FIXME("(%p): stub\n", ppDataObj
);
268 /***********************************************************************
269 * OleFlushClipboard [OLE2.76]
272 HRESULT WINAPI
OleFlushClipboard16(void)
274 return OleFlushClipboard();
277 #define GET_SEGPTR_METHOD_ADDR(ifacename,segptr,methodname) \
278 ((SEGPTR)((const ifacename##Vtbl*)MapSL((SEGPTR)((ifacename*)MapSL(segptr))->lpVtbl))->methodname)
280 /***********************************************************************
281 * ReadClassStg (OLE2.18)
283 * This method reads the CLSID previously written to a storage object with
287 * pstg [I] Segmented LPSTORAGE pointer.
288 * pclsid [O] Pointer to where the CLSID is written
292 * Failure: HRESULT code.
294 HRESULT WINAPI
ReadClassStg16(SEGPTR pstg
, CLSID
*pclsid
)
301 TRACE("(%x, %p)\n", pstg
, pclsid
);
304 return E_INVALIDARG16
;
306 memset(pclsid
, 0, sizeof(*pclsid
));
309 return E_INVALIDARG16
;
312 * read a STATSTG structure (contains the clsid) from the storage
314 args
[0] = pstg
; /* iface */
315 args
[1] = WOWGlobalAllocLock16( 0, sizeof(STATSTG16
), &hstatstg
);
316 args
[2] = STATFLAG_DEFAULT
;
318 if (!WOWCallback16Ex(
319 GET_SEGPTR_METHOD_ADDR(IStorage16
, pstg
, Stat
),
325 WOWGlobalUnlockFree16(args
[1]);
326 ERR("CallTo16 IStorage16::Stat() failed, hres %x\n",hres
);
329 memcpy(&statstg
, MapSL(args
[1]), sizeof(STATSTG16
));
330 WOWGlobalUnlockFree16(args
[1]);
332 if(SUCCEEDED(hres
)) {
333 *pclsid
=statstg
.clsid
;
334 TRACE("clsid is %s\n", debugstr_guid(&statstg
.clsid
));
339 /***********************************************************************
340 * ReadClassStm (OLE2.20)
342 HRESULT WINAPI
ReadClassStm16(SEGPTR stream
, CLSID
*clsid
)
344 HANDLE16 hclsid
, hread
;
348 TRACE("(0x%x, %p)\n", stream
, clsid
);
351 return E_INVALIDARG16
;
353 memset(clsid
, 0, sizeof(*clsid
));
356 return E_INVALIDARG16
;
358 args
[0] = stream
; /* iface */
359 args
[1] = WOWGlobalAllocLock16( 0, sizeof(CLSID
), &hclsid
);
360 args
[2] = sizeof(CLSID
);
361 args
[3] = WOWGlobalAllocLock16( 0, sizeof(ULONG
), &hread
);
364 GET_SEGPTR_METHOD_ADDR(IStream16
, stream
, Read
),
372 memcpy(&readlen
, MapSL(args
[3]), sizeof(readlen
));
373 if (readlen
== sizeof(CLSID
))
374 memcpy(clsid
, MapSL(args
[1]), sizeof(CLSID
));
376 hres
= STG_E_READFAULT
;
378 TRACE("clsid is %s\n", debugstr_guid(clsid
));
382 ERR("CallTo16 IStream16::Read() failed, hres %x\n", hres
);
385 WOWGlobalUnlockFree16(args
[1]);
386 WOWGlobalUnlockFree16(args
[3]);
391 /***********************************************************************
392 * GetConvertStg (OLE2.82)
394 HRESULT WINAPI
GetConvertStg16(LPSTORAGE stg
)
396 FIXME("unimplemented stub!\n");
400 /***********************************************************************
401 * ReleaseStgMedium (OLE2.32)
403 VOID WINAPI
ReleaseStgMedium16(LPSTGMEDIUM medium
)
405 FIXME("%p: unimplemented stub!\n", medium
);
408 /***********************************************************************
409 * WriteClassStg16 (OLE2.19)
411 HRESULT WINAPI
WriteClassStg16(IStorage
*stg
, REFCLSID clsid
)
413 FIXME("stub:%p %s\n", stg
, debugstr_guid(clsid
));
414 return STG_E_MEDIUMFULL
;