Release 980913
[wine/multimedia.git] / dlls / shell32 / folders.c
blob75374f97d9f173a0b3d94d0afb310bbd03998c41
1 /*
2 * Shell Folder stuff (...and all the OLE-Objects of SHELL32.DLL)
4 * Copyright 1997 Marcus Meissner
5 * Copyright 1998 Juergen Schmied
7 * !!! currently work in progress on all classes !!!
8 * <contact juergen.schmied@metronet.de, 980801>
9 */
11 #include <ctype.h>
12 #include <stdlib.h>
13 #include <string.h>
14 #include "ole.h"
15 #include "ole2.h"
16 #include "debug.h"
17 #include "compobj.h"
18 #include "interfaces.h"
19 #include "shlobj.h"
20 #include "shell.h"
21 #include "winerror.h"
22 #include "winnls.h"
23 #include "winproc.h"
24 #include "commctrl.h"
26 #include "shell32_main.h"
29 /******************************************************************************
30 * foreward declaration
33 /* IExtractIcon implementation*/
34 static HRESULT WINAPI IExtractIcon_QueryInterface(LPEXTRACTICON, REFIID, LPVOID *);
35 static ULONG WINAPI IExtractIcon_AddRef(LPEXTRACTICON);
36 static ULONG WINAPI IExtractIcon_AddRef(LPEXTRACTICON);
37 static ULONG WINAPI IExtractIcon_Release(LPEXTRACTICON);
38 static HRESULT WINAPI IExtractIcon_GetIconLocation(LPEXTRACTICON, UINT32, LPSTR, UINT32, int *, UINT32 *);
39 static HRESULT WINAPI IExtractIcon_Extract(LPEXTRACTICON, LPCSTR, UINT32, HICON32 *, HICON32 *, UINT32);
41 /* IShellLink Implementation */
42 static HRESULT WINAPI IShellLink_QueryInterface(LPSHELLLINK,REFIID,LPVOID*);
43 static ULONG WINAPI IShellLink_AddRef(LPSHELLLINK);
44 static ULONG WINAPI IShellLink_Release(LPSHELLLINK);
47 /***********************************************************************
48 * IExtractIcon implementation
50 static struct IExtractIcon_VTable eivt =
51 { IExtractIcon_QueryInterface,
52 IExtractIcon_AddRef,
53 IExtractIcon_Release,
54 IExtractIcon_GetIconLocation,
55 IExtractIcon_Extract
57 /**************************************************************************
58 * IExtractIcon_Constructor
60 LPEXTRACTICON IExtractIcon_Constructor(LPCITEMIDLIST pidl)
61 { LPEXTRACTICON ei;
62 ei=(LPEXTRACTICON)HeapAlloc(GetProcessHeap(),0,sizeof(IExtractIcon));
63 ei->ref=1;
64 ei->lpvtbl=&eivt;
65 ei->pidl=ILClone(pidl);
67 TRACE(shell,"(%p)\n",ei);
68 return ei;
70 /**************************************************************************
71 * IExtractIcon_QueryInterface
73 static HRESULT WINAPI IExtractIcon_QueryInterface( LPEXTRACTICON this, REFIID riid, LPVOID *ppvObj)
74 { char xriid[50];
75 WINE_StringFromCLSID((LPCLSID)riid,xriid);
76 TRACE(shell,"(%p)->(\n\tIID:\t%s,%p)\n",this,xriid,ppvObj);
78 *ppvObj = NULL;
80 if(IsEqualIID(riid, &IID_IUnknown)) /*IUnknown*/
81 { *ppvObj = this;
83 else if(IsEqualIID(riid, &IID_IExtractIcon)) /*IExtractIcon*/
84 { *ppvObj = (IExtractIcon*)this;
87 if(*ppvObj)
88 { (*(LPEXTRACTICON*)ppvObj)->lpvtbl->fnAddRef(this);
89 TRACE(shell,"-- Interface: (%p)->(%p)\n",ppvObj,*ppvObj);
90 return S_OK;
92 TRACE(shell,"-- Interface: E_NOINTERFACE\n");
93 return E_NOINTERFACE;
96 /**************************************************************************
97 * IExtractIcon_AddRef
99 static ULONG WINAPI IExtractIcon_AddRef(LPEXTRACTICON this)
100 { TRACE(shell,"(%p)->(count=%lu)\n",this,(this->ref)+1);
101 return ++(this->ref);
103 /**************************************************************************
104 * IExtractIcon_Release
106 static ULONG WINAPI IExtractIcon_Release(LPEXTRACTICON this)
107 { TRACE(shell,"(%p)->()\n",this);
108 if (!--(this->ref))
109 { TRACE(shell," destroying IExtractIcon(%p)\n",this);
110 SHFree(this->pidl);
111 HeapFree(GetProcessHeap(),0,this);
112 return 0;
114 return this->ref;
116 /**************************************************************************
117 * IExtractIcon_GetIconLocation
118 * NOTE
119 * FIXME returns allways the icon no. 3 (closed Folder)
121 static HRESULT WINAPI IExtractIcon_GetIconLocation(LPEXTRACTICON this, UINT32 uFlags, LPSTR szIconFile, UINT32 cchMax, int * piIndex, UINT32 * pwFlags)
122 { FIXME (shell,"(%p) (flags=%u file=%s max=%u %p %p) semi-stub\n", this, uFlags, szIconFile, cchMax, piIndex, pwFlags);
123 if (!szIconFile)
124 { *piIndex = 20;
126 else
127 { *piIndex = 3;
129 *pwFlags = GIL_NOTFILENAME;
131 return NOERROR;
133 /**************************************************************************
134 * IExtractIcon_Extract
136 static HRESULT WINAPI IExtractIcon_Extract(LPEXTRACTICON this, LPCSTR pszFile, UINT32 nIconIndex, HICON32 *phiconLarge, HICON32 *phiconSmall, UINT32 nIconSize)
137 { FIXME (shell,"(%p) (file=%s index=%u %p %p size=%u) semi-stub\n", this, pszFile, nIconIndex, phiconLarge, phiconSmall, nIconSize);
138 *phiconLarge = pImageList_GetIcon(ShellBigIconList, nIconIndex, ILD_TRANSPARENT);
139 *phiconSmall = pImageList_GetIcon(ShellSmallIconList, nIconIndex, ILD_TRANSPARENT);
140 return S_OK;
143 /**************************************************************************
144 * IShellLink Implementation
147 static struct IShellLink_VTable slvt = {
148 IShellLink_QueryInterface,
149 IShellLink_AddRef,
150 IShellLink_Release,
151 (void *)0xcafe0004,
152 (void *)0xcafe0005,
153 (void *)0xcafe0006,
154 (void *)0xcafe0007,
155 (void *)0xcafe0008,
156 (void *)0xcafe0009,
157 (void *)0xcafe0010,
158 (void *)0xcafe0011,
159 (void *)0xcafe0012,
160 (void *)0xcafe0013,
161 (void *)0xcafe0014,
162 (void *)0xcafe0015,
163 (void *)0xcafe0016,
164 (void *)0xcafe0017,
165 (void *)0xcafe0018,
166 (void *)0xcafe0019,
167 (void *)0xcafe0020,
168 (void *)0xcafe0021
171 /**************************************************************************
172 * IShellLink_Constructor
174 LPSHELLLINK IShellLink_Constructor()
175 { LPSHELLLINK sl;
177 sl = (LPSHELLLINK)HeapAlloc(GetProcessHeap(),0,sizeof(IShellLink));
178 sl->ref = 1;
179 sl->lpvtbl = &slvt;
180 TRACE(shell,"(%p)->()\n",sl);
181 return sl;
184 /**************************************************************************
185 * IShellLink::QueryInterface
187 static HRESULT WINAPI IShellLink_QueryInterface(
188 LPSHELLLINK this, REFIID riid, LPVOID *ppvObj)
189 { char xriid[50];
190 WINE_StringFromCLSID((LPCLSID)riid,xriid);
191 TRACE(shell,"(%p)->(\n\tIID:\t%s)\n",this,xriid);
193 *ppvObj = NULL;
195 if(IsEqualIID(riid, &IID_IUnknown)) /*IUnknown*/
196 { *ppvObj = this;
198 else if(IsEqualIID(riid, &IID_IShellLink)) /*IShellLink*/
199 { *ppvObj = (LPSHELLLINK)this;
202 if(*ppvObj)
203 { (*(LPSHELLLINK*)ppvObj)->lpvtbl->fnAddRef(this);
204 TRACE(shell,"-- Interface: (%p)->(%p)\n",ppvObj,*ppvObj);
205 return S_OK;
207 TRACE(shell,"-- Interface: E_NOINTERFACE\n");
208 return E_NOINTERFACE;
210 /******************************************************************************
211 * IShellLink_AddRef
213 static ULONG WINAPI IShellLink_AddRef(LPSHELLLINK this)
214 { TRACE(shell,"(%p)->(count=%lu)\n",this,this->ref);
215 return ++(this->ref);
217 /******************************************************************************
218 * IClassFactory_Release
220 static ULONG WINAPI IShellLink_Release(LPSHELLLINK this)
221 { TRACE(shell,"(%p)->(count=%lu)\n",this,this->ref);
222 if (!--(this->ref))
223 { TRACE(shell,"-- destroying IShellLink(%p)\n",this);
224 HeapFree(GetProcessHeap(),0,this);
225 return 0;
227 return this->ref;