SHELL32: add the IShellExtInit interface to the ShellLink object

Mike McCormack mike at codeweavers.com
Mon Jun 13 00:43:39 CDT 2005


This is used along with IContextMenu to Open a .lnk file.

Mike


ChangeLog:
* add the IShellExtInit interface to the ShellLink object
* use inline functions rather than macros to resolve the implementation 
pointer from an interface pointer
-------------- next part --------------
? dlls/shell32/tests/cabinet.c
? dlls/shell32/tests/pidl.c
Index: dlls/shell32/shelllink.c
===================================================================
RCS file: /home/wine/wine/dlls/shell32/shelllink.c,v
retrieving revision 1.94
diff -u -p -r1.94 shelllink.c
--- dlls/shell32/shelllink.c	9 Jun 2005 12:05:38 -0000	1.94
+++ dlls/shell32/shelllink.c	13 Jun 2005 05:43:32 -0000
@@ -117,6 +117,7 @@ static const IShellLinkWVtbl slvtw;
 static const IPersistFileVtbl pfvt;
 static const IPersistStreamVtbl psvt;
 static const IShellLinkDataListVtbl dlvt;
+static const IShellExtInitVtbl eivt;
 
 /* IShellLink Implementation */
 
@@ -127,6 +128,7 @@ typedef struct
 	const IPersistFileVtbl *lpvtblPersistFile;
 	const IPersistStreamVtbl *lpvtblPersistStream;
 	const IShellLinkDataListVtbl *lpvtblShellLinkDataList;
+	const IShellExtInitVtbl *lpvtblShellExtInit;
 
 	DWORD           ref;
 
@@ -152,24 +154,45 @@ typedef struct
 	BOOL		bDirty;
 } IShellLinkImpl;
 
-#define _IShellLinkW_Offset ((int)(&(((IShellLinkImpl*)0)->lpvtblw)))
-#define _ICOM_THIS_From_IShellLinkW(class, name) \
-    class* This = (class*)(((char*)name)-_IShellLinkW_Offset)
-
-#define _IPersistFile_Offset \
-    ((int)(&(((IShellLinkImpl*)0)->lpvtblPersistFile)))
-#define _ICOM_THIS_From_IPersistFile(class, name) \
-    class* This = (class*)(((char*)name)-_IPersistFile_Offset)
-
-#define _IPersistStream_Offset \
-    ((int)(&(((IShellLinkImpl*)0)->lpvtblPersistStream)))
-#define _ICOM_THIS_From_IPersistStream(class, name) \
-    class* This = (class*)(((char*)name)-_IPersistStream_Offset)
-
-#define _IShellLinkDataList_Offset \
-    ((int)(&(((IShellLinkImpl*)0)->lpvtblShellLinkDataList)))
-#define _ICOM_THIS_From_IShellLinkDataList(class, name) \
-    class* This = (class*)(((char*)name)-_IShellLinkDataList_Offset)
+static inline IShellLinkImpl *impl_from_IShellLinkW( IShellLinkW *iface )
+{
+    const int ofs = (int)(&(((IShellLinkImpl*)0)->lpvtblw));
+    return (IShellLinkImpl *)&((char*)iface)[-ofs];
+}
+#define _ICOM_THIS_From_IShellLinkW(class, iface) \
+    class* This = impl_from_IShellLinkW( iface )
+
+static inline IShellLinkImpl *impl_from_IPersistFile( IPersistFile *iface )
+{
+    const int ofs = (int)(&(((IShellLinkImpl*)0)->lpvtblPersistFile));
+    return (IShellLinkImpl *)&((char*)iface)[-ofs];
+}
+#define _ICOM_THIS_From_IPersistFile(class, iface) \
+    class* This = impl_from_IPersistFile( iface )
+
+static inline IShellLinkImpl *impl_from_IPersistStream( IPersistStream *iface )
+{
+    const int ofs = (int)(&(((IShellLinkImpl*)0)->lpvtblPersistStream));
+    return (IShellLinkImpl *)&((char*)iface)[-ofs];
+}
+#define _ICOM_THIS_From_IPersistStream(class, iface) \
+    class* This = impl_from_IPersistStream( iface )
+
+static inline IShellLinkImpl *impl_from_IShellLinkDataList( IShellLinkDataList *iface )
+{
+    const int ofs = (int)(&(((IShellLinkImpl*)0)->lpvtblShellLinkDataList));
+    return (IShellLinkImpl *)&((char*)iface)[-ofs];
+}
+#define _ICOM_THIS_From_IShellLinkDataList(class, iface) \
+    class* This = impl_from_IShellLinkDataList( iface )
+
+static inline IShellLinkImpl *impl_from_IShellExtInit( IShellExtInit *iface )
+{
+    const int ofs = (int)(&(((IShellLinkImpl*)0)->lpvtblShellExtInit));
+    return (IShellLinkImpl *)&((char*)iface)[-ofs];
+}
+#define _ICOM_THIS_From_IShellExtInit(class, iface) \
+    class* This = impl_from_IShellExtInit( iface )
 
 static HRESULT ShellLink_UpdatePath(LPWSTR sPathRel, LPCWSTR path, LPCWSTR sWorkDir, LPWSTR* psPath);
 
@@ -1064,6 +1087,7 @@ HRESULT WINAPI IShellLink_Constructor( I
 	sl->lpvtblPersistFile = &pfvt;
 	sl->lpvtblPersistStream = &psvt;
 	sl->lpvtblShellLinkDataList = &dlvt;
+	sl->lpvtblShellExtInit = &eivt;
 	sl->iShowCmd = SW_SHOWNORMAL;
 	sl->bDirty = FALSE;
 
@@ -1212,6 +1236,10 @@ static HRESULT WINAPI IShellLinkA_fnQuer
 	{
 	  *ppvObj = &(This->lpvtblShellLinkDataList);
 	}
+	else if(IsEqualIID(riid, &IID_IShellExtInit))
+	{
+	  *ppvObj = &(This->lpvtblShellExtInit);
+	}
 
 	if(*ppvObj)
 	{
@@ -2208,4 +2236,42 @@ static const IShellLinkDataListVtbl dlvt
     ShellLink_RemoveDataBlock,
     ShellLink_GetFlags,
     ShellLink_SetFlags
+};
+
+static HRESULT WINAPI
+ShellLink_ExtInit_QueryInterface( IShellExtInit* iface, REFIID riid, void** ppvObject )
+{
+    _ICOM_THIS_From_IShellExtInit(IShellLinkImpl, iface);
+    return IShellLinkA_QueryInterface((IShellLinkA*)This, riid, ppvObject);
+}
+
+static ULONG WINAPI
+ShellLink_ExtInit_AddRef( IShellExtInit* iface )
+{
+    _ICOM_THIS_From_IShellExtInit(IShellLinkImpl, iface);
+    return IShellLinkA_AddRef((IShellLinkA*)This);
+}
+
+static ULONG WINAPI
+ShellLink_ExtInit_Release( IShellExtInit* iface )
+{
+    _ICOM_THIS_From_IShellExtInit(IShellLinkImpl, iface);
+    return IShellLinkA_Release((IShellLinkA*)This);
+}
+
+static HRESULT WINAPI
+ShellLink_ExtInit_Initialize( IShellExtInit* iface, LPCITEMIDLIST pidlFolder,
+                              IDataObject *pdtobj, HKEY hkeyProgID )
+{
+    _ICOM_THIS_From_IShellExtInit(IShellLinkImpl, iface);
+    FIXME("%p %p %p %p\n", This, pidlFolder, pdtobj, hkeyProgID );
+    return E_NOTIMPL;
+}
+
+static const IShellExtInitVtbl eivt =
+{
+    ShellLink_ExtInit_QueryInterface,
+    ShellLink_ExtInit_AddRef,
+    ShellLink_ExtInit_Release,
+    ShellLink_ExtInit_Initialize
 };


More information about the wine-patches mailing list