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
},
95 /*************************************************************************
96 * SHCoCreateInstance [SHELL32.102]
98 * Equivalent to CoCreateInstance. Under Windows 9x this function could sometimes
99 * use the shell32 built-in "mini-COM" without the need to load ole32.dll - see
100 * SHLoadOLE for details.
102 * Under wine if a "LoadWithoutCOM" value is present or the object resides in
103 * shell32.dll the function will load the object manually without the help of ole32
106 * exported by ordinal
109 * CoCreateInstance, SHLoadOLE
111 HRESULT WINAPI
SHCoCreateInstance(
120 const CLSID
* myclsid
= clsid
;
121 WCHAR sKeyName
[MAX_PATH
];
122 static const WCHAR sCLSID
[] = {'C','L','S','I','D','\\','\0'};
124 static const WCHAR sInProcServer32
[] = {'\\','I','n','p','r','o','c','S','e','r','v','e','r','3','2','\0'};
125 static const WCHAR sLoadWithoutCOM
[] = {'L','o','a','d','W','i','t','h','o','u','t','C','O','M','\0'};
126 WCHAR sDllPath
[MAX_PATH
];
129 IClassFactory
* pcf
= NULL
;
131 if(!ppv
) return E_POINTER
;
134 /* if the clsid is a string, convert it */
137 if (!aclsid
) return REGDB_E_CLASSNOTREG
;
138 SHCLSIDFromStringW(aclsid
, &iid
);
142 TRACE("(%p,%s,unk:%p,%s,%p)\n",
143 aclsid
,shdebugstr_guid(myclsid
),pUnkOuter
,shdebugstr_guid(refiid
),ppv
);
145 if (SUCCEEDED(DllGetClassObject(myclsid
, &IID_IClassFactory
,(LPVOID
*)&pcf
)))
147 hres
= IClassFactory_CreateInstance(pcf
, pUnkOuter
, refiid
, ppv
);
148 IClassFactory_Release(pcf
);
152 /* we look up the dll path in the registry */
153 SHStringFromGUIDW(myclsid
, sClassID
, ARRAY_SIZE(sClassID
));
154 lstrcpyW(sKeyName
, sCLSID
);
155 lstrcatW(sKeyName
, sClassID
);
156 lstrcatW(sKeyName
, sInProcServer32
);
158 if (RegOpenKeyExW(HKEY_CLASSES_ROOT
, sKeyName
, 0, KEY_READ
, &hKey
))
159 return E_ACCESSDENIED
;
161 /* if a special registry key is set, we load a shell extension without help of OLE32 */
162 if (!SHQueryValueExW(hKey
, sLoadWithoutCOM
, 0, 0, 0, 0))
164 /* load an external dll without ole32 */
166 typedef HRESULT (CALLBACK
*DllGetClassObjectFunc
)(REFCLSID clsid
, REFIID iid
, LPVOID
*ppv
);
167 DllGetClassObjectFunc DllGetClassObject
;
169 dwSize
= sizeof(sDllPath
);
170 SHQueryValueExW(hKey
, NULL
, 0,0, sDllPath
, &dwSize
);
172 if ((hLibrary
= LoadLibraryExW(sDllPath
, 0, LOAD_WITH_ALTERED_SEARCH_PATH
)) == 0) {
173 ERR("couldn't load InprocServer32 dll %s\n", debugstr_w(sDllPath
));
174 hres
= E_ACCESSDENIED
;
176 } else if (!(DllGetClassObject
= (DllGetClassObjectFunc
)GetProcAddress(hLibrary
, "DllGetClassObject"))) {
177 ERR("couldn't find function DllGetClassObject in %s\n", debugstr_w(sDllPath
));
178 FreeLibrary( hLibrary
);
179 hres
= E_ACCESSDENIED
;
181 } else if (FAILED(hres
= DllGetClassObject(myclsid
, &IID_IClassFactory
, (LPVOID
*)&pcf
))) {
182 TRACE("GetClassObject failed 0x%08x\n", hres
);
186 hres
= IClassFactory_CreateInstance(pcf
, pUnkOuter
, refiid
, ppv
);
187 IClassFactory_Release(pcf
);
190 /* load an external dll in the usual way */
191 hres
= CoCreateInstance(myclsid
, pUnkOuter
, CLSCTX_INPROC_SERVER
, refiid
, ppv
);
195 if (hKey
) RegCloseKey(hKey
);
198 ERR("failed (0x%08x) to create CLSID:%s IID:%s\n",
199 hres
, shdebugstr_guid(myclsid
), shdebugstr_guid(refiid
));
200 ERR("class not found in registry\n");
203 TRACE("-- instance: %p\n",*ppv
);
207 /*************************************************************************
208 * DllGetClassObject [SHELL32.@]
209 * SHDllGetClassObject [SHELL32.128]
211 HRESULT WINAPI
DllGetClassObject(REFCLSID rclsid
, REFIID iid
, LPVOID
*ppv
)
213 IClassFactory
* pcf
= NULL
;
217 TRACE("CLSID:%s,IID:%s\n",shdebugstr_guid(rclsid
),shdebugstr_guid(iid
));
219 if (!ppv
) return E_INVALIDARG
;
222 /* search our internal interface table */
223 for(i
=0;InterfaceTable
[i
].clsid
;i
++) {
224 if(IsEqualIID(InterfaceTable
[i
].clsid
, rclsid
)) {
225 TRACE("index[%u]\n", i
);
226 pcf
= IDefClF_fnConstructor(InterfaceTable
[i
].lpfnCI
, NULL
, NULL
);
232 FIXME("failed for CLSID=%s\n", shdebugstr_guid(rclsid
));
233 return CLASS_E_CLASSNOTAVAILABLE
;
236 hres
= IClassFactory_QueryInterface(pcf
, iid
, ppv
);
237 IClassFactory_Release(pcf
);
239 TRACE("-- pointer to class factory: %p\n",*ppv
);
243 /*************************************************************************
244 * SHCLSIDFromString [SHELL32.147]
246 * Under Windows 9x this was an ANSI version of CLSIDFromString. It also allowed
247 * to avoid dependency on ole32.dll (see SHLoadOLE for details).
249 * Under Windows NT/2000/XP this is equivalent to CLSIDFromString
252 * exported by ordinal
255 * CLSIDFromString, SHLoadOLE
257 DWORD WINAPI
SHCLSIDFromStringA (LPCSTR clsid
, CLSID
*id
)
260 TRACE("(%p(%s) %p)\n", clsid
, clsid
, id
);
261 if (!MultiByteToWideChar( CP_ACP
, 0, clsid
, -1, buffer
, ARRAY_SIZE(buffer
) ))
262 return CO_E_CLASSSTRING
;
263 return CLSIDFromString( buffer
, id
);
265 DWORD WINAPI
SHCLSIDFromStringW (LPCWSTR clsid
, CLSID
*id
)
267 TRACE("(%p(%s) %p)\n", clsid
, debugstr_w(clsid
), id
);
268 return CLSIDFromString(clsid
, id
);
270 DWORD WINAPI
SHCLSIDFromStringAW (LPCVOID clsid
, CLSID
*id
)
272 if (SHELL_OsIsUnicode())
273 return SHCLSIDFromStringW (clsid
, id
);
274 return SHCLSIDFromStringA (clsid
, id
);
277 /*************************************************************************
278 * SHGetMalloc [SHELL32.@]
280 * Equivalent to CoGetMalloc(MEMCTX_TASK, ...). Under Windows 9x this function
281 * could use the shell32 built-in "mini-COM" without the need to load ole32.dll -
282 * see SHLoadOLE for details.
285 * lpmal [O] Destination for IMalloc interface.
288 * Success: S_OK. lpmal contains the shells IMalloc interface.
289 * Failure. An HRESULT error code.
292 * CoGetMalloc, SHLoadOLE
294 HRESULT WINAPI
SHGetMalloc(LPMALLOC
*lpmal
)
296 TRACE("(%p)\n", lpmal
);
297 return CoGetMalloc(MEMCTX_TASK
, lpmal
);
300 /*************************************************************************
301 * SHAlloc [SHELL32.196]
303 * Equivalent to CoTaskMemAlloc. Under Windows 9x this function could use
304 * the shell32 built-in "mini-COM" without the need to load ole32.dll -
305 * see SHLoadOLE for details.
308 * exported by ordinal
311 * CoTaskMemAlloc, SHLoadOLE
313 LPVOID WINAPI
SHAlloc(DWORD len
)
317 ret
= CoTaskMemAlloc(len
);
318 TRACE("%u bytes at %p\n",len
, ret
);
322 /*************************************************************************
323 * SHFree [SHELL32.195]
325 * Equivalent to CoTaskMemFree. Under Windows 9x this function could use
326 * the shell32 built-in "mini-COM" without the need to load ole32.dll -
327 * see SHLoadOLE for details.
330 * exported by ordinal
333 * CoTaskMemFree, SHLoadOLE
335 void WINAPI
SHFree(LPVOID pv
)
341 /*************************************************************************
342 * SHGetDesktopFolder [SHELL32.@]
344 HRESULT WINAPI
SHGetDesktopFolder(IShellFolder
**psf
)
348 TRACE("(%p)\n", psf
);
350 if(!psf
) return E_INVALIDARG
;
353 hres
= ISF_Desktop_Constructor(NULL
, &IID_IShellFolder
, (LPVOID
*)psf
);
355 TRACE("-- %p->(%p) 0x%08x\n", psf
, *psf
, hres
);
358 /**************************************************************************
359 * Default ClassFactory Implementation
361 * SHCreateDefClassObject
364 * Helper function for dlls without their own classfactory.
365 * A generic classfactory is returned.
366 * When the CreateInstance of the cf is called the callback is executed.
371 IClassFactory IClassFactory_iface
;
374 LPFNCREATEINSTANCE lpfnCI
;
375 const IID
* riidInst
;
376 LONG
* pcRefDll
; /* pointer to refcounter in external dll (ugrrr...) */
379 static inline IDefClFImpl
*impl_from_IClassFactory(IClassFactory
*iface
)
381 return CONTAINING_RECORD(iface
, IDefClFImpl
, IClassFactory_iface
);
384 static const IClassFactoryVtbl dclfvt
;
386 /**************************************************************************
387 * IDefClF_fnConstructor
390 static IClassFactory
* IDefClF_fnConstructor(LPFNCREATEINSTANCE lpfnCI
, PLONG pcRefDll
, REFIID riidInst
)
394 lpclf
= heap_alloc(sizeof(*lpclf
));
396 lpclf
->IClassFactory_iface
.lpVtbl
= &dclfvt
;
397 lpclf
->lpfnCI
= lpfnCI
;
398 lpclf
->pcRefDll
= pcRefDll
;
400 if (pcRefDll
) InterlockedIncrement(pcRefDll
);
401 lpclf
->riidInst
= riidInst
;
403 TRACE("(%p)%s\n",lpclf
, shdebugstr_guid(riidInst
));
404 return &lpclf
->IClassFactory_iface
;
406 /**************************************************************************
407 * IDefClF_fnQueryInterface
409 static HRESULT WINAPI
IDefClF_fnQueryInterface(
410 LPCLASSFACTORY iface
, REFIID riid
, LPVOID
*ppvObj
)
412 IDefClFImpl
*This
= impl_from_IClassFactory(iface
);
414 TRACE("(%p)->(%s)\n",This
,shdebugstr_guid(riid
));
418 if(IsEqualIID(riid
, &IID_IUnknown
) || IsEqualIID(riid
, &IID_IClassFactory
)) {
420 InterlockedIncrement(&This
->ref
);
424 TRACE("-- E_NOINTERFACE\n");
425 return E_NOINTERFACE
;
427 /******************************************************************************
430 static ULONG WINAPI
IDefClF_fnAddRef(LPCLASSFACTORY iface
)
432 IDefClFImpl
*This
= impl_from_IClassFactory(iface
);
433 ULONG refCount
= InterlockedIncrement(&This
->ref
);
435 TRACE("(%p)->(count=%u)\n", This
, refCount
- 1);
439 /******************************************************************************
442 static ULONG WINAPI
IDefClF_fnRelease(LPCLASSFACTORY iface
)
444 IDefClFImpl
*This
= impl_from_IClassFactory(iface
);
445 ULONG refCount
= InterlockedDecrement(&This
->ref
);
447 TRACE("(%p)->(count=%u)\n", This
, refCount
+ 1);
451 if (This
->pcRefDll
) InterlockedDecrement(This
->pcRefDll
);
453 TRACE("-- destroying IClassFactory(%p)\n",This
);
459 /******************************************************************************
460 * IDefClF_fnCreateInstance
462 static HRESULT WINAPI
IDefClF_fnCreateInstance(
463 LPCLASSFACTORY iface
, LPUNKNOWN pUnkOuter
, REFIID riid
, LPVOID
*ppvObject
)
465 IDefClFImpl
*This
= impl_from_IClassFactory(iface
);
467 TRACE("%p->(%p,%s,%p)\n",This
,pUnkOuter
,shdebugstr_guid(riid
),ppvObject
);
471 if ( This
->riidInst
==NULL
||
472 IsEqualCLSID(riid
, This
->riidInst
) ||
473 IsEqualCLSID(riid
, &IID_IUnknown
) )
475 return This
->lpfnCI(pUnkOuter
, riid
, ppvObject
);
478 ERR("unknown IID requested %s\n",shdebugstr_guid(riid
));
479 return E_NOINTERFACE
;
481 /******************************************************************************
482 * IDefClF_fnLockServer
484 static HRESULT WINAPI
IDefClF_fnLockServer(LPCLASSFACTORY iface
, BOOL fLock
)
486 IDefClFImpl
*This
= impl_from_IClassFactory(iface
);
487 TRACE("%p->(0x%x), not implemented\n",This
, fLock
);
491 static const IClassFactoryVtbl dclfvt
=
493 IDefClF_fnQueryInterface
,
496 IDefClF_fnCreateInstance
,
500 /******************************************************************************
501 * SHCreateDefClassObject [SHELL32.70]
503 HRESULT WINAPI
SHCreateDefClassObject(
506 LPFNCREATEINSTANCE lpfnCI
, /* [in] create instance callback entry */
507 LPDWORD pcRefDll
, /* [in/out] ref count of the dll */
508 REFIID riidInst
) /* [in] optional interface to the instance */
512 TRACE("%s %p %p %p %s\n",
513 shdebugstr_guid(riid
), ppv
, lpfnCI
, pcRefDll
, shdebugstr_guid(riidInst
));
515 if (! IsEqualCLSID(riid
, &IID_IClassFactory
) ) return E_NOINTERFACE
;
516 if (! (pcf
= IDefClF_fnConstructor(lpfnCI
, (PLONG
)pcRefDll
, riidInst
))) return E_OUTOFMEMORY
;
521 /*************************************************************************
522 * DragAcceptFiles [SHELL32.@]
524 void WINAPI
DragAcceptFiles(HWND hWnd
, BOOL b
)
528 if( !IsWindow(hWnd
) ) return;
529 exstyle
= GetWindowLongA(hWnd
,GWL_EXSTYLE
);
531 exstyle
|= WS_EX_ACCEPTFILES
;
533 exstyle
&= ~WS_EX_ACCEPTFILES
;
534 SetWindowLongA(hWnd
,GWL_EXSTYLE
,exstyle
);
537 /*************************************************************************
538 * DragFinish [SHELL32.@]
540 void WINAPI
DragFinish(HDROP h
)
546 /*************************************************************************
547 * DragQueryPoint [SHELL32.@]
549 BOOL WINAPI
DragQueryPoint(HDROP hDrop
, POINT
*p
)
551 DROPFILES
*lpDropFileStruct
;
556 lpDropFileStruct
= GlobalLock(hDrop
);
558 *p
= lpDropFileStruct
->pt
;
559 bRet
= !lpDropFileStruct
->fNC
;
565 /*************************************************************************
566 * DragQueryFileA [SHELL32.@]
567 * DragQueryFile [SHELL32.@]
569 UINT WINAPI
DragQueryFileA(
577 DROPFILES
*lpDropFileStruct
= GlobalLock(hDrop
);
579 TRACE("(%p, %x, %p, %u)\n", hDrop
,lFile
,lpszFile
,lLength
);
581 if(!lpDropFileStruct
) goto end
;
583 lpDrop
= (LPSTR
) lpDropFileStruct
+ lpDropFileStruct
->pFiles
;
585 if(lpDropFileStruct
->fWide
) {
586 LPWSTR lpszFileW
= NULL
;
588 if(lpszFile
&& lFile
!= 0xFFFFFFFF) {
589 lpszFileW
= heap_alloc(lLength
*sizeof(WCHAR
));
590 if(lpszFileW
== NULL
) {
594 i
= DragQueryFileW(hDrop
, lFile
, lpszFileW
, lLength
);
597 WideCharToMultiByte(CP_ACP
, 0, lpszFileW
, -1, lpszFile
, lLength
, 0, NULL
);
598 heap_free(lpszFileW
);
605 while (*lpDrop
++); /* skip filename */
608 i
= (lFile
== 0xFFFFFFFF) ? i
: 0;
614 if (!lpszFile
) goto end
; /* needed buffer size */
615 lstrcpynA (lpszFile
, lpDrop
, lLength
);
621 /*************************************************************************
622 * DragQueryFileW [SHELL32.@]
624 UINT WINAPI
DragQueryFileW(
632 DROPFILES
*lpDropFileStruct
= GlobalLock(hDrop
);
634 TRACE("(%p, %x, %p, %u)\n", hDrop
,lFile
,lpszwFile
,lLength
);
636 if(!lpDropFileStruct
) goto end
;
638 lpwDrop
= (LPWSTR
) ((LPSTR
)lpDropFileStruct
+ lpDropFileStruct
->pFiles
);
640 if(lpDropFileStruct
->fWide
== FALSE
) {
641 LPSTR lpszFileA
= NULL
;
643 if(lpszwFile
&& lFile
!= 0xFFFFFFFF) {
644 lpszFileA
= heap_alloc(lLength
);
645 if(lpszFileA
== NULL
) {
649 i
= DragQueryFileA(hDrop
, lFile
, lpszFileA
, lLength
);
652 MultiByteToWideChar(CP_ACP
, 0, lpszFileA
, -1, lpszwFile
, lLength
);
653 heap_free(lpszFileA
);
661 while (*lpwDrop
++); /* skip filename */
664 i
= (lFile
== 0xFFFFFFFF) ? i
: 0;
669 i
= strlenW(lpwDrop
);
670 if ( !lpszwFile
) goto end
; /* needed buffer size */
671 lstrcpynW (lpszwFile
, lpwDrop
, lLength
);
677 /*************************************************************************
678 * SHPropStgCreate [SHELL32.685]
680 HRESULT WINAPI
SHPropStgCreate(IPropertySetStorage
*psstg
, REFFMTID fmtid
,
681 const CLSID
*pclsid
, DWORD grfFlags
, DWORD grfMode
,
682 DWORD dwDisposition
, IPropertyStorage
**ppstg
, UINT
*puCodePage
)
688 TRACE("%p %s %s %x %x %x %p %p\n", psstg
, debugstr_guid(fmtid
), debugstr_guid(pclsid
),
689 grfFlags
, grfMode
, dwDisposition
, ppstg
, puCodePage
);
691 hres
= IPropertySetStorage_Open(psstg
, fmtid
, grfMode
, ppstg
);
693 switch(dwDisposition
) {
695 if(SUCCEEDED(hres
)) {
696 IPropertyStorage_Release(*ppstg
);
697 hres
= IPropertySetStorage_Delete(psstg
, fmtid
);
706 hres
= IPropertySetStorage_Create(psstg
, fmtid
, pclsid
,
707 grfFlags
, grfMode
, ppstg
);
714 prop
.ulKind
= PRSPEC_PROPID
;
715 prop
.u
.propid
= PID_CODEPAGE
;
716 hres
= IPropertyStorage_ReadMultiple(*ppstg
, 1, &prop
, &ret
);
717 if(FAILED(hres
) || ret
.vt
!=VT_I2
)
720 *puCodePage
= ret
.u
.iVal
;
727 /*************************************************************************
728 * SHPropStgReadMultiple [SHELL32.688]
730 HRESULT WINAPI
SHPropStgReadMultiple(IPropertyStorage
*pps
, UINT uCodePage
,
731 ULONG cpspec
, const PROPSPEC
*rgpspec
, PROPVARIANT
*rgvar
)
736 FIXME("%p %u %u %p %p\n", pps
, uCodePage
, cpspec
, rgpspec
, rgvar
);
738 memset(rgvar
, 0, cpspec
*sizeof(PROPVARIANT
));
739 hres
= IPropertyStorage_ReadMultiple(pps
, cpspec
, rgpspec
, rgvar
);
747 prop
.ulKind
= PRSPEC_PROPID
;
748 prop
.u
.propid
= PID_CODEPAGE
;
749 hres
= IPropertyStorage_ReadMultiple(pps
, 1, &prop
, &ret
);
750 if(FAILED(hres
) || ret
.vt
!=VT_I2
)
753 uCodePage
= ret
.u
.iVal
;
756 hres
= IPropertyStorage_Stat(pps
, &stat
);
760 /* TODO: do something with codepage and stat */
764 /*************************************************************************
765 * SHPropStgWriteMultiple [SHELL32.689]
767 HRESULT WINAPI
SHPropStgWriteMultiple(IPropertyStorage
*pps
, UINT
*uCodePage
,
768 ULONG cpspec
, const PROPSPEC
*rgpspec
, PROPVARIANT
*rgvar
, PROPID propidNameFirst
)
774 FIXME("%p %p %u %p %p %d\n", pps
, uCodePage
, cpspec
, rgpspec
, rgvar
, propidNameFirst
);
776 hres
= IPropertyStorage_Stat(pps
, &stat
);
780 if(uCodePage
&& *uCodePage
)
781 codepage
= *uCodePage
;
786 prop
.ulKind
= PRSPEC_PROPID
;
787 prop
.u
.propid
= PID_CODEPAGE
;
788 hres
= IPropertyStorage_ReadMultiple(pps
, 1, &prop
, &ret
);
791 if(ret
.vt
!=VT_I2
|| !ret
.u
.iVal
)
794 codepage
= ret
.u
.iVal
;
796 *uCodePage
= codepage
;
799 /* TODO: do something with codepage and stat */
801 hres
= IPropertyStorage_WriteMultiple(pps
, cpspec
, rgpspec
, rgvar
, propidNameFirst
);
805 /*************************************************************************
806 * SHCreateQueryCancelAutoPlayMoniker [SHELL32.@]
808 HRESULT WINAPI
SHCreateQueryCancelAutoPlayMoniker(IMoniker
**moniker
)
810 TRACE("%p\n", moniker
);
812 if (!moniker
) return E_INVALIDARG
;
813 return CreateClassMoniker(&CLSID_QueryCancelAutoPlay
, moniker
);
816 static HRESULT
gpstatus_to_hresult(GpStatus status
)
822 case InvalidParameter
:
825 return E_OUTOFMEMORY
;
833 /* IShellImageData */
836 IShellImageData IShellImageData_iface
;
843 static inline ShellImageData
*impl_from_IShellImageData(IShellImageData
*iface
)
845 return CONTAINING_RECORD(iface
, ShellImageData
, IShellImageData_iface
);
848 static HRESULT WINAPI
ShellImageData_QueryInterface(IShellImageData
*iface
, REFIID riid
, void **obj
)
850 ShellImageData
*This
= impl_from_IShellImageData(iface
);
852 TRACE("%p, %s, %p\n", This
, debugstr_guid(riid
), obj
);
854 if (IsEqualIID(riid
, &IID_IShellImageData
) || IsEqualIID(riid
, &IID_IUnknown
))
856 *obj
= &This
->IShellImageData_iface
;
857 IShellImageData_AddRef(iface
);
862 return E_NOINTERFACE
;
865 static ULONG WINAPI
ShellImageData_AddRef(IShellImageData
*iface
)
867 ShellImageData
*This
= impl_from_IShellImageData(iface
);
868 ULONG ref
= InterlockedIncrement(&This
->ref
);
870 TRACE("%p, %u\n", This
, ref
);
875 static ULONG WINAPI
ShellImageData_Release(IShellImageData
*iface
)
877 ShellImageData
*This
= impl_from_IShellImageData(iface
);
878 ULONG ref
= InterlockedDecrement(&This
->ref
);
880 TRACE("%p, %u\n", This
, ref
);
884 GdipDisposeImage(This
->image
);
885 heap_free(This
->path
);
892 static HRESULT WINAPI
ShellImageData_Decode(IShellImageData
*iface
, DWORD flags
, ULONG cx_desired
, ULONG cy_desired
)
894 ShellImageData
*This
= impl_from_IShellImageData(iface
);
898 TRACE("%p, %#x, %u, %u\n", This
, flags
, cx_desired
, cy_desired
);
903 if (flags
& SHIMGDEC_LOADFULL
)
904 FIXME("LOADFULL flag ignored\n");
906 hr
= gpstatus_to_hresult(GdipLoadImageFromFile(This
->path
, &image
));
910 if (flags
& SHIMGDEC_THUMBNAIL
)
912 hr
= gpstatus_to_hresult(GdipGetImageThumbnail(image
, cx_desired
, cy_desired
, &This
->image
, NULL
, NULL
));
913 GdipDisposeImage(image
);
921 static HRESULT WINAPI
ShellImageData_Draw(IShellImageData
*iface
, HDC hdc
, RECT
*dest
, RECT
*src
)
923 ShellImageData
*This
= impl_from_IShellImageData(iface
);
924 GpGraphics
*graphics
;
927 TRACE("%p, %p, %s, %s\n", This
, hdc
, wine_dbgstr_rect(dest
), wine_dbgstr_rect(src
));
938 hr
= gpstatus_to_hresult(GdipCreateFromHDC(hdc
, &graphics
));
942 hr
= gpstatus_to_hresult(GdipDrawImageRectRectI(graphics
, This
->image
, dest
->left
, dest
->top
, dest
->right
- dest
->left
,
943 dest
->bottom
- dest
->top
, src
->left
, src
->top
, src
->right
- src
->left
, src
->bottom
- src
->top
,
944 UnitPixel
, NULL
, NULL
, NULL
));
945 GdipDeleteGraphics(graphics
);
950 static HRESULT WINAPI
ShellImageData_NextFrame(IShellImageData
*iface
)
952 ShellImageData
*This
= impl_from_IShellImageData(iface
);
954 FIXME("%p: stub\n", This
);
959 static HRESULT WINAPI
ShellImageData_NextPage(IShellImageData
*iface
)
961 ShellImageData
*This
= impl_from_IShellImageData(iface
);
963 FIXME("%p: stub\n", This
);
968 static HRESULT WINAPI
ShellImageData_PrevPage(IShellImageData
*iface
)
970 ShellImageData
*This
= impl_from_IShellImageData(iface
);
972 FIXME("%p: stub\n", This
);
977 static HRESULT WINAPI
ShellImageData_IsTransparent(IShellImageData
*iface
)
979 ShellImageData
*This
= impl_from_IShellImageData(iface
);
981 FIXME("%p: stub\n", This
);
986 static HRESULT WINAPI
ShellImageData_IsAnimated(IShellImageData
*iface
)
988 ShellImageData
*This
= impl_from_IShellImageData(iface
);
990 FIXME("%p: stub\n", This
);
995 static HRESULT WINAPI
ShellImageData_IsVector(IShellImageData
*iface
)
997 ShellImageData
*This
= impl_from_IShellImageData(iface
);
999 FIXME("%p: stub\n", This
);
1004 static HRESULT WINAPI
ShellImageData_IsMultipage(IShellImageData
*iface
)
1006 ShellImageData
*This
= impl_from_IShellImageData(iface
);
1008 FIXME("%p: stub\n", This
);
1013 static HRESULT WINAPI
ShellImageData_IsEditable(IShellImageData
*iface
)
1015 ShellImageData
*This
= impl_from_IShellImageData(iface
);
1017 FIXME("%p: stub\n", This
);
1022 static HRESULT WINAPI
ShellImageData_IsPrintable(IShellImageData
*iface
)
1024 ShellImageData
*This
= impl_from_IShellImageData(iface
);
1026 FIXME("%p: stub\n", This
);
1031 static HRESULT WINAPI
ShellImageData_IsDecoded(IShellImageData
*iface
)
1033 ShellImageData
*This
= impl_from_IShellImageData(iface
);
1035 FIXME("%p: stub\n", This
);
1040 static HRESULT WINAPI
ShellImageData_GetCurrentPage(IShellImageData
*iface
, ULONG
*page
)
1042 ShellImageData
*This
= impl_from_IShellImageData(iface
);
1044 FIXME("%p: stub\n", This
);
1049 static HRESULT WINAPI
ShellImageData_GetPageCount(IShellImageData
*iface
, ULONG
*count
)
1051 ShellImageData
*This
= impl_from_IShellImageData(iface
);
1053 FIXME("%p, %p: stub\n", This
, count
);
1058 static HRESULT WINAPI
ShellImageDate_SelectPage(IShellImageData
*iface
, ULONG page
)
1060 ShellImageData
*This
= impl_from_IShellImageData(iface
);
1062 FIXME("%p, %u: stub\n", This
, page
);
1067 static HRESULT WINAPI
ShellImageData_GetSize(IShellImageData
*iface
, SIZE
*size
)
1069 ShellImageData
*This
= impl_from_IShellImageData(iface
);
1073 TRACE("%p, %p\n", This
, size
);
1078 hr
= gpstatus_to_hresult(GdipGetImageDimension(This
->image
, &cx
, &cy
));
1088 static HRESULT WINAPI
ShellImageData_GetRawDataFormat(IShellImageData
*iface
, GUID
*format
)
1090 ShellImageData
*This
= impl_from_IShellImageData(iface
);
1092 FIXME("%p, %p: stub\n", This
, format
);
1097 static HRESULT WINAPI
ShellImageData_GetPixelFormat(IShellImageData
*iface
, PixelFormat
*format
)
1099 ShellImageData
*This
= impl_from_IShellImageData(iface
);
1101 FIXME("%p, %p: stub\n", This
, format
);
1106 static HRESULT WINAPI
ShellImageData_GetDelay(IShellImageData
*iface
, DWORD
*delay
)
1108 ShellImageData
*This
= impl_from_IShellImageData(iface
);
1110 FIXME("%p, %p: stub\n", This
, delay
);
1115 static HRESULT WINAPI
ShellImageData_GetProperties(IShellImageData
*iface
, DWORD mode
, IPropertySetStorage
**props
)
1117 ShellImageData
*This
= impl_from_IShellImageData(iface
);
1119 FIXME("%p, %#x, %p: stub\n", This
, mode
, props
);
1124 static HRESULT WINAPI
ShellImageData_Rotate(IShellImageData
*iface
, DWORD angle
)
1126 ShellImageData
*This
= impl_from_IShellImageData(iface
);
1128 FIXME("%p, %u: stub\n", This
, angle
);
1133 static HRESULT WINAPI
ShellImageData_Scale(IShellImageData
*iface
, ULONG cx
, ULONG cy
, InterpolationMode mode
)
1135 ShellImageData
*This
= impl_from_IShellImageData(iface
);
1137 FIXME("%p, %u, %u, %#x: stub\n", This
, cx
, cy
, mode
);
1142 static HRESULT WINAPI
ShellImageData_DiscardEdit(IShellImageData
*iface
)
1144 ShellImageData
*This
= impl_from_IShellImageData(iface
);
1146 FIXME("%p: stub\n", This
);
1151 static HRESULT WINAPI
ShellImageDate_SetEncoderParams(IShellImageData
*iface
, IPropertyBag
*params
)
1153 ShellImageData
*This
= impl_from_IShellImageData(iface
);
1155 FIXME("%p, %p: stub\n", This
, params
);
1160 static HRESULT WINAPI
ShellImageData_DisplayName(IShellImageData
*iface
, LPWSTR name
, UINT count
)
1162 ShellImageData
*This
= impl_from_IShellImageData(iface
);
1164 FIXME("%p, %p, %u: stub\n", This
, name
, count
);
1169 static HRESULT WINAPI
ShellImageData_GetResolution(IShellImageData
*iface
, ULONG
*res_x
, ULONG
*res_y
)
1171 ShellImageData
*This
= impl_from_IShellImageData(iface
);
1173 FIXME("%p, %p, %p: stub\n", This
, res_x
, res_y
);
1178 static HRESULT WINAPI
ShellImageData_GetEncoderParams(IShellImageData
*iface
, GUID
*format
, EncoderParameters
**params
)
1180 ShellImageData
*This
= impl_from_IShellImageData(iface
);
1182 FIXME("%p, %p, %p: stub\n", This
, format
, params
);
1187 static HRESULT WINAPI
ShellImageData_RegisterAbort(IShellImageData
*iface
, IShellImageDataAbort
*abort
,
1188 IShellImageDataAbort
**prev
)
1190 ShellImageData
*This
= impl_from_IShellImageData(iface
);
1192 FIXME("%p, %p, %p: stub\n", This
, abort
, prev
);
1197 static HRESULT WINAPI
ShellImageData_CloneFrame(IShellImageData
*iface
, Image
**frame
)
1199 ShellImageData
*This
= impl_from_IShellImageData(iface
);
1201 FIXME("%p, %p: stub\n", This
, frame
);
1206 static HRESULT WINAPI
ShellImageData_ReplaceFrame(IShellImageData
*iface
, Image
*frame
)
1208 ShellImageData
*This
= impl_from_IShellImageData(iface
);
1210 FIXME("%p, %p: stub\n", This
, frame
);
1215 static const IShellImageDataVtbl ShellImageDataVtbl
=
1217 ShellImageData_QueryInterface
,
1218 ShellImageData_AddRef
,
1219 ShellImageData_Release
,
1220 ShellImageData_Decode
,
1221 ShellImageData_Draw
,
1222 ShellImageData_NextFrame
,
1223 ShellImageData_NextPage
,
1224 ShellImageData_PrevPage
,
1225 ShellImageData_IsTransparent
,
1226 ShellImageData_IsAnimated
,
1227 ShellImageData_IsVector
,
1228 ShellImageData_IsMultipage
,
1229 ShellImageData_IsEditable
,
1230 ShellImageData_IsPrintable
,
1231 ShellImageData_IsDecoded
,
1232 ShellImageData_GetCurrentPage
,
1233 ShellImageData_GetPageCount
,
1234 ShellImageDate_SelectPage
,
1235 ShellImageData_GetSize
,
1236 ShellImageData_GetRawDataFormat
,
1237 ShellImageData_GetPixelFormat
,
1238 ShellImageData_GetDelay
,
1239 ShellImageData_GetProperties
,
1240 ShellImageData_Rotate
,
1241 ShellImageData_Scale
,
1242 ShellImageData_DiscardEdit
,
1243 ShellImageDate_SetEncoderParams
,
1244 ShellImageData_DisplayName
,
1245 ShellImageData_GetResolution
,
1246 ShellImageData_GetEncoderParams
,
1247 ShellImageData_RegisterAbort
,
1248 ShellImageData_CloneFrame
,
1249 ShellImageData_ReplaceFrame
,
1252 static HRESULT
create_shellimagedata_from_path(const WCHAR
*path
, IShellImageData
**data
)
1254 ShellImageData
*This
;
1256 This
= SHAlloc(sizeof(*This
));
1258 This
->IShellImageData_iface
.lpVtbl
= &ShellImageDataVtbl
;
1261 This
->path
= strdupW(path
);
1264 *data
= &This
->IShellImageData_iface
;
1268 /* IShellImageDataFactory */
1269 static HRESULT WINAPI
ShellImageDataFactory_QueryInterface(IShellImageDataFactory
*iface
, REFIID riid
, void **obj
)
1271 TRACE("(%p, %s, %p)\n", iface
, debugstr_guid(riid
), obj
);
1273 if (IsEqualIID(&IID_IShellImageDataFactory
, riid
) || IsEqualIID(&IID_IUnknown
, riid
))
1279 FIXME("not implemented for %s\n", debugstr_guid(riid
));
1281 return E_NOINTERFACE
;
1284 IUnknown_AddRef((IUnknown
*)*obj
);
1288 static ULONG WINAPI
ShellImageDataFactory_AddRef(IShellImageDataFactory
*iface
)
1290 TRACE("(%p)\n", iface
);
1295 static ULONG WINAPI
ShellImageDataFactory_Release(IShellImageDataFactory
*iface
)
1297 TRACE("(%p)\n", iface
);
1302 static HRESULT WINAPI
ShellImageDataFactory_CreateIShellImageData(IShellImageDataFactory
*iface
, IShellImageData
**data
)
1304 FIXME("%p, %p: stub\n", iface
, data
);
1309 static HRESULT WINAPI
ShellImageDataFactory_CreateImageFromFile(IShellImageDataFactory
*iface
, const WCHAR
*path
,
1310 IShellImageData
**data
)
1312 TRACE("%p, %s, %p\n", iface
, debugstr_w(path
), data
);
1314 return create_shellimagedata_from_path(path
, data
);
1317 static HRESULT WINAPI
ShellImageDataFactory_CreateImageFromStream(IShellImageDataFactory
*iface
, IStream
*stream
,
1318 IShellImageData
**data
)
1320 FIXME("%p, %p, %p: stub\n", iface
, stream
, data
);
1325 static HRESULT WINAPI
ShellImageDataFactory_GetDataFormatFromPath(IShellImageDataFactory
*iface
, const WCHAR
*path
,
1328 FIXME("%p, %s, %p: stub\n", iface
, debugstr_w(path
), format
);
1333 static const IShellImageDataFactoryVtbl ShellImageDataFactoryVtbl
=
1335 ShellImageDataFactory_QueryInterface
,
1336 ShellImageDataFactory_AddRef
,
1337 ShellImageDataFactory_Release
,
1338 ShellImageDataFactory_CreateIShellImageData
,
1339 ShellImageDataFactory_CreateImageFromFile
,
1340 ShellImageDataFactory_CreateImageFromStream
,
1341 ShellImageDataFactory_GetDataFormatFromPath
,
1344 static IShellImageDataFactory ShellImageDataFactory
= { &ShellImageDataFactoryVtbl
};
1346 HRESULT WINAPI
ShellImageDataFactory_Constructor(IUnknown
*outer
, REFIID riid
, void **obj
)
1348 TRACE("%p %s %p\n", outer
, debugstr_guid(riid
), obj
);
1351 return CLASS_E_NOAGGREGATION
;
1353 return IShellImageDataFactory_QueryInterface(&ShellImageDataFactory
, riid
, obj
);