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_AutoComplete
, IAutoComplete_Constructor
},
71 {&CLSID_ControlPanel
, IControlPanel_Constructor
},
72 {&CLSID_DragDropHelper
, IDropTargetHelper_Constructor
},
73 {&CLSID_FolderShortcut
, FolderShortcut_Constructor
},
74 {&CLSID_MyComputer
, ISF_MyComputer_Constructor
},
75 {&CLSID_MyDocuments
, MyDocuments_Constructor
},
76 {&CLSID_NetworkPlaces
, ISF_NetworkPlaces_Constructor
},
77 {&CLSID_Printers
, Printers_Constructor
},
78 {&CLSID_QueryAssociations
, QueryAssociations_Constructor
},
79 {&CLSID_RecycleBin
, RecycleBin_Constructor
},
80 {&CLSID_ShellDesktop
, ISF_Desktop_Constructor
},
81 {&CLSID_ShellFSFolder
, IFSFolder_Constructor
},
82 {&CLSID_ShellItem
, IShellItem_Constructor
},
83 {&CLSID_ShellLink
, IShellLink_Constructor
},
84 {&CLSID_UnixDosFolder
, UnixDosFolder_Constructor
},
85 {&CLSID_UnixFolder
, UnixFolder_Constructor
},
86 {&CLSID_ExplorerBrowser
,ExplorerBrowser_Constructor
},
87 {&CLSID_KnownFolderManager
, KnownFolderManager_Constructor
},
88 {&CLSID_Shell
, IShellDispatch_Constructor
},
89 {&CLSID_DestinationList
, CustomDestinationList_Constructor
},
90 {&CLSID_ShellImageDataFactory
, ShellImageDataFactory_Constructor
},
94 /*************************************************************************
95 * SHCoCreateInstance [SHELL32.102]
97 * Equivalent to CoCreateInstance. Under Windows 9x this function could sometimes
98 * use the shell32 built-in "mini-COM" without the need to load ole32.dll - see
99 * SHLoadOLE for details.
101 * Under wine if a "LoadWithoutCOM" value is present or the object resides in
102 * shell32.dll the function will load the object manually without the help of ole32
105 * exported by ordinal
108 * CoCreateInstance, SHLoadOLE
110 HRESULT WINAPI
SHCoCreateInstance(
119 const CLSID
* myclsid
= clsid
;
120 WCHAR sKeyName
[MAX_PATH
];
121 static const WCHAR sCLSID
[] = {'C','L','S','I','D','\\','\0'};
123 static const WCHAR sInProcServer32
[] = {'\\','I','n','p','r','o','c','S','e','r','v','e','r','3','2','\0'};
124 static const WCHAR sLoadWithoutCOM
[] = {'L','o','a','d','W','i','t','h','o','u','t','C','O','M','\0'};
125 WCHAR sDllPath
[MAX_PATH
];
128 IClassFactory
* pcf
= NULL
;
130 if(!ppv
) return E_POINTER
;
133 /* if the clsid is a string, convert it */
136 if (!aclsid
) return REGDB_E_CLASSNOTREG
;
137 SHCLSIDFromStringW(aclsid
, &iid
);
141 TRACE("(%p,%s,unk:%p,%s,%p)\n",
142 aclsid
,shdebugstr_guid(myclsid
),pUnkOuter
,shdebugstr_guid(refiid
),ppv
);
144 if (SUCCEEDED(DllGetClassObject(myclsid
, &IID_IClassFactory
,(LPVOID
*)&pcf
)))
146 hres
= IClassFactory_CreateInstance(pcf
, pUnkOuter
, refiid
, ppv
);
147 IClassFactory_Release(pcf
);
151 /* we look up the dll path in the registry */
152 SHStringFromGUIDW(myclsid
, sClassID
, sizeof(sClassID
)/sizeof(WCHAR
));
153 lstrcpyW(sKeyName
, sCLSID
);
154 lstrcatW(sKeyName
, sClassID
);
155 lstrcatW(sKeyName
, sInProcServer32
);
157 if (RegOpenKeyExW(HKEY_CLASSES_ROOT
, sKeyName
, 0, KEY_READ
, &hKey
))
158 return E_ACCESSDENIED
;
160 /* if a special registry key is set, we load a shell extension without help of OLE32 */
161 if (!SHQueryValueExW(hKey
, sLoadWithoutCOM
, 0, 0, 0, 0))
163 /* load an external dll without ole32 */
165 typedef HRESULT (CALLBACK
*DllGetClassObjectFunc
)(REFCLSID clsid
, REFIID iid
, LPVOID
*ppv
);
166 DllGetClassObjectFunc DllGetClassObject
;
168 dwSize
= sizeof(sDllPath
);
169 SHQueryValueExW(hKey
, NULL
, 0,0, sDllPath
, &dwSize
);
171 if ((hLibrary
= LoadLibraryExW(sDllPath
, 0, LOAD_WITH_ALTERED_SEARCH_PATH
)) == 0) {
172 ERR("couldn't load InprocServer32 dll %s\n", debugstr_w(sDllPath
));
173 hres
= E_ACCESSDENIED
;
175 } else if (!(DllGetClassObject
= (DllGetClassObjectFunc
)GetProcAddress(hLibrary
, "DllGetClassObject"))) {
176 ERR("couldn't find function DllGetClassObject in %s\n", debugstr_w(sDllPath
));
177 FreeLibrary( hLibrary
);
178 hres
= E_ACCESSDENIED
;
180 } else if (FAILED(hres
= DllGetClassObject(myclsid
, &IID_IClassFactory
, (LPVOID
*)&pcf
))) {
181 TRACE("GetClassObject failed 0x%08x\n", hres
);
185 hres
= IClassFactory_CreateInstance(pcf
, pUnkOuter
, refiid
, ppv
);
186 IClassFactory_Release(pcf
);
189 /* load an external dll in the usual way */
190 hres
= CoCreateInstance(myclsid
, pUnkOuter
, CLSCTX_INPROC_SERVER
, refiid
, ppv
);
194 if (hKey
) RegCloseKey(hKey
);
197 ERR("failed (0x%08x) to create CLSID:%s IID:%s\n",
198 hres
, shdebugstr_guid(myclsid
), shdebugstr_guid(refiid
));
199 ERR("class not found in registry\n");
202 TRACE("-- instance: %p\n",*ppv
);
206 /*************************************************************************
207 * DllGetClassObject [SHELL32.@]
208 * SHDllGetClassObject [SHELL32.128]
210 HRESULT WINAPI
DllGetClassObject(REFCLSID rclsid
, REFIID iid
, LPVOID
*ppv
)
212 IClassFactory
* pcf
= NULL
;
216 TRACE("CLSID:%s,IID:%s\n",shdebugstr_guid(rclsid
),shdebugstr_guid(iid
));
218 if (!ppv
) return E_INVALIDARG
;
221 /* search our internal interface table */
222 for(i
=0;InterfaceTable
[i
].clsid
;i
++) {
223 if(IsEqualIID(InterfaceTable
[i
].clsid
, rclsid
)) {
224 TRACE("index[%u]\n", i
);
225 pcf
= IDefClF_fnConstructor(InterfaceTable
[i
].lpfnCI
, NULL
, NULL
);
231 FIXME("failed for CLSID=%s\n", shdebugstr_guid(rclsid
));
232 return CLASS_E_CLASSNOTAVAILABLE
;
235 hres
= IClassFactory_QueryInterface(pcf
, iid
, ppv
);
236 IClassFactory_Release(pcf
);
238 TRACE("-- pointer to class factory: %p\n",*ppv
);
242 /*************************************************************************
243 * SHCLSIDFromString [SHELL32.147]
245 * Under Windows 9x this was an ANSI version of CLSIDFromString. It also allowed
246 * to avoid dependency on ole32.dll (see SHLoadOLE for details).
248 * Under Windows NT/2000/XP this is equivalent to CLSIDFromString
251 * exported by ordinal
254 * CLSIDFromString, SHLoadOLE
256 DWORD WINAPI
SHCLSIDFromStringA (LPCSTR clsid
, CLSID
*id
)
259 TRACE("(%p(%s) %p)\n", clsid
, clsid
, id
);
260 if (!MultiByteToWideChar( CP_ACP
, 0, clsid
, -1, buffer
, sizeof(buffer
)/sizeof(WCHAR
) ))
261 return CO_E_CLASSSTRING
;
262 return CLSIDFromString( buffer
, id
);
264 DWORD WINAPI
SHCLSIDFromStringW (LPCWSTR clsid
, CLSID
*id
)
266 TRACE("(%p(%s) %p)\n", clsid
, debugstr_w(clsid
), id
);
267 return CLSIDFromString(clsid
, id
);
269 DWORD WINAPI
SHCLSIDFromStringAW (LPCVOID clsid
, CLSID
*id
)
271 if (SHELL_OsIsUnicode())
272 return SHCLSIDFromStringW (clsid
, id
);
273 return SHCLSIDFromStringA (clsid
, id
);
276 /*************************************************************************
277 * SHGetMalloc [SHELL32.@]
279 * Equivalent to CoGetMalloc(MEMCTX_TASK, ...). Under Windows 9x this function
280 * could use the shell32 built-in "mini-COM" without the need to load ole32.dll -
281 * see SHLoadOLE for details.
284 * lpmal [O] Destination for IMalloc interface.
287 * Success: S_OK. lpmal contains the shells IMalloc interface.
288 * Failure. An HRESULT error code.
291 * CoGetMalloc, SHLoadOLE
293 HRESULT WINAPI
SHGetMalloc(LPMALLOC
*lpmal
)
295 TRACE("(%p)\n", lpmal
);
296 return CoGetMalloc(MEMCTX_TASK
, lpmal
);
299 /*************************************************************************
300 * SHAlloc [SHELL32.196]
302 * Equivalent to CoTaskMemAlloc. Under Windows 9x this function could use
303 * the shell32 built-in "mini-COM" without the need to load ole32.dll -
304 * see SHLoadOLE for details.
307 * exported by ordinal
310 * CoTaskMemAlloc, SHLoadOLE
312 LPVOID WINAPI
SHAlloc(DWORD len
)
316 ret
= CoTaskMemAlloc(len
);
317 TRACE("%u bytes at %p\n",len
, ret
);
321 /*************************************************************************
322 * SHFree [SHELL32.195]
324 * Equivalent to CoTaskMemFree. Under Windows 9x this function could use
325 * the shell32 built-in "mini-COM" without the need to load ole32.dll -
326 * see SHLoadOLE for details.
329 * exported by ordinal
332 * CoTaskMemFree, SHLoadOLE
334 void WINAPI
SHFree(LPVOID pv
)
340 /*************************************************************************
341 * SHGetDesktopFolder [SHELL32.@]
343 HRESULT WINAPI
SHGetDesktopFolder(IShellFolder
**psf
)
347 TRACE("(%p)\n", psf
);
349 if(!psf
) return E_INVALIDARG
;
352 hres
= ISF_Desktop_Constructor(NULL
, &IID_IShellFolder
, (LPVOID
*)psf
);
354 TRACE("-- %p->(%p) 0x%08x\n", psf
, *psf
, hres
);
357 /**************************************************************************
358 * Default ClassFactory Implementation
360 * SHCreateDefClassObject
363 * Helper function for dlls without their own classfactory.
364 * A generic classfactory is returned.
365 * When the CreateInstance of the cf is called the callback is executed.
370 IClassFactory IClassFactory_iface
;
373 LPFNCREATEINSTANCE lpfnCI
;
374 const IID
* riidInst
;
375 LONG
* pcRefDll
; /* pointer to refcounter in external dll (ugrrr...) */
378 static inline IDefClFImpl
*impl_from_IClassFactory(IClassFactory
*iface
)
380 return CONTAINING_RECORD(iface
, IDefClFImpl
, IClassFactory_iface
);
383 static const IClassFactoryVtbl dclfvt
;
385 /**************************************************************************
386 * IDefClF_fnConstructor
389 static IClassFactory
* IDefClF_fnConstructor(LPFNCREATEINSTANCE lpfnCI
, PLONG pcRefDll
, REFIID riidInst
)
393 lpclf
= HeapAlloc(GetProcessHeap(),0,sizeof(IDefClFImpl
));
395 lpclf
->IClassFactory_iface
.lpVtbl
= &dclfvt
;
396 lpclf
->lpfnCI
= lpfnCI
;
397 lpclf
->pcRefDll
= pcRefDll
;
399 if (pcRefDll
) InterlockedIncrement(pcRefDll
);
400 lpclf
->riidInst
= riidInst
;
402 TRACE("(%p)%s\n",lpclf
, shdebugstr_guid(riidInst
));
403 return (LPCLASSFACTORY
)lpclf
;
405 /**************************************************************************
406 * IDefClF_fnQueryInterface
408 static HRESULT WINAPI
IDefClF_fnQueryInterface(
409 LPCLASSFACTORY iface
, REFIID riid
, LPVOID
*ppvObj
)
411 IDefClFImpl
*This
= impl_from_IClassFactory(iface
);
413 TRACE("(%p)->(%s)\n",This
,shdebugstr_guid(riid
));
417 if(IsEqualIID(riid
, &IID_IUnknown
) || IsEqualIID(riid
, &IID_IClassFactory
)) {
419 InterlockedIncrement(&This
->ref
);
423 TRACE("-- E_NOINTERFACE\n");
424 return E_NOINTERFACE
;
426 /******************************************************************************
429 static ULONG WINAPI
IDefClF_fnAddRef(LPCLASSFACTORY iface
)
431 IDefClFImpl
*This
= impl_from_IClassFactory(iface
);
432 ULONG refCount
= InterlockedIncrement(&This
->ref
);
434 TRACE("(%p)->(count=%u)\n", This
, refCount
- 1);
438 /******************************************************************************
441 static ULONG WINAPI
IDefClF_fnRelease(LPCLASSFACTORY iface
)
443 IDefClFImpl
*This
= impl_from_IClassFactory(iface
);
444 ULONG refCount
= InterlockedDecrement(&This
->ref
);
446 TRACE("(%p)->(count=%u)\n", This
, refCount
+ 1);
450 if (This
->pcRefDll
) InterlockedDecrement(This
->pcRefDll
);
452 TRACE("-- destroying IClassFactory(%p)\n",This
);
453 HeapFree(GetProcessHeap(),0,This
);
458 /******************************************************************************
459 * IDefClF_fnCreateInstance
461 static HRESULT WINAPI
IDefClF_fnCreateInstance(
462 LPCLASSFACTORY iface
, LPUNKNOWN pUnkOuter
, REFIID riid
, LPVOID
*ppvObject
)
464 IDefClFImpl
*This
= impl_from_IClassFactory(iface
);
466 TRACE("%p->(%p,%s,%p)\n",This
,pUnkOuter
,shdebugstr_guid(riid
),ppvObject
);
470 if ( This
->riidInst
==NULL
||
471 IsEqualCLSID(riid
, This
->riidInst
) ||
472 IsEqualCLSID(riid
, &IID_IUnknown
) )
474 return This
->lpfnCI(pUnkOuter
, riid
, ppvObject
);
477 ERR("unknown IID requested %s\n",shdebugstr_guid(riid
));
478 return E_NOINTERFACE
;
480 /******************************************************************************
481 * IDefClF_fnLockServer
483 static HRESULT WINAPI
IDefClF_fnLockServer(LPCLASSFACTORY iface
, BOOL fLock
)
485 IDefClFImpl
*This
= impl_from_IClassFactory(iface
);
486 TRACE("%p->(0x%x), not implemented\n",This
, fLock
);
490 static const IClassFactoryVtbl dclfvt
=
492 IDefClF_fnQueryInterface
,
495 IDefClF_fnCreateInstance
,
499 /******************************************************************************
500 * SHCreateDefClassObject [SHELL32.70]
502 HRESULT WINAPI
SHCreateDefClassObject(
505 LPFNCREATEINSTANCE lpfnCI
, /* [in] create instance callback entry */
506 LPDWORD pcRefDll
, /* [in/out] ref count of the dll */
507 REFIID riidInst
) /* [in] optional interface to the instance */
511 TRACE("%s %p %p %p %s\n",
512 shdebugstr_guid(riid
), ppv
, lpfnCI
, pcRefDll
, shdebugstr_guid(riidInst
));
514 if (! IsEqualCLSID(riid
, &IID_IClassFactory
) ) return E_NOINTERFACE
;
515 if (! (pcf
= IDefClF_fnConstructor(lpfnCI
, (PLONG
)pcRefDll
, riidInst
))) return E_OUTOFMEMORY
;
520 /*************************************************************************
521 * DragAcceptFiles [SHELL32.@]
523 void WINAPI
DragAcceptFiles(HWND hWnd
, BOOL b
)
527 if( !IsWindow(hWnd
) ) return;
528 exstyle
= GetWindowLongA(hWnd
,GWL_EXSTYLE
);
530 exstyle
|= WS_EX_ACCEPTFILES
;
532 exstyle
&= ~WS_EX_ACCEPTFILES
;
533 SetWindowLongA(hWnd
,GWL_EXSTYLE
,exstyle
);
536 /*************************************************************************
537 * DragFinish [SHELL32.@]
539 void WINAPI
DragFinish(HDROP h
)
545 /*************************************************************************
546 * DragQueryPoint [SHELL32.@]
548 BOOL WINAPI
DragQueryPoint(HDROP hDrop
, POINT
*p
)
550 DROPFILES
*lpDropFileStruct
;
555 lpDropFileStruct
= GlobalLock(hDrop
);
557 *p
= lpDropFileStruct
->pt
;
558 bRet
= lpDropFileStruct
->fNC
;
564 /*************************************************************************
565 * DragQueryFileA [SHELL32.@]
566 * DragQueryFile [SHELL32.@]
568 UINT WINAPI
DragQueryFileA(
576 DROPFILES
*lpDropFileStruct
= GlobalLock(hDrop
);
578 TRACE("(%p, %x, %p, %u)\n", hDrop
,lFile
,lpszFile
,lLength
);
580 if(!lpDropFileStruct
) goto end
;
582 lpDrop
= (LPSTR
) lpDropFileStruct
+ lpDropFileStruct
->pFiles
;
584 if(lpDropFileStruct
->fWide
) {
585 LPWSTR lpszFileW
= NULL
;
587 if(lpszFile
&& lFile
!= 0xFFFFFFFF) {
588 lpszFileW
= HeapAlloc(GetProcessHeap(), 0, lLength
*sizeof(WCHAR
));
589 if(lpszFileW
== NULL
) {
593 i
= DragQueryFileW(hDrop
, lFile
, lpszFileW
, lLength
);
596 WideCharToMultiByte(CP_ACP
, 0, lpszFileW
, -1, lpszFile
, lLength
, 0, NULL
);
597 HeapFree(GetProcessHeap(), 0, lpszFileW
);
604 while (*lpDrop
++); /* skip filename */
607 i
= (lFile
== 0xFFFFFFFF) ? i
: 0;
613 if (!lpszFile
) goto end
; /* needed buffer size */
614 lstrcpynA (lpszFile
, lpDrop
, lLength
);
620 /*************************************************************************
621 * DragQueryFileW [SHELL32.@]
623 UINT WINAPI
DragQueryFileW(
631 DROPFILES
*lpDropFileStruct
= GlobalLock(hDrop
);
633 TRACE("(%p, %x, %p, %u)\n", hDrop
,lFile
,lpszwFile
,lLength
);
635 if(!lpDropFileStruct
) goto end
;
637 lpwDrop
= (LPWSTR
) ((LPSTR
)lpDropFileStruct
+ lpDropFileStruct
->pFiles
);
639 if(lpDropFileStruct
->fWide
== FALSE
) {
640 LPSTR lpszFileA
= NULL
;
642 if(lpszwFile
&& lFile
!= 0xFFFFFFFF) {
643 lpszFileA
= HeapAlloc(GetProcessHeap(), 0, lLength
);
644 if(lpszFileA
== NULL
) {
648 i
= DragQueryFileA(hDrop
, lFile
, lpszFileA
, lLength
);
651 MultiByteToWideChar(CP_ACP
, 0, lpszFileA
, -1, lpszwFile
, lLength
);
652 HeapFree(GetProcessHeap(), 0, lpszFileA
);
660 while (*lpwDrop
++); /* skip filename */
663 i
= (lFile
== 0xFFFFFFFF) ? i
: 0;
668 i
= strlenW(lpwDrop
);
669 if ( !lpszwFile
) goto end
; /* needed buffer size */
670 lstrcpynW (lpszwFile
, lpwDrop
, lLength
);
676 /*************************************************************************
677 * SHPropStgCreate [SHELL32.685]
679 HRESULT WINAPI
SHPropStgCreate(IPropertySetStorage
*psstg
, REFFMTID fmtid
,
680 const CLSID
*pclsid
, DWORD grfFlags
, DWORD grfMode
,
681 DWORD dwDisposition
, IPropertyStorage
**ppstg
, UINT
*puCodePage
)
687 TRACE("%p %s %s %x %x %x %p %p\n", psstg
, debugstr_guid(fmtid
), debugstr_guid(pclsid
),
688 grfFlags
, grfMode
, dwDisposition
, ppstg
, puCodePage
);
690 hres
= IPropertySetStorage_Open(psstg
, fmtid
, grfMode
, ppstg
);
692 switch(dwDisposition
) {
694 if(SUCCEEDED(hres
)) {
695 IPropertyStorage_Release(*ppstg
);
696 hres
= IPropertySetStorage_Delete(psstg
, fmtid
);
705 hres
= IPropertySetStorage_Create(psstg
, fmtid
, pclsid
,
706 grfFlags
, grfMode
, ppstg
);
713 prop
.ulKind
= PRSPEC_PROPID
;
714 prop
.u
.propid
= PID_CODEPAGE
;
715 hres
= IPropertyStorage_ReadMultiple(*ppstg
, 1, &prop
, &ret
);
716 if(FAILED(hres
) || ret
.vt
!=VT_I2
)
719 *puCodePage
= ret
.u
.iVal
;
726 /*************************************************************************
727 * SHPropStgReadMultiple [SHELL32.688]
729 HRESULT WINAPI
SHPropStgReadMultiple(IPropertyStorage
*pps
, UINT uCodePage
,
730 ULONG cpspec
, const PROPSPEC
*rgpspec
, PROPVARIANT
*rgvar
)
735 FIXME("%p %u %u %p %p\n", pps
, uCodePage
, cpspec
, rgpspec
, rgvar
);
737 memset(rgvar
, 0, cpspec
*sizeof(PROPVARIANT
));
738 hres
= IPropertyStorage_ReadMultiple(pps
, cpspec
, rgpspec
, rgvar
);
746 prop
.ulKind
= PRSPEC_PROPID
;
747 prop
.u
.propid
= PID_CODEPAGE
;
748 hres
= IPropertyStorage_ReadMultiple(pps
, 1, &prop
, &ret
);
749 if(FAILED(hres
) || ret
.vt
!=VT_I2
)
752 uCodePage
= ret
.u
.iVal
;
755 hres
= IPropertyStorage_Stat(pps
, &stat
);
759 /* TODO: do something with codepage and stat */
763 /*************************************************************************
764 * SHPropStgWriteMultiple [SHELL32.689]
766 HRESULT WINAPI
SHPropStgWriteMultiple(IPropertyStorage
*pps
, UINT
*uCodePage
,
767 ULONG cpspec
, const PROPSPEC
*rgpspec
, PROPVARIANT
*rgvar
, PROPID propidNameFirst
)
773 FIXME("%p %p %u %p %p %d\n", pps
, uCodePage
, cpspec
, rgpspec
, rgvar
, propidNameFirst
);
775 hres
= IPropertyStorage_Stat(pps
, &stat
);
779 if(uCodePage
&& *uCodePage
)
780 codepage
= *uCodePage
;
785 prop
.ulKind
= PRSPEC_PROPID
;
786 prop
.u
.propid
= PID_CODEPAGE
;
787 hres
= IPropertyStorage_ReadMultiple(pps
, 1, &prop
, &ret
);
790 if(ret
.vt
!=VT_I2
|| !ret
.u
.iVal
)
793 codepage
= ret
.u
.iVal
;
795 *uCodePage
= codepage
;
798 /* TODO: do something with codepage and stat */
800 hres
= IPropertyStorage_WriteMultiple(pps
, cpspec
, rgpspec
, rgvar
, propidNameFirst
);
804 /*************************************************************************
805 * SHCreateQueryCancelAutoPlayMoniker [SHELL32.@]
807 HRESULT WINAPI
SHCreateQueryCancelAutoPlayMoniker(IMoniker
**moniker
)
809 TRACE("%p\n", moniker
);
811 if (!moniker
) return E_INVALIDARG
;
812 return CreateClassMoniker(&CLSID_QueryCancelAutoPlay
, moniker
);
815 static HRESULT
gpstatus_to_hresult(GpStatus status
)
821 case InvalidParameter
:
824 return E_OUTOFMEMORY
;
832 /* IShellImageData */
835 IShellImageData IShellImageData_iface
;
842 static inline ShellImageData
*impl_from_IShellImageData(IShellImageData
*iface
)
844 return CONTAINING_RECORD(iface
, ShellImageData
, IShellImageData_iface
);
847 static HRESULT WINAPI
ShellImageData_QueryInterface(IShellImageData
*iface
, REFIID riid
, void **obj
)
849 ShellImageData
*This
= impl_from_IShellImageData(iface
);
851 TRACE("%p, %s, %p\n", This
, debugstr_guid(riid
), obj
);
853 if (IsEqualIID(riid
, &IID_IShellImageData
) || IsEqualIID(riid
, &IID_IUnknown
))
855 *obj
= &This
->IShellImageData_iface
;
856 IShellImageData_AddRef(iface
);
861 return E_NOINTERFACE
;
864 static ULONG WINAPI
ShellImageData_AddRef(IShellImageData
*iface
)
866 ShellImageData
*This
= impl_from_IShellImageData(iface
);
867 ULONG ref
= InterlockedIncrement(&This
->ref
);
869 TRACE("%p, %u\n", This
, ref
);
874 static ULONG WINAPI
ShellImageData_Release(IShellImageData
*iface
)
876 ShellImageData
*This
= impl_from_IShellImageData(iface
);
877 ULONG ref
= InterlockedDecrement(&This
->ref
);
879 TRACE("%p, %u\n", This
, ref
);
883 GdipDisposeImage(This
->image
);
884 HeapFree(GetProcessHeap(), 0, This
->path
);
891 static HRESULT WINAPI
ShellImageData_Decode(IShellImageData
*iface
, DWORD flags
, ULONG cx_desired
, ULONG cy_desired
)
893 ShellImageData
*This
= impl_from_IShellImageData(iface
);
897 TRACE("%p, %#x, %u, %u\n", This
, flags
, cx_desired
, cy_desired
);
902 if (flags
& SHIMGDEC_LOADFULL
)
903 FIXME("LOADFULL flag ignored\n");
905 hr
= gpstatus_to_hresult(GdipLoadImageFromFile(This
->path
, &image
));
909 if (flags
& SHIMGDEC_THUMBNAIL
)
911 hr
= gpstatus_to_hresult(GdipGetImageThumbnail(image
, cx_desired
, cy_desired
, &This
->image
, NULL
, NULL
));
912 GdipDisposeImage(image
);
920 static HRESULT WINAPI
ShellImageData_Draw(IShellImageData
*iface
, HDC hdc
, RECT
*dest
, RECT
*src
)
922 ShellImageData
*This
= impl_from_IShellImageData(iface
);
923 GpGraphics
*graphics
;
926 TRACE("%p, %p, %s, %s\n", This
, hdc
, wine_dbgstr_rect(dest
), wine_dbgstr_rect(src
));
937 hr
= gpstatus_to_hresult(GdipCreateFromHDC(hdc
, &graphics
));
941 hr
= gpstatus_to_hresult(GdipDrawImageRectRectI(graphics
, This
->image
, dest
->left
, dest
->top
, dest
->right
- dest
->left
,
942 dest
->bottom
- dest
->top
, src
->left
, src
->top
, src
->right
- src
->left
, src
->bottom
- src
->top
,
943 UnitPixel
, NULL
, NULL
, NULL
));
944 GdipDeleteGraphics(graphics
);
949 static HRESULT WINAPI
ShellImageData_NextFrame(IShellImageData
*iface
)
951 ShellImageData
*This
= impl_from_IShellImageData(iface
);
953 FIXME("%p: stub\n", This
);
958 static HRESULT WINAPI
ShellImageData_NextPage(IShellImageData
*iface
)
960 ShellImageData
*This
= impl_from_IShellImageData(iface
);
962 FIXME("%p: stub\n", This
);
967 static HRESULT WINAPI
ShellImageData_PrevPage(IShellImageData
*iface
)
969 ShellImageData
*This
= impl_from_IShellImageData(iface
);
971 FIXME("%p: stub\n", This
);
976 static HRESULT WINAPI
ShellImageData_IsTransparent(IShellImageData
*iface
)
978 ShellImageData
*This
= impl_from_IShellImageData(iface
);
980 FIXME("%p: stub\n", This
);
985 static HRESULT WINAPI
ShellImageData_IsAnimated(IShellImageData
*iface
)
987 ShellImageData
*This
= impl_from_IShellImageData(iface
);
989 FIXME("%p: stub\n", This
);
994 static HRESULT WINAPI
ShellImageData_IsVector(IShellImageData
*iface
)
996 ShellImageData
*This
= impl_from_IShellImageData(iface
);
998 FIXME("%p: stub\n", This
);
1003 static HRESULT WINAPI
ShellImageData_IsMultipage(IShellImageData
*iface
)
1005 ShellImageData
*This
= impl_from_IShellImageData(iface
);
1007 FIXME("%p: stub\n", This
);
1012 static HRESULT WINAPI
ShellImageData_IsEditable(IShellImageData
*iface
)
1014 ShellImageData
*This
= impl_from_IShellImageData(iface
);
1016 FIXME("%p: stub\n", This
);
1021 static HRESULT WINAPI
ShellImageData_IsPrintable(IShellImageData
*iface
)
1023 ShellImageData
*This
= impl_from_IShellImageData(iface
);
1025 FIXME("%p: stub\n", This
);
1030 static HRESULT WINAPI
ShellImageData_IsDecoded(IShellImageData
*iface
)
1032 ShellImageData
*This
= impl_from_IShellImageData(iface
);
1034 FIXME("%p: stub\n", This
);
1039 static HRESULT WINAPI
ShellImageData_GetCurrentPage(IShellImageData
*iface
, ULONG
*page
)
1041 ShellImageData
*This
= impl_from_IShellImageData(iface
);
1043 FIXME("%p: stub\n", This
);
1048 static HRESULT WINAPI
ShellImageData_GetPageCount(IShellImageData
*iface
, ULONG
*count
)
1050 ShellImageData
*This
= impl_from_IShellImageData(iface
);
1052 FIXME("%p, %p: stub\n", This
, count
);
1057 static HRESULT WINAPI
ShellImageDate_SelectPage(IShellImageData
*iface
, ULONG page
)
1059 ShellImageData
*This
= impl_from_IShellImageData(iface
);
1061 FIXME("%p, %u: stub\n", This
, page
);
1066 static HRESULT WINAPI
ShellImageData_GetSize(IShellImageData
*iface
, SIZE
*size
)
1068 ShellImageData
*This
= impl_from_IShellImageData(iface
);
1072 TRACE("%p, %p\n", This
, size
);
1077 hr
= gpstatus_to_hresult(GdipGetImageDimension(This
->image
, &cx
, &cy
));
1087 static HRESULT WINAPI
ShellImageData_GetRawDataFormat(IShellImageData
*iface
, GUID
*format
)
1089 ShellImageData
*This
= impl_from_IShellImageData(iface
);
1091 FIXME("%p, %p: stub\n", This
, format
);
1096 static HRESULT WINAPI
ShellImageData_GetPixelFormat(IShellImageData
*iface
, PixelFormat
*format
)
1098 ShellImageData
*This
= impl_from_IShellImageData(iface
);
1100 FIXME("%p, %p: stub\n", This
, format
);
1105 static HRESULT WINAPI
ShellImageData_GetDelay(IShellImageData
*iface
, DWORD
*delay
)
1107 ShellImageData
*This
= impl_from_IShellImageData(iface
);
1109 FIXME("%p, %p: stub\n", This
, delay
);
1114 static HRESULT WINAPI
ShellImageData_GetProperties(IShellImageData
*iface
, DWORD mode
, IPropertySetStorage
**props
)
1116 ShellImageData
*This
= impl_from_IShellImageData(iface
);
1118 FIXME("%p, %#x, %p: stub\n", This
, mode
, props
);
1123 static HRESULT WINAPI
ShellImageData_Rotate(IShellImageData
*iface
, DWORD angle
)
1125 ShellImageData
*This
= impl_from_IShellImageData(iface
);
1127 FIXME("%p, %u: stub\n", This
, angle
);
1132 static HRESULT WINAPI
ShellImageData_Scale(IShellImageData
*iface
, ULONG cx
, ULONG cy
, InterpolationMode mode
)
1134 ShellImageData
*This
= impl_from_IShellImageData(iface
);
1136 FIXME("%p, %u, %u, %#x: stub\n", This
, cx
, cy
, mode
);
1141 static HRESULT WINAPI
ShellImageData_DiscardEdit(IShellImageData
*iface
)
1143 ShellImageData
*This
= impl_from_IShellImageData(iface
);
1145 FIXME("%p: stub\n", This
);
1150 static HRESULT WINAPI
ShellImageDate_SetEncoderParams(IShellImageData
*iface
, IPropertyBag
*params
)
1152 ShellImageData
*This
= impl_from_IShellImageData(iface
);
1154 FIXME("%p, %p: stub\n", This
, params
);
1159 static HRESULT WINAPI
ShellImageData_DisplayName(IShellImageData
*iface
, LPWSTR name
, UINT count
)
1161 ShellImageData
*This
= impl_from_IShellImageData(iface
);
1163 FIXME("%p, %p, %u: stub\n", This
, name
, count
);
1168 static HRESULT WINAPI
ShellImageData_GetResolution(IShellImageData
*iface
, ULONG
*res_x
, ULONG
*res_y
)
1170 ShellImageData
*This
= impl_from_IShellImageData(iface
);
1172 FIXME("%p, %p, %p: stub\n", This
, res_x
, res_y
);
1177 static HRESULT WINAPI
ShellImageData_GetEncoderParams(IShellImageData
*iface
, GUID
*format
, EncoderParameters
**params
)
1179 ShellImageData
*This
= impl_from_IShellImageData(iface
);
1181 FIXME("%p, %p, %p: stub\n", This
, format
, params
);
1186 static HRESULT WINAPI
ShellImageData_RegisterAbort(IShellImageData
*iface
, IShellImageDataAbort
*abort
,
1187 IShellImageDataAbort
**prev
)
1189 ShellImageData
*This
= impl_from_IShellImageData(iface
);
1191 FIXME("%p, %p, %p: stub\n", This
, abort
, prev
);
1196 static HRESULT WINAPI
ShellImageData_CloneFrame(IShellImageData
*iface
, Image
**frame
)
1198 ShellImageData
*This
= impl_from_IShellImageData(iface
);
1200 FIXME("%p, %p: stub\n", This
, frame
);
1205 static HRESULT WINAPI
ShellImageData_ReplaceFrame(IShellImageData
*iface
, Image
*frame
)
1207 ShellImageData
*This
= impl_from_IShellImageData(iface
);
1209 FIXME("%p, %p: stub\n", This
, frame
);
1214 static const IShellImageDataVtbl ShellImageDataVtbl
=
1216 ShellImageData_QueryInterface
,
1217 ShellImageData_AddRef
,
1218 ShellImageData_Release
,
1219 ShellImageData_Decode
,
1220 ShellImageData_Draw
,
1221 ShellImageData_NextFrame
,
1222 ShellImageData_NextPage
,
1223 ShellImageData_PrevPage
,
1224 ShellImageData_IsTransparent
,
1225 ShellImageData_IsAnimated
,
1226 ShellImageData_IsVector
,
1227 ShellImageData_IsMultipage
,
1228 ShellImageData_IsEditable
,
1229 ShellImageData_IsPrintable
,
1230 ShellImageData_IsDecoded
,
1231 ShellImageData_GetCurrentPage
,
1232 ShellImageData_GetPageCount
,
1233 ShellImageDate_SelectPage
,
1234 ShellImageData_GetSize
,
1235 ShellImageData_GetRawDataFormat
,
1236 ShellImageData_GetPixelFormat
,
1237 ShellImageData_GetDelay
,
1238 ShellImageData_GetProperties
,
1239 ShellImageData_Rotate
,
1240 ShellImageData_Scale
,
1241 ShellImageData_DiscardEdit
,
1242 ShellImageDate_SetEncoderParams
,
1243 ShellImageData_DisplayName
,
1244 ShellImageData_GetResolution
,
1245 ShellImageData_GetEncoderParams
,
1246 ShellImageData_RegisterAbort
,
1247 ShellImageData_CloneFrame
,
1248 ShellImageData_ReplaceFrame
,
1251 static HRESULT
create_shellimagedata_from_path(const WCHAR
*path
, IShellImageData
**data
)
1253 ShellImageData
*This
;
1255 This
= SHAlloc(sizeof(*This
));
1257 This
->IShellImageData_iface
.lpVtbl
= &ShellImageDataVtbl
;
1260 This
->path
= strdupW(path
);
1263 *data
= &This
->IShellImageData_iface
;
1267 /* IShellImageDataFactory */
1268 static HRESULT WINAPI
ShellImageDataFactory_QueryInterface(IShellImageDataFactory
*iface
, REFIID riid
, void **obj
)
1270 TRACE("(%p, %s, %p)\n", iface
, debugstr_guid(riid
), obj
);
1272 if (IsEqualIID(&IID_IShellImageDataFactory
, riid
) || IsEqualIID(&IID_IUnknown
, riid
))
1278 FIXME("not implemented for %s\n", debugstr_guid(riid
));
1280 return E_NOINTERFACE
;
1283 IUnknown_AddRef((IUnknown
*)*obj
);
1287 static ULONG WINAPI
ShellImageDataFactory_AddRef(IShellImageDataFactory
*iface
)
1289 TRACE("(%p)\n", iface
);
1294 static ULONG WINAPI
ShellImageDataFactory_Release(IShellImageDataFactory
*iface
)
1296 TRACE("(%p)\n", iface
);
1301 static HRESULT WINAPI
ShellImageDataFactory_CreateIShellImageData(IShellImageDataFactory
*iface
, IShellImageData
**data
)
1303 FIXME("%p, %p: stub\n", iface
, data
);
1308 static HRESULT WINAPI
ShellImageDataFactory_CreateImageFromFile(IShellImageDataFactory
*iface
, const WCHAR
*path
,
1309 IShellImageData
**data
)
1311 TRACE("%p, %s, %p\n", iface
, debugstr_w(path
), data
);
1313 return create_shellimagedata_from_path(path
, data
);
1316 static HRESULT WINAPI
ShellImageDataFactory_CreateImageFromStream(IShellImageDataFactory
*iface
, IStream
*stream
,
1317 IShellImageData
**data
)
1319 FIXME("%p, %p, %p: stub\n", iface
, stream
, data
);
1324 static HRESULT WINAPI
ShellImageDataFactory_GetDataFormatFromPath(IShellImageDataFactory
*iface
, const WCHAR
*path
,
1327 FIXME("%p, %s, %p: stub\n", iface
, debugstr_w(path
), format
);
1332 static const IShellImageDataFactoryVtbl ShellImageDataFactoryVtbl
=
1334 ShellImageDataFactory_QueryInterface
,
1335 ShellImageDataFactory_AddRef
,
1336 ShellImageDataFactory_Release
,
1337 ShellImageDataFactory_CreateIShellImageData
,
1338 ShellImageDataFactory_CreateImageFromFile
,
1339 ShellImageDataFactory_CreateImageFromStream
,
1340 ShellImageDataFactory_GetDataFormatFromPath
,
1343 static IShellImageDataFactory ShellImageDataFactory
= { &ShellImageDataFactoryVtbl
};
1345 HRESULT WINAPI
ShellImageDataFactory_Constructor(IUnknown
*outer
, REFIID riid
, void **obj
)
1347 TRACE("%p %s %p\n", outer
, debugstr_guid(riid
), obj
);
1350 return CLASS_E_NOAGGREGATION
;
1352 return IShellImageDataFactory_QueryInterface(&ShellImageDataFactory
, riid
, obj
);