2 * handling of SHELL32.DLL OLE-Objects
4 * Copyright 1997 Marcus Meissner
5 * Copyright 1998 Juergen Schmied <juergen.schmied@metronet.de>
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
29 #define NONAMELESSUNION
40 #include "shimgdata.h"
44 #include "undocshell.h"
45 #include "wine/unicode.h"
46 #include "shell32_main.h"
48 #include "wine/debug.h"
52 WINE_DEFAULT_DEBUG_CHANNEL(shell
);
54 extern INT WINAPI
SHStringFromGUIDW(REFGUID guid
, LPWSTR lpszDest
, INT cchMax
); /* shlwapi.24 */
55 static HRESULT WINAPI
ShellImageDataFactory_Constructor(IUnknown
*outer
, REFIID riid
, void **obj
);
57 /**************************************************************************
58 * Default ClassFactory types
60 typedef HRESULT (CALLBACK
*LPFNCREATEINSTANCE
)(IUnknown
* pUnkOuter
, REFIID riid
, LPVOID
* ppvObject
);
61 static IClassFactory
* IDefClF_fnConstructor(LPFNCREATEINSTANCE lpfnCI
, PLONG pcRefDll
, REFIID riidInst
);
63 /* this table contains all CLSIDs of shell32 objects */
66 LPFNCREATEINSTANCE lpfnCI
;
67 } InterfaceTable
[] = {
69 {&CLSID_ApplicationAssociationRegistration
, ApplicationAssociationRegistration_Constructor
},
70 {&CLSID_ApplicationDestinations
, ApplicationDestinations_Constructor
},
71 {&CLSID_AutoComplete
, IAutoComplete_Constructor
},
72 {&CLSID_ControlPanel
, IControlPanel_Constructor
},
73 {&CLSID_DragDropHelper
, IDropTargetHelper_Constructor
},
74 {&CLSID_FolderShortcut
, FolderShortcut_Constructor
},
75 {&CLSID_MyComputer
, ISF_MyComputer_Constructor
},
76 {&CLSID_MyDocuments
, MyDocuments_Constructor
},
77 {&CLSID_NetworkPlaces
, ISF_NetworkPlaces_Constructor
},
78 {&CLSID_Printers
, Printers_Constructor
},
79 {&CLSID_QueryAssociations
, QueryAssociations_Constructor
},
80 {&CLSID_RecycleBin
, RecycleBin_Constructor
},
81 {&CLSID_ShellDesktop
, ISF_Desktop_Constructor
},
82 {&CLSID_ShellFSFolder
, IFSFolder_Constructor
},
83 {&CLSID_ShellItem
, IShellItem_Constructor
},
84 {&CLSID_ShellLink
, IShellLink_Constructor
},
85 {&CLSID_UnixDosFolder
, UnixDosFolder_Constructor
},
86 {&CLSID_UnixFolder
, UnixFolder_Constructor
},
87 {&CLSID_ExplorerBrowser
,ExplorerBrowser_Constructor
},
88 {&CLSID_KnownFolderManager
, KnownFolderManager_Constructor
},
89 {&CLSID_Shell
, IShellDispatch_Constructor
},
90 {&CLSID_DestinationList
, CustomDestinationList_Constructor
},
91 {&CLSID_ShellImageDataFactory
, ShellImageDataFactory_Constructor
},
92 {&CLSID_FileOperation
, IFileOperation_Constructor
},
96 /*************************************************************************
97 * SHCoCreateInstance [SHELL32.102]
99 * Equivalent to CoCreateInstance. Under Windows 9x this function could sometimes
100 * use the shell32 built-in "mini-COM" without the need to load ole32.dll - see
101 * SHLoadOLE for details.
103 * Under wine if a "LoadWithoutCOM" value is present or the object resides in
104 * shell32.dll the function will load the object manually without the help of ole32
107 * exported by ordinal
110 * CoCreateInstance, SHLoadOLE
112 HRESULT WINAPI
SHCoCreateInstance(
121 const CLSID
* myclsid
= clsid
;
122 WCHAR sKeyName
[MAX_PATH
];
123 static const WCHAR sCLSID
[] = {'C','L','S','I','D','\\','\0'};
125 static const WCHAR sInProcServer32
[] = {'\\','I','n','p','r','o','c','S','e','r','v','e','r','3','2','\0'};
126 static const WCHAR sLoadWithoutCOM
[] = {'L','o','a','d','W','i','t','h','o','u','t','C','O','M','\0'};
127 WCHAR sDllPath
[MAX_PATH
];
130 IClassFactory
* pcf
= NULL
;
132 if(!ppv
) return E_POINTER
;
135 /* if the clsid is a string, convert it */
138 if (!aclsid
) return REGDB_E_CLASSNOTREG
;
139 SHCLSIDFromStringW(aclsid
, &iid
);
143 TRACE("(%p,%s,unk:%p,%s,%p)\n",
144 aclsid
,shdebugstr_guid(myclsid
),pUnkOuter
,shdebugstr_guid(refiid
),ppv
);
146 if (SUCCEEDED(DllGetClassObject(myclsid
, &IID_IClassFactory
,(LPVOID
*)&pcf
)))
148 hres
= IClassFactory_CreateInstance(pcf
, pUnkOuter
, refiid
, ppv
);
149 IClassFactory_Release(pcf
);
153 /* we look up the dll path in the registry */
154 SHStringFromGUIDW(myclsid
, sClassID
, ARRAY_SIZE(sClassID
));
155 lstrcpyW(sKeyName
, sCLSID
);
156 lstrcatW(sKeyName
, sClassID
);
157 lstrcatW(sKeyName
, sInProcServer32
);
159 if (RegOpenKeyExW(HKEY_CLASSES_ROOT
, sKeyName
, 0, KEY_READ
, &hKey
))
160 return E_ACCESSDENIED
;
162 /* if a special registry key is set, we load a shell extension without help of OLE32 */
163 if (!SHQueryValueExW(hKey
, sLoadWithoutCOM
, 0, 0, 0, 0))
165 /* load an external dll without ole32 */
167 typedef HRESULT (CALLBACK
*DllGetClassObjectFunc
)(REFCLSID clsid
, REFIID iid
, LPVOID
*ppv
);
168 DllGetClassObjectFunc DllGetClassObject
;
170 dwSize
= sizeof(sDllPath
);
171 SHQueryValueExW(hKey
, NULL
, 0,0, sDllPath
, &dwSize
);
173 if ((hLibrary
= LoadLibraryExW(sDllPath
, 0, LOAD_WITH_ALTERED_SEARCH_PATH
)) == 0) {
174 ERR("couldn't load InprocServer32 dll %s\n", debugstr_w(sDllPath
));
175 hres
= E_ACCESSDENIED
;
177 } else if (!(DllGetClassObject
= (DllGetClassObjectFunc
)GetProcAddress(hLibrary
, "DllGetClassObject"))) {
178 ERR("couldn't find function DllGetClassObject in %s\n", debugstr_w(sDllPath
));
179 FreeLibrary( hLibrary
);
180 hres
= E_ACCESSDENIED
;
182 } else if (FAILED(hres
= DllGetClassObject(myclsid
, &IID_IClassFactory
, (LPVOID
*)&pcf
))) {
183 TRACE("GetClassObject failed 0x%08x\n", hres
);
187 hres
= IClassFactory_CreateInstance(pcf
, pUnkOuter
, refiid
, ppv
);
188 IClassFactory_Release(pcf
);
191 /* load an external dll in the usual way */
192 hres
= CoCreateInstance(myclsid
, pUnkOuter
, CLSCTX_INPROC_SERVER
, refiid
, ppv
);
196 if (hKey
) RegCloseKey(hKey
);
199 ERR("failed (0x%08x) to create CLSID:%s IID:%s\n",
200 hres
, shdebugstr_guid(myclsid
), shdebugstr_guid(refiid
));
201 ERR("class not found in registry\n");
204 TRACE("-- instance: %p\n",*ppv
);
208 /*************************************************************************
209 * DllGetClassObject [SHELL32.@]
210 * SHDllGetClassObject [SHELL32.128]
212 HRESULT WINAPI
DllGetClassObject(REFCLSID rclsid
, REFIID iid
, LPVOID
*ppv
)
214 IClassFactory
* pcf
= NULL
;
218 TRACE("CLSID:%s,IID:%s\n",shdebugstr_guid(rclsid
),shdebugstr_guid(iid
));
220 if (!ppv
) return E_INVALIDARG
;
223 /* search our internal interface table */
224 for(i
=0;InterfaceTable
[i
].clsid
;i
++) {
225 if(IsEqualIID(InterfaceTable
[i
].clsid
, rclsid
)) {
226 TRACE("index[%u]\n", i
);
227 pcf
= IDefClF_fnConstructor(InterfaceTable
[i
].lpfnCI
, NULL
, NULL
);
233 FIXME("failed for CLSID=%s\n", shdebugstr_guid(rclsid
));
234 return CLASS_E_CLASSNOTAVAILABLE
;
237 hres
= IClassFactory_QueryInterface(pcf
, iid
, ppv
);
238 IClassFactory_Release(pcf
);
240 TRACE("-- pointer to class factory: %p\n",*ppv
);
244 /*************************************************************************
245 * SHCLSIDFromString [SHELL32.147]
247 * Under Windows 9x this was an ANSI version of CLSIDFromString. It also allowed
248 * to avoid dependency on ole32.dll (see SHLoadOLE for details).
250 * Under Windows NT/2000/XP this is equivalent to CLSIDFromString
253 * exported by ordinal
256 * CLSIDFromString, SHLoadOLE
258 DWORD WINAPI
SHCLSIDFromStringA (LPCSTR clsid
, CLSID
*id
)
261 TRACE("(%p(%s) %p)\n", clsid
, clsid
, id
);
262 if (!MultiByteToWideChar( CP_ACP
, 0, clsid
, -1, buffer
, ARRAY_SIZE(buffer
) ))
263 return CO_E_CLASSSTRING
;
264 return CLSIDFromString( buffer
, id
);
266 DWORD WINAPI
SHCLSIDFromStringW (LPCWSTR clsid
, CLSID
*id
)
268 TRACE("(%p(%s) %p)\n", clsid
, debugstr_w(clsid
), id
);
269 return CLSIDFromString(clsid
, id
);
271 DWORD WINAPI
SHCLSIDFromStringAW (LPCVOID clsid
, CLSID
*id
)
273 if (SHELL_OsIsUnicode())
274 return SHCLSIDFromStringW (clsid
, id
);
275 return SHCLSIDFromStringA (clsid
, id
);
278 /*************************************************************************
279 * SHGetMalloc [SHELL32.@]
281 * Equivalent to CoGetMalloc(MEMCTX_TASK, ...). Under Windows 9x this function
282 * could use the shell32 built-in "mini-COM" without the need to load ole32.dll -
283 * see SHLoadOLE for details.
286 * lpmal [O] Destination for IMalloc interface.
289 * Success: S_OK. lpmal contains the shells IMalloc interface.
290 * Failure. An HRESULT error code.
293 * CoGetMalloc, SHLoadOLE
295 HRESULT WINAPI
SHGetMalloc(LPMALLOC
*lpmal
)
297 TRACE("(%p)\n", lpmal
);
298 return CoGetMalloc(MEMCTX_TASK
, lpmal
);
301 /*************************************************************************
302 * SHAlloc [SHELL32.196]
304 * Equivalent to CoTaskMemAlloc. Under Windows 9x this function could use
305 * the shell32 built-in "mini-COM" without the need to load ole32.dll -
306 * see SHLoadOLE for details.
309 * exported by ordinal
312 * CoTaskMemAlloc, SHLoadOLE
314 LPVOID WINAPI
SHAlloc(DWORD len
)
318 ret
= CoTaskMemAlloc(len
);
319 TRACE("%u bytes at %p\n",len
, ret
);
323 /*************************************************************************
324 * SHFree [SHELL32.195]
326 * Equivalent to CoTaskMemFree. Under Windows 9x this function could use
327 * the shell32 built-in "mini-COM" without the need to load ole32.dll -
328 * see SHLoadOLE for details.
331 * exported by ordinal
334 * CoTaskMemFree, SHLoadOLE
336 void WINAPI
SHFree(LPVOID pv
)
342 /*************************************************************************
343 * SHGetDesktopFolder [SHELL32.@]
345 HRESULT WINAPI
SHGetDesktopFolder(IShellFolder
**psf
)
349 TRACE("(%p)\n", psf
);
351 if(!psf
) return E_INVALIDARG
;
354 hres
= ISF_Desktop_Constructor(NULL
, &IID_IShellFolder
, (LPVOID
*)psf
);
356 TRACE("-- %p->(%p) 0x%08x\n", psf
, *psf
, hres
);
359 /**************************************************************************
360 * Default ClassFactory Implementation
362 * SHCreateDefClassObject
365 * Helper function for dlls without their own classfactory.
366 * A generic classfactory is returned.
367 * When the CreateInstance of the cf is called the callback is executed.
372 IClassFactory IClassFactory_iface
;
375 LPFNCREATEINSTANCE lpfnCI
;
376 const IID
* riidInst
;
377 LONG
* pcRefDll
; /* pointer to refcounter in external dll (ugrrr...) */
380 static inline IDefClFImpl
*impl_from_IClassFactory(IClassFactory
*iface
)
382 return CONTAINING_RECORD(iface
, IDefClFImpl
, IClassFactory_iface
);
385 static const IClassFactoryVtbl dclfvt
;
387 /**************************************************************************
388 * IDefClF_fnConstructor
391 static IClassFactory
* IDefClF_fnConstructor(LPFNCREATEINSTANCE lpfnCI
, PLONG pcRefDll
, REFIID riidInst
)
395 lpclf
= heap_alloc(sizeof(*lpclf
));
397 lpclf
->IClassFactory_iface
.lpVtbl
= &dclfvt
;
398 lpclf
->lpfnCI
= lpfnCI
;
399 lpclf
->pcRefDll
= pcRefDll
;
401 if (pcRefDll
) InterlockedIncrement(pcRefDll
);
402 lpclf
->riidInst
= riidInst
;
404 TRACE("(%p)%s\n",lpclf
, shdebugstr_guid(riidInst
));
405 return &lpclf
->IClassFactory_iface
;
407 /**************************************************************************
408 * IDefClF_fnQueryInterface
410 static HRESULT WINAPI
IDefClF_fnQueryInterface(
411 LPCLASSFACTORY iface
, REFIID riid
, LPVOID
*ppvObj
)
413 IDefClFImpl
*This
= impl_from_IClassFactory(iface
);
415 TRACE("(%p)->(%s)\n",This
,shdebugstr_guid(riid
));
419 if(IsEqualIID(riid
, &IID_IUnknown
) || IsEqualIID(riid
, &IID_IClassFactory
)) {
421 InterlockedIncrement(&This
->ref
);
425 TRACE("-- E_NOINTERFACE\n");
426 return E_NOINTERFACE
;
428 /******************************************************************************
431 static ULONG WINAPI
IDefClF_fnAddRef(LPCLASSFACTORY iface
)
433 IDefClFImpl
*This
= impl_from_IClassFactory(iface
);
434 ULONG refCount
= InterlockedIncrement(&This
->ref
);
436 TRACE("(%p)->(count=%u)\n", This
, refCount
- 1);
440 /******************************************************************************
443 static ULONG WINAPI
IDefClF_fnRelease(LPCLASSFACTORY iface
)
445 IDefClFImpl
*This
= impl_from_IClassFactory(iface
);
446 ULONG refCount
= InterlockedDecrement(&This
->ref
);
448 TRACE("(%p)->(count=%u)\n", This
, refCount
+ 1);
452 if (This
->pcRefDll
) InterlockedDecrement(This
->pcRefDll
);
454 TRACE("-- destroying IClassFactory(%p)\n",This
);
460 /******************************************************************************
461 * IDefClF_fnCreateInstance
463 static HRESULT WINAPI
IDefClF_fnCreateInstance(
464 LPCLASSFACTORY iface
, LPUNKNOWN pUnkOuter
, REFIID riid
, LPVOID
*ppvObject
)
466 IDefClFImpl
*This
= impl_from_IClassFactory(iface
);
468 TRACE("%p->(%p,%s,%p)\n",This
,pUnkOuter
,shdebugstr_guid(riid
),ppvObject
);
472 if ( This
->riidInst
==NULL
||
473 IsEqualCLSID(riid
, This
->riidInst
) ||
474 IsEqualCLSID(riid
, &IID_IUnknown
) )
476 return This
->lpfnCI(pUnkOuter
, riid
, ppvObject
);
479 ERR("unknown IID requested %s\n",shdebugstr_guid(riid
));
480 return E_NOINTERFACE
;
482 /******************************************************************************
483 * IDefClF_fnLockServer
485 static HRESULT WINAPI
IDefClF_fnLockServer(LPCLASSFACTORY iface
, BOOL fLock
)
487 IDefClFImpl
*This
= impl_from_IClassFactory(iface
);
488 TRACE("%p->(0x%x), not implemented\n",This
, fLock
);
492 static const IClassFactoryVtbl dclfvt
=
494 IDefClF_fnQueryInterface
,
497 IDefClF_fnCreateInstance
,
501 /******************************************************************************
502 * SHCreateDefClassObject [SHELL32.70]
504 HRESULT WINAPI
SHCreateDefClassObject(
507 LPFNCREATEINSTANCE lpfnCI
, /* [in] create instance callback entry */
508 LPDWORD pcRefDll
, /* [in/out] ref count of the dll */
509 REFIID riidInst
) /* [in] optional interface to the instance */
513 TRACE("%s %p %p %p %s\n",
514 shdebugstr_guid(riid
), ppv
, lpfnCI
, pcRefDll
, shdebugstr_guid(riidInst
));
516 if (! IsEqualCLSID(riid
, &IID_IClassFactory
) ) return E_NOINTERFACE
;
517 if (! (pcf
= IDefClF_fnConstructor(lpfnCI
, (PLONG
)pcRefDll
, riidInst
))) return E_OUTOFMEMORY
;
522 /*************************************************************************
523 * DragAcceptFiles [SHELL32.@]
525 void WINAPI
DragAcceptFiles(HWND hWnd
, BOOL b
)
529 if( !IsWindow(hWnd
) ) return;
530 exstyle
= GetWindowLongA(hWnd
,GWL_EXSTYLE
);
532 exstyle
|= WS_EX_ACCEPTFILES
;
534 exstyle
&= ~WS_EX_ACCEPTFILES
;
535 SetWindowLongA(hWnd
,GWL_EXSTYLE
,exstyle
);
538 /*************************************************************************
539 * DragFinish [SHELL32.@]
541 void WINAPI
DragFinish(HDROP h
)
547 /*************************************************************************
548 * DragQueryPoint [SHELL32.@]
550 BOOL WINAPI
DragQueryPoint(HDROP hDrop
, POINT
*p
)
552 DROPFILES
*lpDropFileStruct
;
557 lpDropFileStruct
= GlobalLock(hDrop
);
559 *p
= lpDropFileStruct
->pt
;
560 bRet
= !lpDropFileStruct
->fNC
;
566 /*************************************************************************
567 * DragQueryFileA [SHELL32.@]
568 * DragQueryFile [SHELL32.@]
570 UINT WINAPI
DragQueryFileA(
578 DROPFILES
*lpDropFileStruct
= GlobalLock(hDrop
);
580 TRACE("(%p, %x, %p, %u)\n", hDrop
,lFile
,lpszFile
,lLength
);
582 if(!lpDropFileStruct
) goto end
;
584 lpDrop
= (LPSTR
) lpDropFileStruct
+ lpDropFileStruct
->pFiles
;
586 if(lpDropFileStruct
->fWide
) {
587 LPWSTR lpszFileW
= NULL
;
589 if(lpszFile
&& lFile
!= 0xFFFFFFFF) {
590 lpszFileW
= heap_alloc(lLength
*sizeof(WCHAR
));
591 if(lpszFileW
== NULL
) {
595 i
= DragQueryFileW(hDrop
, lFile
, lpszFileW
, lLength
);
598 WideCharToMultiByte(CP_ACP
, 0, lpszFileW
, -1, lpszFile
, lLength
, 0, NULL
);
599 heap_free(lpszFileW
);
606 while (*lpDrop
++); /* skip filename */
609 i
= (lFile
== 0xFFFFFFFF) ? i
: 0;
615 if (!lpszFile
) goto end
; /* needed buffer size */
616 lstrcpynA (lpszFile
, lpDrop
, lLength
);
622 /*************************************************************************
623 * DragQueryFileW [SHELL32.@]
625 UINT WINAPI
DragQueryFileW(
633 DROPFILES
*lpDropFileStruct
= GlobalLock(hDrop
);
635 TRACE("(%p, %x, %p, %u)\n", hDrop
,lFile
,lpszwFile
,lLength
);
637 if(!lpDropFileStruct
) goto end
;
639 lpwDrop
= (LPWSTR
) ((LPSTR
)lpDropFileStruct
+ lpDropFileStruct
->pFiles
);
641 if(lpDropFileStruct
->fWide
== FALSE
) {
642 LPSTR lpszFileA
= NULL
;
644 if(lpszwFile
&& lFile
!= 0xFFFFFFFF) {
645 lpszFileA
= heap_alloc(lLength
);
646 if(lpszFileA
== NULL
) {
650 i
= DragQueryFileA(hDrop
, lFile
, lpszFileA
, lLength
);
653 MultiByteToWideChar(CP_ACP
, 0, lpszFileA
, -1, lpszwFile
, lLength
);
654 heap_free(lpszFileA
);
662 while (*lpwDrop
++); /* skip filename */
665 i
= (lFile
== 0xFFFFFFFF) ? i
: 0;
670 i
= strlenW(lpwDrop
);
671 if ( !lpszwFile
) goto end
; /* needed buffer size */
672 lstrcpynW (lpszwFile
, lpwDrop
, lLength
);
678 /*************************************************************************
679 * SHPropStgCreate [SHELL32.685]
681 HRESULT WINAPI
SHPropStgCreate(IPropertySetStorage
*psstg
, REFFMTID fmtid
,
682 const CLSID
*pclsid
, DWORD grfFlags
, DWORD grfMode
,
683 DWORD dwDisposition
, IPropertyStorage
**ppstg
, UINT
*puCodePage
)
689 TRACE("%p %s %s %x %x %x %p %p\n", psstg
, debugstr_guid(fmtid
), debugstr_guid(pclsid
),
690 grfFlags
, grfMode
, dwDisposition
, ppstg
, puCodePage
);
692 hres
= IPropertySetStorage_Open(psstg
, fmtid
, grfMode
, ppstg
);
694 switch(dwDisposition
) {
696 if(SUCCEEDED(hres
)) {
697 IPropertyStorage_Release(*ppstg
);
698 hres
= IPropertySetStorage_Delete(psstg
, fmtid
);
707 hres
= IPropertySetStorage_Create(psstg
, fmtid
, pclsid
,
708 grfFlags
, grfMode
, ppstg
);
715 prop
.ulKind
= PRSPEC_PROPID
;
716 prop
.u
.propid
= PID_CODEPAGE
;
717 hres
= IPropertyStorage_ReadMultiple(*ppstg
, 1, &prop
, &ret
);
718 if(FAILED(hres
) || ret
.vt
!=VT_I2
)
721 *puCodePage
= ret
.iVal
;
728 /*************************************************************************
729 * SHPropStgReadMultiple [SHELL32.688]
731 HRESULT WINAPI
SHPropStgReadMultiple(IPropertyStorage
*pps
, UINT uCodePage
,
732 ULONG cpspec
, const PROPSPEC
*rgpspec
, PROPVARIANT
*rgvar
)
737 FIXME("%p %u %u %p %p\n", pps
, uCodePage
, cpspec
, rgpspec
, rgvar
);
739 memset(rgvar
, 0, cpspec
*sizeof(PROPVARIANT
));
740 hres
= IPropertyStorage_ReadMultiple(pps
, cpspec
, rgpspec
, rgvar
);
748 prop
.ulKind
= PRSPEC_PROPID
;
749 prop
.u
.propid
= PID_CODEPAGE
;
750 hres
= IPropertyStorage_ReadMultiple(pps
, 1, &prop
, &ret
);
751 if(FAILED(hres
) || ret
.vt
!=VT_I2
)
754 uCodePage
= ret
.iVal
;
757 hres
= IPropertyStorage_Stat(pps
, &stat
);
761 /* TODO: do something with codepage and stat */
765 /*************************************************************************
766 * SHPropStgWriteMultiple [SHELL32.689]
768 HRESULT WINAPI
SHPropStgWriteMultiple(IPropertyStorage
*pps
, UINT
*uCodePage
,
769 ULONG cpspec
, const PROPSPEC
*rgpspec
, PROPVARIANT
*rgvar
, PROPID propidNameFirst
)
775 FIXME("%p %p %u %p %p %d\n", pps
, uCodePage
, cpspec
, rgpspec
, rgvar
, propidNameFirst
);
777 hres
= IPropertyStorage_Stat(pps
, &stat
);
781 if(uCodePage
&& *uCodePage
)
782 codepage
= *uCodePage
;
787 prop
.ulKind
= PRSPEC_PROPID
;
788 prop
.u
.propid
= PID_CODEPAGE
;
789 hres
= IPropertyStorage_ReadMultiple(pps
, 1, &prop
, &ret
);
792 if(ret
.vt
!=VT_I2
|| !ret
.iVal
)
797 *uCodePage
= codepage
;
800 /* TODO: do something with codepage and stat */
802 hres
= IPropertyStorage_WriteMultiple(pps
, cpspec
, rgpspec
, rgvar
, propidNameFirst
);
806 /*************************************************************************
807 * SHCreateQueryCancelAutoPlayMoniker [SHELL32.@]
809 HRESULT WINAPI
SHCreateQueryCancelAutoPlayMoniker(IMoniker
**moniker
)
811 TRACE("%p\n", moniker
);
813 if (!moniker
) return E_INVALIDARG
;
814 return CreateClassMoniker(&CLSID_QueryCancelAutoPlay
, moniker
);
817 static HRESULT
gpstatus_to_hresult(GpStatus status
)
823 case InvalidParameter
:
826 return E_OUTOFMEMORY
;
834 /* IShellImageData */
837 IShellImageData IShellImageData_iface
;
844 static inline ShellImageData
*impl_from_IShellImageData(IShellImageData
*iface
)
846 return CONTAINING_RECORD(iface
, ShellImageData
, IShellImageData_iface
);
849 static HRESULT WINAPI
ShellImageData_QueryInterface(IShellImageData
*iface
, REFIID riid
, void **obj
)
851 ShellImageData
*This
= impl_from_IShellImageData(iface
);
853 TRACE("%p, %s, %p\n", This
, debugstr_guid(riid
), obj
);
855 if (IsEqualIID(riid
, &IID_IShellImageData
) || IsEqualIID(riid
, &IID_IUnknown
))
857 *obj
= &This
->IShellImageData_iface
;
858 IShellImageData_AddRef(iface
);
863 return E_NOINTERFACE
;
866 static ULONG WINAPI
ShellImageData_AddRef(IShellImageData
*iface
)
868 ShellImageData
*This
= impl_from_IShellImageData(iface
);
869 ULONG ref
= InterlockedIncrement(&This
->ref
);
871 TRACE("%p, %u\n", This
, ref
);
876 static ULONG WINAPI
ShellImageData_Release(IShellImageData
*iface
)
878 ShellImageData
*This
= impl_from_IShellImageData(iface
);
879 ULONG ref
= InterlockedDecrement(&This
->ref
);
881 TRACE("%p, %u\n", This
, ref
);
885 GdipDisposeImage(This
->image
);
886 heap_free(This
->path
);
893 static HRESULT WINAPI
ShellImageData_Decode(IShellImageData
*iface
, DWORD flags
, ULONG cx_desired
, ULONG cy_desired
)
895 ShellImageData
*This
= impl_from_IShellImageData(iface
);
899 TRACE("%p, %#x, %u, %u\n", This
, flags
, cx_desired
, cy_desired
);
904 if (flags
& SHIMGDEC_LOADFULL
)
905 FIXME("LOADFULL flag ignored\n");
907 hr
= gpstatus_to_hresult(GdipLoadImageFromFile(This
->path
, &image
));
911 if (flags
& SHIMGDEC_THUMBNAIL
)
913 hr
= gpstatus_to_hresult(GdipGetImageThumbnail(image
, cx_desired
, cy_desired
, &This
->image
, NULL
, NULL
));
914 GdipDisposeImage(image
);
922 static HRESULT WINAPI
ShellImageData_Draw(IShellImageData
*iface
, HDC hdc
, RECT
*dest
, RECT
*src
)
924 ShellImageData
*This
= impl_from_IShellImageData(iface
);
925 GpGraphics
*graphics
;
928 TRACE("%p, %p, %s, %s\n", This
, hdc
, wine_dbgstr_rect(dest
), wine_dbgstr_rect(src
));
939 hr
= gpstatus_to_hresult(GdipCreateFromHDC(hdc
, &graphics
));
943 hr
= gpstatus_to_hresult(GdipDrawImageRectRectI(graphics
, This
->image
, dest
->left
, dest
->top
, dest
->right
- dest
->left
,
944 dest
->bottom
- dest
->top
, src
->left
, src
->top
, src
->right
- src
->left
, src
->bottom
- src
->top
,
945 UnitPixel
, NULL
, NULL
, NULL
));
946 GdipDeleteGraphics(graphics
);
951 static HRESULT WINAPI
ShellImageData_NextFrame(IShellImageData
*iface
)
953 ShellImageData
*This
= impl_from_IShellImageData(iface
);
955 FIXME("%p: stub\n", This
);
960 static HRESULT WINAPI
ShellImageData_NextPage(IShellImageData
*iface
)
962 ShellImageData
*This
= impl_from_IShellImageData(iface
);
964 FIXME("%p: stub\n", This
);
969 static HRESULT WINAPI
ShellImageData_PrevPage(IShellImageData
*iface
)
971 ShellImageData
*This
= impl_from_IShellImageData(iface
);
973 FIXME("%p: stub\n", This
);
978 static HRESULT WINAPI
ShellImageData_IsTransparent(IShellImageData
*iface
)
980 ShellImageData
*This
= impl_from_IShellImageData(iface
);
982 FIXME("%p: stub\n", This
);
987 static HRESULT WINAPI
ShellImageData_IsAnimated(IShellImageData
*iface
)
989 ShellImageData
*This
= impl_from_IShellImageData(iface
);
991 FIXME("%p: stub\n", This
);
996 static HRESULT WINAPI
ShellImageData_IsVector(IShellImageData
*iface
)
998 ShellImageData
*This
= impl_from_IShellImageData(iface
);
1000 FIXME("%p: stub\n", This
);
1005 static HRESULT WINAPI
ShellImageData_IsMultipage(IShellImageData
*iface
)
1007 ShellImageData
*This
= impl_from_IShellImageData(iface
);
1009 FIXME("%p: stub\n", This
);
1014 static HRESULT WINAPI
ShellImageData_IsEditable(IShellImageData
*iface
)
1016 ShellImageData
*This
= impl_from_IShellImageData(iface
);
1018 FIXME("%p: stub\n", This
);
1023 static HRESULT WINAPI
ShellImageData_IsPrintable(IShellImageData
*iface
)
1025 ShellImageData
*This
= impl_from_IShellImageData(iface
);
1027 FIXME("%p: stub\n", This
);
1032 static HRESULT WINAPI
ShellImageData_IsDecoded(IShellImageData
*iface
)
1034 ShellImageData
*This
= impl_from_IShellImageData(iface
);
1036 FIXME("%p: stub\n", This
);
1041 static HRESULT WINAPI
ShellImageData_GetCurrentPage(IShellImageData
*iface
, ULONG
*page
)
1043 ShellImageData
*This
= impl_from_IShellImageData(iface
);
1045 FIXME("%p: stub\n", This
);
1050 static HRESULT WINAPI
ShellImageData_GetPageCount(IShellImageData
*iface
, ULONG
*count
)
1052 ShellImageData
*This
= impl_from_IShellImageData(iface
);
1054 FIXME("%p, %p: stub\n", This
, count
);
1059 static HRESULT WINAPI
ShellImageDate_SelectPage(IShellImageData
*iface
, ULONG page
)
1061 ShellImageData
*This
= impl_from_IShellImageData(iface
);
1063 FIXME("%p, %u: stub\n", This
, page
);
1068 static HRESULT WINAPI
ShellImageData_GetSize(IShellImageData
*iface
, SIZE
*size
)
1070 ShellImageData
*This
= impl_from_IShellImageData(iface
);
1074 TRACE("%p, %p\n", This
, size
);
1079 hr
= gpstatus_to_hresult(GdipGetImageDimension(This
->image
, &cx
, &cy
));
1089 static HRESULT WINAPI
ShellImageData_GetRawDataFormat(IShellImageData
*iface
, GUID
*format
)
1091 ShellImageData
*This
= impl_from_IShellImageData(iface
);
1093 FIXME("%p, %p: stub\n", This
, format
);
1098 static HRESULT WINAPI
ShellImageData_GetPixelFormat(IShellImageData
*iface
, PixelFormat
*format
)
1100 ShellImageData
*This
= impl_from_IShellImageData(iface
);
1102 FIXME("%p, %p: stub\n", This
, format
);
1107 static HRESULT WINAPI
ShellImageData_GetDelay(IShellImageData
*iface
, DWORD
*delay
)
1109 ShellImageData
*This
= impl_from_IShellImageData(iface
);
1111 FIXME("%p, %p: stub\n", This
, delay
);
1116 static HRESULT WINAPI
ShellImageData_GetProperties(IShellImageData
*iface
, DWORD mode
, IPropertySetStorage
**props
)
1118 ShellImageData
*This
= impl_from_IShellImageData(iface
);
1120 FIXME("%p, %#x, %p: stub\n", This
, mode
, props
);
1125 static HRESULT WINAPI
ShellImageData_Rotate(IShellImageData
*iface
, DWORD angle
)
1127 ShellImageData
*This
= impl_from_IShellImageData(iface
);
1129 FIXME("%p, %u: stub\n", This
, angle
);
1134 static HRESULT WINAPI
ShellImageData_Scale(IShellImageData
*iface
, ULONG cx
, ULONG cy
, InterpolationMode mode
)
1136 ShellImageData
*This
= impl_from_IShellImageData(iface
);
1138 FIXME("%p, %u, %u, %#x: stub\n", This
, cx
, cy
, mode
);
1143 static HRESULT WINAPI
ShellImageData_DiscardEdit(IShellImageData
*iface
)
1145 ShellImageData
*This
= impl_from_IShellImageData(iface
);
1147 FIXME("%p: stub\n", This
);
1152 static HRESULT WINAPI
ShellImageDate_SetEncoderParams(IShellImageData
*iface
, IPropertyBag
*params
)
1154 ShellImageData
*This
= impl_from_IShellImageData(iface
);
1156 FIXME("%p, %p: stub\n", This
, params
);
1161 static HRESULT WINAPI
ShellImageData_DisplayName(IShellImageData
*iface
, LPWSTR name
, UINT count
)
1163 ShellImageData
*This
= impl_from_IShellImageData(iface
);
1165 FIXME("%p, %p, %u: stub\n", This
, name
, count
);
1170 static HRESULT WINAPI
ShellImageData_GetResolution(IShellImageData
*iface
, ULONG
*res_x
, ULONG
*res_y
)
1172 ShellImageData
*This
= impl_from_IShellImageData(iface
);
1174 FIXME("%p, %p, %p: stub\n", This
, res_x
, res_y
);
1179 static HRESULT WINAPI
ShellImageData_GetEncoderParams(IShellImageData
*iface
, GUID
*format
, EncoderParameters
**params
)
1181 ShellImageData
*This
= impl_from_IShellImageData(iface
);
1183 FIXME("%p, %p, %p: stub\n", This
, format
, params
);
1188 static HRESULT WINAPI
ShellImageData_RegisterAbort(IShellImageData
*iface
, IShellImageDataAbort
*abort
,
1189 IShellImageDataAbort
**prev
)
1191 ShellImageData
*This
= impl_from_IShellImageData(iface
);
1193 FIXME("%p, %p, %p: stub\n", This
, abort
, prev
);
1198 static HRESULT WINAPI
ShellImageData_CloneFrame(IShellImageData
*iface
, Image
**frame
)
1200 ShellImageData
*This
= impl_from_IShellImageData(iface
);
1202 FIXME("%p, %p: stub\n", This
, frame
);
1207 static HRESULT WINAPI
ShellImageData_ReplaceFrame(IShellImageData
*iface
, Image
*frame
)
1209 ShellImageData
*This
= impl_from_IShellImageData(iface
);
1211 FIXME("%p, %p: stub\n", This
, frame
);
1216 static const IShellImageDataVtbl ShellImageDataVtbl
=
1218 ShellImageData_QueryInterface
,
1219 ShellImageData_AddRef
,
1220 ShellImageData_Release
,
1221 ShellImageData_Decode
,
1222 ShellImageData_Draw
,
1223 ShellImageData_NextFrame
,
1224 ShellImageData_NextPage
,
1225 ShellImageData_PrevPage
,
1226 ShellImageData_IsTransparent
,
1227 ShellImageData_IsAnimated
,
1228 ShellImageData_IsVector
,
1229 ShellImageData_IsMultipage
,
1230 ShellImageData_IsEditable
,
1231 ShellImageData_IsPrintable
,
1232 ShellImageData_IsDecoded
,
1233 ShellImageData_GetCurrentPage
,
1234 ShellImageData_GetPageCount
,
1235 ShellImageDate_SelectPage
,
1236 ShellImageData_GetSize
,
1237 ShellImageData_GetRawDataFormat
,
1238 ShellImageData_GetPixelFormat
,
1239 ShellImageData_GetDelay
,
1240 ShellImageData_GetProperties
,
1241 ShellImageData_Rotate
,
1242 ShellImageData_Scale
,
1243 ShellImageData_DiscardEdit
,
1244 ShellImageDate_SetEncoderParams
,
1245 ShellImageData_DisplayName
,
1246 ShellImageData_GetResolution
,
1247 ShellImageData_GetEncoderParams
,
1248 ShellImageData_RegisterAbort
,
1249 ShellImageData_CloneFrame
,
1250 ShellImageData_ReplaceFrame
,
1253 static HRESULT
create_shellimagedata_from_path(const WCHAR
*path
, IShellImageData
**data
)
1255 ShellImageData
*This
;
1257 This
= SHAlloc(sizeof(*This
));
1259 This
->IShellImageData_iface
.lpVtbl
= &ShellImageDataVtbl
;
1262 This
->path
= strdupW(path
);
1265 *data
= &This
->IShellImageData_iface
;
1269 /* IShellImageDataFactory */
1270 static HRESULT WINAPI
ShellImageDataFactory_QueryInterface(IShellImageDataFactory
*iface
, REFIID riid
, void **obj
)
1272 TRACE("(%p, %s, %p)\n", iface
, debugstr_guid(riid
), obj
);
1274 if (IsEqualIID(&IID_IShellImageDataFactory
, riid
) || IsEqualIID(&IID_IUnknown
, riid
))
1280 FIXME("not implemented for %s\n", debugstr_guid(riid
));
1282 return E_NOINTERFACE
;
1285 IUnknown_AddRef((IUnknown
*)*obj
);
1289 static ULONG WINAPI
ShellImageDataFactory_AddRef(IShellImageDataFactory
*iface
)
1291 TRACE("(%p)\n", iface
);
1296 static ULONG WINAPI
ShellImageDataFactory_Release(IShellImageDataFactory
*iface
)
1298 TRACE("(%p)\n", iface
);
1303 static HRESULT WINAPI
ShellImageDataFactory_CreateIShellImageData(IShellImageDataFactory
*iface
, IShellImageData
**data
)
1305 FIXME("%p, %p: stub\n", iface
, data
);
1310 static HRESULT WINAPI
ShellImageDataFactory_CreateImageFromFile(IShellImageDataFactory
*iface
, const WCHAR
*path
,
1311 IShellImageData
**data
)
1313 TRACE("%p, %s, %p\n", iface
, debugstr_w(path
), data
);
1315 return create_shellimagedata_from_path(path
, data
);
1318 static HRESULT WINAPI
ShellImageDataFactory_CreateImageFromStream(IShellImageDataFactory
*iface
, IStream
*stream
,
1319 IShellImageData
**data
)
1321 FIXME("%p, %p, %p: stub\n", iface
, stream
, data
);
1326 static HRESULT WINAPI
ShellImageDataFactory_GetDataFormatFromPath(IShellImageDataFactory
*iface
, const WCHAR
*path
,
1329 FIXME("%p, %s, %p: stub\n", iface
, debugstr_w(path
), format
);
1334 static const IShellImageDataFactoryVtbl ShellImageDataFactoryVtbl
=
1336 ShellImageDataFactory_QueryInterface
,
1337 ShellImageDataFactory_AddRef
,
1338 ShellImageDataFactory_Release
,
1339 ShellImageDataFactory_CreateIShellImageData
,
1340 ShellImageDataFactory_CreateImageFromFile
,
1341 ShellImageDataFactory_CreateImageFromStream
,
1342 ShellImageDataFactory_GetDataFormatFromPath
,
1345 static IShellImageDataFactory ShellImageDataFactory
= { &ShellImageDataFactoryVtbl
};
1347 HRESULT WINAPI
ShellImageDataFactory_Constructor(IUnknown
*outer
, REFIID riid
, void **obj
)
1349 TRACE("%p %s %p\n", outer
, debugstr_guid(riid
), obj
);
1352 return CLASS_E_NOAGGREGATION
;
1354 return IShellImageDataFactory_QueryInterface(&ShellImageDataFactory
, riid
, obj
);