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
27 #define NONAMELESSUNION
38 #include "shimgdata.h"
42 #include "undocshell.h"
43 #include "shell32_main.h"
45 #include "wine/debug.h"
49 WINE_DEFAULT_DEBUG_CHANNEL(shell
);
51 extern INT WINAPI
SHStringFromGUIDW(REFGUID guid
, LPWSTR lpszDest
, INT cchMax
); /* shlwapi.24 */
52 static HRESULT WINAPI
ShellImageDataFactory_Constructor(IUnknown
*outer
, REFIID riid
, void **obj
);
54 /**************************************************************************
55 * Default ClassFactory types
57 typedef HRESULT (CALLBACK
*LPFNCREATEINSTANCE
)(IUnknown
* pUnkOuter
, REFIID riid
, LPVOID
* ppvObject
);
58 static IClassFactory
* IDefClF_fnConstructor(LPFNCREATEINSTANCE lpfnCI
, PLONG pcRefDll
, REFIID riidInst
);
60 /* this table contains all CLSIDs of shell32 objects */
63 LPFNCREATEINSTANCE lpfnCI
;
64 } InterfaceTable
[] = {
66 {&CLSID_ApplicationAssociationRegistration
, ApplicationAssociationRegistration_Constructor
},
67 {&CLSID_ApplicationDestinations
, ApplicationDestinations_Constructor
},
68 {&CLSID_ApplicationDocumentLists
, ApplicationDocumentLists_Constructor
},
69 {&CLSID_AutoComplete
, IAutoComplete_Constructor
},
70 {&CLSID_ControlPanel
, IControlPanel_Constructor
},
71 {&CLSID_DragDropHelper
, IDropTargetHelper_Constructor
},
72 {&CLSID_FolderShortcut
, FolderShortcut_Constructor
},
73 {&CLSID_MyComputer
, ISF_MyComputer_Constructor
},
74 {&CLSID_MyDocuments
, MyDocuments_Constructor
},
75 {&CLSID_NetworkPlaces
, ISF_NetworkPlaces_Constructor
},
76 {&CLSID_Printers
, Printers_Constructor
},
77 {&CLSID_QueryAssociations
, QueryAssociations_Constructor
},
78 {&CLSID_RecycleBin
, RecycleBin_Constructor
},
79 {&CLSID_ShellDesktop
, ISF_Desktop_Constructor
},
80 {&CLSID_ShellFSFolder
, IFSFolder_Constructor
},
81 {&CLSID_ShellItem
, IShellItem_Constructor
},
82 {&CLSID_ShellLink
, IShellLink_Constructor
},
83 {&CLSID_UnixDosFolder
, UnixDosFolder_Constructor
},
84 {&CLSID_UnixFolder
, UnixFolder_Constructor
},
85 {&CLSID_ExplorerBrowser
,ExplorerBrowser_Constructor
},
86 {&CLSID_KnownFolderManager
, KnownFolderManager_Constructor
},
87 {&CLSID_Shell
, IShellDispatch_Constructor
},
88 {&CLSID_DestinationList
, CustomDestinationList_Constructor
},
89 {&CLSID_ShellImageDataFactory
, ShellImageDataFactory_Constructor
},
90 {&CLSID_FileOperation
, IFileOperation_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
];
122 WCHAR sDllPath
[MAX_PATH
];
125 IClassFactory
* pcf
= NULL
;
127 if(!ppv
) return E_POINTER
;
130 /* if the clsid is a string, convert it */
133 if (!aclsid
) return REGDB_E_CLASSNOTREG
;
134 SHCLSIDFromStringW(aclsid
, &iid
);
138 TRACE("(%p,%s,unk:%p,%s,%p)\n",
139 aclsid
,shdebugstr_guid(myclsid
),pUnkOuter
,shdebugstr_guid(refiid
),ppv
);
141 if (SUCCEEDED(DllGetClassObject(myclsid
, &IID_IClassFactory
,(LPVOID
*)&pcf
)))
143 hres
= IClassFactory_CreateInstance(pcf
, pUnkOuter
, refiid
, ppv
);
144 IClassFactory_Release(pcf
);
148 /* we look up the dll path in the registry */
149 SHStringFromGUIDW(myclsid
, sClassID
, ARRAY_SIZE(sClassID
));
150 swprintf( sKeyName
, ARRAY_SIZE(sKeyName
), L
"CLSID\\%s\\InprocServer32", sClassID
);
152 if (RegOpenKeyExW(HKEY_CLASSES_ROOT
, sKeyName
, 0, KEY_READ
, &hKey
))
153 return E_ACCESSDENIED
;
155 /* if a special registry key is set, we load a shell extension without help of OLE32 */
156 if (!SHQueryValueExW(hKey
, L
"LoadWithoutCOM", 0, 0, 0, 0))
158 /* load an external dll without ole32 */
160 typedef HRESULT (CALLBACK
*DllGetClassObjectFunc
)(REFCLSID clsid
, REFIID iid
, LPVOID
*ppv
);
161 DllGetClassObjectFunc DllGetClassObject
;
163 dwSize
= sizeof(sDllPath
);
164 SHQueryValueExW(hKey
, NULL
, 0,0, sDllPath
, &dwSize
);
166 if ((hLibrary
= LoadLibraryExW(sDllPath
, 0, LOAD_WITH_ALTERED_SEARCH_PATH
)) == 0) {
167 ERR("couldn't load InprocServer32 dll %s\n", debugstr_w(sDllPath
));
168 hres
= E_ACCESSDENIED
;
170 } else if (!(DllGetClassObject
= (DllGetClassObjectFunc
)GetProcAddress(hLibrary
, "DllGetClassObject"))) {
171 ERR("couldn't find function DllGetClassObject in %s\n", debugstr_w(sDllPath
));
172 FreeLibrary( hLibrary
);
173 hres
= E_ACCESSDENIED
;
175 } else if (FAILED(hres
= DllGetClassObject(myclsid
, &IID_IClassFactory
, (LPVOID
*)&pcf
))) {
176 TRACE("GetClassObject failed 0x%08x\n", hres
);
180 hres
= IClassFactory_CreateInstance(pcf
, pUnkOuter
, refiid
, ppv
);
181 IClassFactory_Release(pcf
);
184 /* load an external dll in the usual way */
185 hres
= CoCreateInstance(myclsid
, pUnkOuter
, CLSCTX_INPROC_SERVER
, refiid
, ppv
);
189 if (hKey
) RegCloseKey(hKey
);
192 ERR("failed (0x%08x) to create CLSID:%s IID:%s\n",
193 hres
, shdebugstr_guid(myclsid
), shdebugstr_guid(refiid
));
194 ERR("class not found in registry\n");
197 TRACE("-- instance: %p\n",*ppv
);
201 /*************************************************************************
202 * DllGetClassObject [SHELL32.@]
203 * SHDllGetClassObject [SHELL32.128]
205 HRESULT WINAPI
DllGetClassObject(REFCLSID rclsid
, REFIID iid
, LPVOID
*ppv
)
207 IClassFactory
* pcf
= NULL
;
211 TRACE("CLSID:%s,IID:%s\n",shdebugstr_guid(rclsid
),shdebugstr_guid(iid
));
213 if (!ppv
) return E_INVALIDARG
;
216 /* search our internal interface table */
217 for(i
=0;InterfaceTable
[i
].clsid
;i
++) {
218 if(IsEqualIID(InterfaceTable
[i
].clsid
, rclsid
)) {
219 TRACE("index[%u]\n", i
);
220 pcf
= IDefClF_fnConstructor(InterfaceTable
[i
].lpfnCI
, NULL
, NULL
);
226 FIXME("failed for CLSID=%s\n", shdebugstr_guid(rclsid
));
227 return CLASS_E_CLASSNOTAVAILABLE
;
230 hres
= IClassFactory_QueryInterface(pcf
, iid
, ppv
);
231 IClassFactory_Release(pcf
);
233 TRACE("-- pointer to class factory: %p\n",*ppv
);
237 /*************************************************************************
238 * SHCLSIDFromString [SHELL32.147]
240 * Under Windows 9x this was an ANSI version of CLSIDFromString. It also allowed
241 * to avoid dependency on ole32.dll (see SHLoadOLE for details).
243 * Under Windows NT/2000/XP this is equivalent to CLSIDFromString
246 * exported by ordinal
249 * CLSIDFromString, SHLoadOLE
251 DWORD WINAPI
SHCLSIDFromStringA (LPCSTR clsid
, CLSID
*id
)
254 TRACE("(%p(%s) %p)\n", clsid
, clsid
, id
);
255 if (!MultiByteToWideChar( CP_ACP
, 0, clsid
, -1, buffer
, ARRAY_SIZE(buffer
) ))
256 return CO_E_CLASSSTRING
;
257 return CLSIDFromString( buffer
, id
);
259 DWORD WINAPI
SHCLSIDFromStringW (LPCWSTR clsid
, CLSID
*id
)
261 TRACE("(%p(%s) %p)\n", clsid
, debugstr_w(clsid
), id
);
262 return CLSIDFromString(clsid
, id
);
264 DWORD WINAPI
SHCLSIDFromStringAW (LPCVOID clsid
, CLSID
*id
)
266 if (SHELL_OsIsUnicode())
267 return SHCLSIDFromStringW (clsid
, id
);
268 return SHCLSIDFromStringA (clsid
, id
);
271 /*************************************************************************
272 * SHGetMalloc [SHELL32.@]
274 * Equivalent to CoGetMalloc(MEMCTX_TASK, ...). Under Windows 9x this function
275 * could use the shell32 built-in "mini-COM" without the need to load ole32.dll -
276 * see SHLoadOLE for details.
279 * lpmal [O] Destination for IMalloc interface.
282 * Success: S_OK. lpmal contains the shells IMalloc interface.
283 * Failure. An HRESULT error code.
286 * CoGetMalloc, SHLoadOLE
288 HRESULT WINAPI
SHGetMalloc(LPMALLOC
*lpmal
)
290 TRACE("(%p)\n", lpmal
);
291 return CoGetMalloc(MEMCTX_TASK
, lpmal
);
294 /*************************************************************************
295 * SHAlloc [SHELL32.196]
297 * Equivalent to CoTaskMemAlloc. Under Windows 9x this function could use
298 * the shell32 built-in "mini-COM" without the need to load ole32.dll -
299 * see SHLoadOLE for details.
302 * exported by ordinal
305 * CoTaskMemAlloc, SHLoadOLE
307 LPVOID WINAPI
SHAlloc(DWORD len
)
311 ret
= CoTaskMemAlloc(len
);
312 TRACE("%u bytes at %p\n",len
, ret
);
316 /*************************************************************************
317 * SHFree [SHELL32.195]
319 * Equivalent to CoTaskMemFree. Under Windows 9x this function could use
320 * the shell32 built-in "mini-COM" without the need to load ole32.dll -
321 * see SHLoadOLE for details.
324 * exported by ordinal
327 * CoTaskMemFree, SHLoadOLE
329 void WINAPI
SHFree(LPVOID pv
)
335 /*************************************************************************
336 * SHGetDesktopFolder [SHELL32.@]
338 HRESULT WINAPI
SHGetDesktopFolder(IShellFolder
**psf
)
342 TRACE("(%p)\n", psf
);
344 if(!psf
) return E_INVALIDARG
;
347 hres
= ISF_Desktop_Constructor(NULL
, &IID_IShellFolder
, (LPVOID
*)psf
);
349 TRACE("-- %p->(%p) 0x%08x\n", psf
, *psf
, hres
);
352 /**************************************************************************
353 * Default ClassFactory Implementation
355 * SHCreateDefClassObject
358 * Helper function for dlls without their own classfactory.
359 * A generic classfactory is returned.
360 * When the CreateInstance of the cf is called the callback is executed.
365 IClassFactory IClassFactory_iface
;
368 LPFNCREATEINSTANCE lpfnCI
;
369 const IID
* riidInst
;
370 LONG
* pcRefDll
; /* pointer to refcounter in external dll (ugrrr...) */
373 static inline IDefClFImpl
*impl_from_IClassFactory(IClassFactory
*iface
)
375 return CONTAINING_RECORD(iface
, IDefClFImpl
, IClassFactory_iface
);
378 static const IClassFactoryVtbl dclfvt
;
380 /**************************************************************************
381 * IDefClF_fnConstructor
384 static IClassFactory
* IDefClF_fnConstructor(LPFNCREATEINSTANCE lpfnCI
, PLONG pcRefDll
, REFIID riidInst
)
388 lpclf
= heap_alloc(sizeof(*lpclf
));
390 lpclf
->IClassFactory_iface
.lpVtbl
= &dclfvt
;
391 lpclf
->lpfnCI
= lpfnCI
;
392 lpclf
->pcRefDll
= pcRefDll
;
394 if (pcRefDll
) InterlockedIncrement(pcRefDll
);
395 lpclf
->riidInst
= riidInst
;
397 TRACE("(%p)%s\n",lpclf
, shdebugstr_guid(riidInst
));
398 return &lpclf
->IClassFactory_iface
;
400 /**************************************************************************
401 * IDefClF_fnQueryInterface
403 static HRESULT WINAPI
IDefClF_fnQueryInterface(
404 LPCLASSFACTORY iface
, REFIID riid
, LPVOID
*ppvObj
)
406 IDefClFImpl
*This
= impl_from_IClassFactory(iface
);
408 TRACE("(%p)->(%s)\n",This
,shdebugstr_guid(riid
));
412 if(IsEqualIID(riid
, &IID_IUnknown
) || IsEqualIID(riid
, &IID_IClassFactory
)) {
414 InterlockedIncrement(&This
->ref
);
418 TRACE("-- E_NOINTERFACE\n");
419 return E_NOINTERFACE
;
421 /******************************************************************************
424 static ULONG WINAPI
IDefClF_fnAddRef(LPCLASSFACTORY iface
)
426 IDefClFImpl
*This
= impl_from_IClassFactory(iface
);
427 ULONG refCount
= InterlockedIncrement(&This
->ref
);
429 TRACE("(%p)->(count=%u)\n", This
, refCount
- 1);
433 /******************************************************************************
436 static ULONG WINAPI
IDefClF_fnRelease(LPCLASSFACTORY iface
)
438 IDefClFImpl
*This
= impl_from_IClassFactory(iface
);
439 ULONG refCount
= InterlockedDecrement(&This
->ref
);
441 TRACE("(%p)->(count=%u)\n", This
, refCount
+ 1);
445 if (This
->pcRefDll
) InterlockedDecrement(This
->pcRefDll
);
447 TRACE("-- destroying IClassFactory(%p)\n",This
);
453 /******************************************************************************
454 * IDefClF_fnCreateInstance
456 static HRESULT WINAPI
IDefClF_fnCreateInstance(
457 LPCLASSFACTORY iface
, LPUNKNOWN pUnkOuter
, REFIID riid
, LPVOID
*ppvObject
)
459 IDefClFImpl
*This
= impl_from_IClassFactory(iface
);
461 TRACE("%p->(%p,%s,%p)\n",This
,pUnkOuter
,shdebugstr_guid(riid
),ppvObject
);
465 if ( This
->riidInst
==NULL
||
466 IsEqualCLSID(riid
, This
->riidInst
) ||
467 IsEqualCLSID(riid
, &IID_IUnknown
) )
469 return This
->lpfnCI(pUnkOuter
, riid
, ppvObject
);
472 ERR("unknown IID requested %s\n",shdebugstr_guid(riid
));
473 return E_NOINTERFACE
;
475 /******************************************************************************
476 * IDefClF_fnLockServer
478 static HRESULT WINAPI
IDefClF_fnLockServer(LPCLASSFACTORY iface
, BOOL fLock
)
480 IDefClFImpl
*This
= impl_from_IClassFactory(iface
);
481 TRACE("%p->(0x%x), not implemented\n",This
, fLock
);
485 static const IClassFactoryVtbl dclfvt
=
487 IDefClF_fnQueryInterface
,
490 IDefClF_fnCreateInstance
,
494 /******************************************************************************
495 * SHCreateDefClassObject [SHELL32.70]
497 HRESULT WINAPI
SHCreateDefClassObject(
500 LPFNCREATEINSTANCE lpfnCI
, /* [in] create instance callback entry */
501 LPDWORD pcRefDll
, /* [in/out] ref count of the dll */
502 REFIID riidInst
) /* [in] optional interface to the instance */
506 TRACE("%s %p %p %p %s\n",
507 shdebugstr_guid(riid
), ppv
, lpfnCI
, pcRefDll
, shdebugstr_guid(riidInst
));
509 if (! IsEqualCLSID(riid
, &IID_IClassFactory
) ) return E_NOINTERFACE
;
510 if (! (pcf
= IDefClF_fnConstructor(lpfnCI
, (PLONG
)pcRefDll
, riidInst
))) return E_OUTOFMEMORY
;
515 /*************************************************************************
516 * DragAcceptFiles [SHELL32.@]
518 void WINAPI
DragAcceptFiles(HWND hWnd
, BOOL b
)
522 if( !IsWindow(hWnd
) ) return;
523 exstyle
= GetWindowLongA(hWnd
,GWL_EXSTYLE
);
525 exstyle
|= WS_EX_ACCEPTFILES
;
527 exstyle
&= ~WS_EX_ACCEPTFILES
;
528 SetWindowLongA(hWnd
,GWL_EXSTYLE
,exstyle
);
531 /*************************************************************************
532 * DragFinish [SHELL32.@]
534 void WINAPI
DragFinish(HDROP h
)
540 /*************************************************************************
541 * DragQueryPoint [SHELL32.@]
543 BOOL WINAPI
DragQueryPoint(HDROP hDrop
, POINT
*p
)
545 DROPFILES
*lpDropFileStruct
;
550 lpDropFileStruct
= GlobalLock(hDrop
);
552 *p
= lpDropFileStruct
->pt
;
553 bRet
= !lpDropFileStruct
->fNC
;
559 /*************************************************************************
560 * DragQueryFileA [SHELL32.@]
561 * DragQueryFile [SHELL32.@]
563 UINT WINAPI
DragQueryFileA(
571 DROPFILES
*lpDropFileStruct
= GlobalLock(hDrop
);
573 TRACE("(%p, %x, %p, %u)\n", hDrop
,lFile
,lpszFile
,lLength
);
575 if(!lpDropFileStruct
) goto end
;
577 lpDrop
= (LPSTR
) lpDropFileStruct
+ lpDropFileStruct
->pFiles
;
579 if(lpDropFileStruct
->fWide
) {
580 LPWSTR lpszFileW
= NULL
;
582 if(lpszFile
&& lFile
!= 0xFFFFFFFF) {
583 lpszFileW
= heap_alloc(lLength
*sizeof(WCHAR
));
584 if(lpszFileW
== NULL
) {
588 i
= DragQueryFileW(hDrop
, lFile
, lpszFileW
, lLength
);
591 WideCharToMultiByte(CP_ACP
, 0, lpszFileW
, -1, lpszFile
, lLength
, 0, NULL
);
592 heap_free(lpszFileW
);
599 while (*lpDrop
++); /* skip filename */
602 i
= (lFile
== 0xFFFFFFFF) ? i
: 0;
608 if (!lpszFile
) goto end
; /* needed buffer size */
609 lstrcpynA (lpszFile
, lpDrop
, lLength
);
615 /*************************************************************************
616 * DragQueryFileW [SHELL32.@]
618 UINT WINAPI
DragQueryFileW(
626 DROPFILES
*lpDropFileStruct
= GlobalLock(hDrop
);
628 TRACE("(%p, %x, %p, %u)\n", hDrop
,lFile
,lpszwFile
,lLength
);
630 if(!lpDropFileStruct
) goto end
;
632 lpwDrop
= (LPWSTR
) ((LPSTR
)lpDropFileStruct
+ lpDropFileStruct
->pFiles
);
634 if(lpDropFileStruct
->fWide
== FALSE
) {
635 LPSTR lpszFileA
= NULL
;
637 if(lpszwFile
&& lFile
!= 0xFFFFFFFF) {
638 lpszFileA
= heap_alloc(lLength
);
639 if(lpszFileA
== NULL
) {
643 i
= DragQueryFileA(hDrop
, lFile
, lpszFileA
, lLength
);
646 MultiByteToWideChar(CP_ACP
, 0, lpszFileA
, -1, lpszwFile
, lLength
);
647 heap_free(lpszFileA
);
655 while (*lpwDrop
++); /* skip filename */
658 i
= (lFile
== 0xFFFFFFFF) ? i
: 0;
663 i
= lstrlenW(lpwDrop
);
664 if ( !lpszwFile
) goto end
; /* needed buffer size */
665 lstrcpynW (lpszwFile
, lpwDrop
, lLength
);
671 /*************************************************************************
672 * SHPropStgCreate [SHELL32.685]
674 HRESULT WINAPI
SHPropStgCreate(IPropertySetStorage
*psstg
, REFFMTID fmtid
,
675 const CLSID
*pclsid
, DWORD grfFlags
, DWORD grfMode
,
676 DWORD dwDisposition
, IPropertyStorage
**ppstg
, UINT
*puCodePage
)
682 TRACE("%p %s %s %x %x %x %p %p\n", psstg
, debugstr_guid(fmtid
), debugstr_guid(pclsid
),
683 grfFlags
, grfMode
, dwDisposition
, ppstg
, puCodePage
);
685 hres
= IPropertySetStorage_Open(psstg
, fmtid
, grfMode
, ppstg
);
687 switch(dwDisposition
) {
689 if(SUCCEEDED(hres
)) {
690 IPropertyStorage_Release(*ppstg
);
691 hres
= IPropertySetStorage_Delete(psstg
, fmtid
);
700 hres
= IPropertySetStorage_Create(psstg
, fmtid
, pclsid
,
701 grfFlags
, grfMode
, ppstg
);
708 prop
.ulKind
= PRSPEC_PROPID
;
709 prop
.u
.propid
= PID_CODEPAGE
;
710 hres
= IPropertyStorage_ReadMultiple(*ppstg
, 1, &prop
, &ret
);
711 if(FAILED(hres
) || ret
.vt
!=VT_I2
)
714 *puCodePage
= ret
.iVal
;
721 /*************************************************************************
722 * SHPropStgReadMultiple [SHELL32.688]
724 HRESULT WINAPI
SHPropStgReadMultiple(IPropertyStorage
*pps
, UINT uCodePage
,
725 ULONG cpspec
, const PROPSPEC
*rgpspec
, PROPVARIANT
*rgvar
)
730 FIXME("%p %u %u %p %p\n", pps
, uCodePage
, cpspec
, rgpspec
, rgvar
);
732 memset(rgvar
, 0, cpspec
*sizeof(PROPVARIANT
));
733 hres
= IPropertyStorage_ReadMultiple(pps
, cpspec
, rgpspec
, rgvar
);
741 prop
.ulKind
= PRSPEC_PROPID
;
742 prop
.u
.propid
= PID_CODEPAGE
;
743 hres
= IPropertyStorage_ReadMultiple(pps
, 1, &prop
, &ret
);
744 if(FAILED(hres
) || ret
.vt
!=VT_I2
)
747 uCodePage
= ret
.iVal
;
750 hres
= IPropertyStorage_Stat(pps
, &stat
);
754 /* TODO: do something with codepage and stat */
758 /*************************************************************************
759 * SHPropStgWriteMultiple [SHELL32.689]
761 HRESULT WINAPI
SHPropStgWriteMultiple(IPropertyStorage
*pps
, UINT
*uCodePage
,
762 ULONG cpspec
, const PROPSPEC
*rgpspec
, PROPVARIANT
*rgvar
, PROPID propidNameFirst
)
768 FIXME("%p %p %u %p %p %d\n", pps
, uCodePage
, cpspec
, rgpspec
, rgvar
, propidNameFirst
);
770 hres
= IPropertyStorage_Stat(pps
, &stat
);
774 if(uCodePage
&& *uCodePage
)
775 codepage
= *uCodePage
;
780 prop
.ulKind
= PRSPEC_PROPID
;
781 prop
.u
.propid
= PID_CODEPAGE
;
782 hres
= IPropertyStorage_ReadMultiple(pps
, 1, &prop
, &ret
);
785 if(ret
.vt
!=VT_I2
|| !ret
.iVal
)
790 *uCodePage
= codepage
;
793 /* TODO: do something with codepage and stat */
795 hres
= IPropertyStorage_WriteMultiple(pps
, cpspec
, rgpspec
, rgvar
, propidNameFirst
);
799 /*************************************************************************
800 * SHCreateQueryCancelAutoPlayMoniker [SHELL32.@]
802 HRESULT WINAPI
SHCreateQueryCancelAutoPlayMoniker(IMoniker
**moniker
)
804 TRACE("%p\n", moniker
);
806 if (!moniker
) return E_INVALIDARG
;
807 return CreateClassMoniker(&CLSID_QueryCancelAutoPlay
, moniker
);
810 static HRESULT
gpstatus_to_hresult(GpStatus status
)
816 case InvalidParameter
:
819 return E_OUTOFMEMORY
;
827 /* IShellImageData */
830 IShellImageData IShellImageData_iface
;
837 static inline ShellImageData
*impl_from_IShellImageData(IShellImageData
*iface
)
839 return CONTAINING_RECORD(iface
, ShellImageData
, IShellImageData_iface
);
842 static HRESULT WINAPI
ShellImageData_QueryInterface(IShellImageData
*iface
, REFIID riid
, void **obj
)
844 ShellImageData
*This
= impl_from_IShellImageData(iface
);
846 TRACE("%p, %s, %p\n", This
, debugstr_guid(riid
), obj
);
848 if (IsEqualIID(riid
, &IID_IShellImageData
) || IsEqualIID(riid
, &IID_IUnknown
))
850 *obj
= &This
->IShellImageData_iface
;
851 IShellImageData_AddRef(iface
);
856 return E_NOINTERFACE
;
859 static ULONG WINAPI
ShellImageData_AddRef(IShellImageData
*iface
)
861 ShellImageData
*This
= impl_from_IShellImageData(iface
);
862 ULONG ref
= InterlockedIncrement(&This
->ref
);
864 TRACE("%p, %u\n", This
, ref
);
869 static ULONG WINAPI
ShellImageData_Release(IShellImageData
*iface
)
871 ShellImageData
*This
= impl_from_IShellImageData(iface
);
872 ULONG ref
= InterlockedDecrement(&This
->ref
);
874 TRACE("%p, %u\n", This
, ref
);
878 GdipDisposeImage(This
->image
);
879 heap_free(This
->path
);
886 static HRESULT WINAPI
ShellImageData_Decode(IShellImageData
*iface
, DWORD flags
, ULONG cx_desired
, ULONG cy_desired
)
888 ShellImageData
*This
= impl_from_IShellImageData(iface
);
892 TRACE("%p, %#x, %u, %u\n", This
, flags
, cx_desired
, cy_desired
);
897 if (flags
& SHIMGDEC_LOADFULL
)
898 FIXME("LOADFULL flag ignored\n");
900 hr
= gpstatus_to_hresult(GdipLoadImageFromFile(This
->path
, &image
));
904 if (flags
& SHIMGDEC_THUMBNAIL
)
906 hr
= gpstatus_to_hresult(GdipGetImageThumbnail(image
, cx_desired
, cy_desired
, &This
->image
, NULL
, NULL
));
907 GdipDisposeImage(image
);
915 static HRESULT WINAPI
ShellImageData_Draw(IShellImageData
*iface
, HDC hdc
, RECT
*dest
, RECT
*src
)
917 ShellImageData
*This
= impl_from_IShellImageData(iface
);
918 GpGraphics
*graphics
;
921 TRACE("%p, %p, %s, %s\n", This
, hdc
, wine_dbgstr_rect(dest
), wine_dbgstr_rect(src
));
932 hr
= gpstatus_to_hresult(GdipCreateFromHDC(hdc
, &graphics
));
936 hr
= gpstatus_to_hresult(GdipDrawImageRectRectI(graphics
, This
->image
, dest
->left
, dest
->top
, dest
->right
- dest
->left
,
937 dest
->bottom
- dest
->top
, src
->left
, src
->top
, src
->right
- src
->left
, src
->bottom
- src
->top
,
938 UnitPixel
, NULL
, NULL
, NULL
));
939 GdipDeleteGraphics(graphics
);
944 static HRESULT WINAPI
ShellImageData_NextFrame(IShellImageData
*iface
)
946 ShellImageData
*This
= impl_from_IShellImageData(iface
);
948 FIXME("%p: stub\n", This
);
953 static HRESULT WINAPI
ShellImageData_NextPage(IShellImageData
*iface
)
955 ShellImageData
*This
= impl_from_IShellImageData(iface
);
957 FIXME("%p: stub\n", This
);
962 static HRESULT WINAPI
ShellImageData_PrevPage(IShellImageData
*iface
)
964 ShellImageData
*This
= impl_from_IShellImageData(iface
);
966 FIXME("%p: stub\n", This
);
971 static HRESULT WINAPI
ShellImageData_IsTransparent(IShellImageData
*iface
)
973 ShellImageData
*This
= impl_from_IShellImageData(iface
);
975 FIXME("%p: stub\n", This
);
980 static HRESULT WINAPI
ShellImageData_IsAnimated(IShellImageData
*iface
)
982 ShellImageData
*This
= impl_from_IShellImageData(iface
);
984 FIXME("%p: stub\n", This
);
989 static HRESULT WINAPI
ShellImageData_IsVector(IShellImageData
*iface
)
991 ShellImageData
*This
= impl_from_IShellImageData(iface
);
993 FIXME("%p: stub\n", This
);
998 static HRESULT WINAPI
ShellImageData_IsMultipage(IShellImageData
*iface
)
1000 ShellImageData
*This
= impl_from_IShellImageData(iface
);
1002 FIXME("%p: stub\n", This
);
1007 static HRESULT WINAPI
ShellImageData_IsEditable(IShellImageData
*iface
)
1009 ShellImageData
*This
= impl_from_IShellImageData(iface
);
1011 FIXME("%p: stub\n", This
);
1016 static HRESULT WINAPI
ShellImageData_IsPrintable(IShellImageData
*iface
)
1018 ShellImageData
*This
= impl_from_IShellImageData(iface
);
1020 FIXME("%p: stub\n", This
);
1025 static HRESULT WINAPI
ShellImageData_IsDecoded(IShellImageData
*iface
)
1027 ShellImageData
*This
= impl_from_IShellImageData(iface
);
1029 FIXME("%p: stub\n", This
);
1034 static HRESULT WINAPI
ShellImageData_GetCurrentPage(IShellImageData
*iface
, ULONG
*page
)
1036 ShellImageData
*This
= impl_from_IShellImageData(iface
);
1038 FIXME("%p: stub\n", This
);
1043 static HRESULT WINAPI
ShellImageData_GetPageCount(IShellImageData
*iface
, ULONG
*count
)
1045 ShellImageData
*This
= impl_from_IShellImageData(iface
);
1047 FIXME("%p, %p: stub\n", This
, count
);
1052 static HRESULT WINAPI
ShellImageDate_SelectPage(IShellImageData
*iface
, ULONG page
)
1054 ShellImageData
*This
= impl_from_IShellImageData(iface
);
1056 FIXME("%p, %u: stub\n", This
, page
);
1061 static HRESULT WINAPI
ShellImageData_GetSize(IShellImageData
*iface
, SIZE
*size
)
1063 ShellImageData
*This
= impl_from_IShellImageData(iface
);
1067 TRACE("%p, %p\n", This
, size
);
1072 hr
= gpstatus_to_hresult(GdipGetImageDimension(This
->image
, &cx
, &cy
));
1082 static HRESULT WINAPI
ShellImageData_GetRawDataFormat(IShellImageData
*iface
, GUID
*format
)
1084 ShellImageData
*This
= impl_from_IShellImageData(iface
);
1086 FIXME("%p, %p: stub\n", This
, format
);
1091 static HRESULT WINAPI
ShellImageData_GetPixelFormat(IShellImageData
*iface
, PixelFormat
*format
)
1093 ShellImageData
*This
= impl_from_IShellImageData(iface
);
1095 FIXME("%p, %p: stub\n", This
, format
);
1100 static HRESULT WINAPI
ShellImageData_GetDelay(IShellImageData
*iface
, DWORD
*delay
)
1102 ShellImageData
*This
= impl_from_IShellImageData(iface
);
1104 FIXME("%p, %p: stub\n", This
, delay
);
1109 static HRESULT WINAPI
ShellImageData_GetProperties(IShellImageData
*iface
, DWORD mode
, IPropertySetStorage
**props
)
1111 ShellImageData
*This
= impl_from_IShellImageData(iface
);
1113 FIXME("%p, %#x, %p: stub\n", This
, mode
, props
);
1118 static HRESULT WINAPI
ShellImageData_Rotate(IShellImageData
*iface
, DWORD angle
)
1120 ShellImageData
*This
= impl_from_IShellImageData(iface
);
1122 FIXME("%p, %u: stub\n", This
, angle
);
1127 static HRESULT WINAPI
ShellImageData_Scale(IShellImageData
*iface
, ULONG cx
, ULONG cy
, InterpolationMode mode
)
1129 ShellImageData
*This
= impl_from_IShellImageData(iface
);
1131 FIXME("%p, %u, %u, %#x: stub\n", This
, cx
, cy
, mode
);
1136 static HRESULT WINAPI
ShellImageData_DiscardEdit(IShellImageData
*iface
)
1138 ShellImageData
*This
= impl_from_IShellImageData(iface
);
1140 FIXME("%p: stub\n", This
);
1145 static HRESULT WINAPI
ShellImageDate_SetEncoderParams(IShellImageData
*iface
, IPropertyBag
*params
)
1147 ShellImageData
*This
= impl_from_IShellImageData(iface
);
1149 FIXME("%p, %p: stub\n", This
, params
);
1154 static HRESULT WINAPI
ShellImageData_DisplayName(IShellImageData
*iface
, LPWSTR name
, UINT count
)
1156 ShellImageData
*This
= impl_from_IShellImageData(iface
);
1158 FIXME("%p, %p, %u: stub\n", This
, name
, count
);
1163 static HRESULT WINAPI
ShellImageData_GetResolution(IShellImageData
*iface
, ULONG
*res_x
, ULONG
*res_y
)
1165 ShellImageData
*This
= impl_from_IShellImageData(iface
);
1167 FIXME("%p, %p, %p: stub\n", This
, res_x
, res_y
);
1172 static HRESULT WINAPI
ShellImageData_GetEncoderParams(IShellImageData
*iface
, GUID
*format
, EncoderParameters
**params
)
1174 ShellImageData
*This
= impl_from_IShellImageData(iface
);
1176 FIXME("%p, %p, %p: stub\n", This
, format
, params
);
1181 static HRESULT WINAPI
ShellImageData_RegisterAbort(IShellImageData
*iface
, IShellImageDataAbort
*abort
,
1182 IShellImageDataAbort
**prev
)
1184 ShellImageData
*This
= impl_from_IShellImageData(iface
);
1186 FIXME("%p, %p, %p: stub\n", This
, abort
, prev
);
1191 static HRESULT WINAPI
ShellImageData_CloneFrame(IShellImageData
*iface
, Image
**frame
)
1193 ShellImageData
*This
= impl_from_IShellImageData(iface
);
1195 FIXME("%p, %p: stub\n", This
, frame
);
1200 static HRESULT WINAPI
ShellImageData_ReplaceFrame(IShellImageData
*iface
, Image
*frame
)
1202 ShellImageData
*This
= impl_from_IShellImageData(iface
);
1204 FIXME("%p, %p: stub\n", This
, frame
);
1209 static const IShellImageDataVtbl ShellImageDataVtbl
=
1211 ShellImageData_QueryInterface
,
1212 ShellImageData_AddRef
,
1213 ShellImageData_Release
,
1214 ShellImageData_Decode
,
1215 ShellImageData_Draw
,
1216 ShellImageData_NextFrame
,
1217 ShellImageData_NextPage
,
1218 ShellImageData_PrevPage
,
1219 ShellImageData_IsTransparent
,
1220 ShellImageData_IsAnimated
,
1221 ShellImageData_IsVector
,
1222 ShellImageData_IsMultipage
,
1223 ShellImageData_IsEditable
,
1224 ShellImageData_IsPrintable
,
1225 ShellImageData_IsDecoded
,
1226 ShellImageData_GetCurrentPage
,
1227 ShellImageData_GetPageCount
,
1228 ShellImageDate_SelectPage
,
1229 ShellImageData_GetSize
,
1230 ShellImageData_GetRawDataFormat
,
1231 ShellImageData_GetPixelFormat
,
1232 ShellImageData_GetDelay
,
1233 ShellImageData_GetProperties
,
1234 ShellImageData_Rotate
,
1235 ShellImageData_Scale
,
1236 ShellImageData_DiscardEdit
,
1237 ShellImageDate_SetEncoderParams
,
1238 ShellImageData_DisplayName
,
1239 ShellImageData_GetResolution
,
1240 ShellImageData_GetEncoderParams
,
1241 ShellImageData_RegisterAbort
,
1242 ShellImageData_CloneFrame
,
1243 ShellImageData_ReplaceFrame
,
1246 static HRESULT
create_shellimagedata_from_path(const WCHAR
*path
, IShellImageData
**data
)
1248 ShellImageData
*This
;
1250 This
= SHAlloc(sizeof(*This
));
1252 This
->IShellImageData_iface
.lpVtbl
= &ShellImageDataVtbl
;
1255 This
->path
= strdupW(path
);
1258 *data
= &This
->IShellImageData_iface
;
1262 /* IShellImageDataFactory */
1263 static HRESULT WINAPI
ShellImageDataFactory_QueryInterface(IShellImageDataFactory
*iface
, REFIID riid
, void **obj
)
1265 TRACE("(%p, %s, %p)\n", iface
, debugstr_guid(riid
), obj
);
1267 if (IsEqualIID(&IID_IShellImageDataFactory
, riid
) || IsEqualIID(&IID_IUnknown
, riid
))
1273 FIXME("not implemented for %s\n", debugstr_guid(riid
));
1275 return E_NOINTERFACE
;
1278 IUnknown_AddRef((IUnknown
*)*obj
);
1282 static ULONG WINAPI
ShellImageDataFactory_AddRef(IShellImageDataFactory
*iface
)
1284 TRACE("(%p)\n", iface
);
1289 static ULONG WINAPI
ShellImageDataFactory_Release(IShellImageDataFactory
*iface
)
1291 TRACE("(%p)\n", iface
);
1296 static HRESULT WINAPI
ShellImageDataFactory_CreateIShellImageData(IShellImageDataFactory
*iface
, IShellImageData
**data
)
1298 FIXME("%p, %p: stub\n", iface
, data
);
1303 static HRESULT WINAPI
ShellImageDataFactory_CreateImageFromFile(IShellImageDataFactory
*iface
, const WCHAR
*path
,
1304 IShellImageData
**data
)
1306 TRACE("%p, %s, %p\n", iface
, debugstr_w(path
), data
);
1308 return create_shellimagedata_from_path(path
, data
);
1311 static HRESULT WINAPI
ShellImageDataFactory_CreateImageFromStream(IShellImageDataFactory
*iface
, IStream
*stream
,
1312 IShellImageData
**data
)
1314 FIXME("%p, %p, %p: stub\n", iface
, stream
, data
);
1319 static HRESULT WINAPI
ShellImageDataFactory_GetDataFormatFromPath(IShellImageDataFactory
*iface
, const WCHAR
*path
,
1322 FIXME("%p, %s, %p: stub\n", iface
, debugstr_w(path
), format
);
1327 static const IShellImageDataFactoryVtbl ShellImageDataFactoryVtbl
=
1329 ShellImageDataFactory_QueryInterface
,
1330 ShellImageDataFactory_AddRef
,
1331 ShellImageDataFactory_Release
,
1332 ShellImageDataFactory_CreateIShellImageData
,
1333 ShellImageDataFactory_CreateImageFromFile
,
1334 ShellImageDataFactory_CreateImageFromStream
,
1335 ShellImageDataFactory_GetDataFormatFromPath
,
1338 static IShellImageDataFactory ShellImageDataFactory
= { &ShellImageDataFactoryVtbl
};
1340 HRESULT WINAPI
ShellImageDataFactory_Constructor(IUnknown
*outer
, REFIID riid
, void **obj
)
1342 TRACE("%p %s %p\n", outer
, debugstr_guid(riid
), obj
);
1345 return CLASS_E_NOAGGREGATION
;
1347 return IShellImageDataFactory_QueryInterface(&ShellImageDataFactory
, riid
, obj
);