Added stubs for user32,advapi32 functions.
[wine/multimedia.git] / dlls / shell32 / folders.c
blob4373a3a4d7bd772a5e10e099de56bf54200e42ef
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"
25 #include "pidl.h"
27 #include "shell32_main.h"
30 /******************************************************************************
31 * foreward declaration
34 /* IExtractIcon implementation*/
35 static HRESULT WINAPI IExtractIcon_QueryInterface(LPEXTRACTICON, REFIID, LPVOID *);
36 static ULONG WINAPI IExtractIcon_AddRef(LPEXTRACTICON);
37 static ULONG WINAPI IExtractIcon_AddRef(LPEXTRACTICON);
38 static ULONG WINAPI IExtractIcon_Release(LPEXTRACTICON);
39 static HRESULT WINAPI IExtractIcon_GetIconLocation(LPEXTRACTICON, UINT32, LPSTR, UINT32, int *, UINT32 *);
40 static HRESULT WINAPI IExtractIcon_Extract(LPEXTRACTICON, LPCSTR, UINT32, HICON32 *, HICON32 *, UINT32);
42 /* IShellLink Implementation */
43 static HRESULT WINAPI IShellLink_QueryInterface(LPSHELLLINK,REFIID,LPVOID*);
44 static ULONG WINAPI IShellLink_AddRef(LPSHELLLINK);
45 static ULONG WINAPI IShellLink_Release(LPSHELLLINK);
46 static HRESULT WINAPI IShellLink_GetPath(LPSHELLLINK, LPSTR,INT32, WIN32_FIND_DATA32A *, DWORD);
47 static HRESULT WINAPI IShellLink_GetIDList(LPSHELLLINK, LPITEMIDLIST *);
48 static HRESULT WINAPI IShellLink_SetIDList(LPSHELLLINK, LPCITEMIDLIST);
49 static HRESULT WINAPI IShellLink_GetDescription(LPSHELLLINK, LPSTR,INT32);
50 static HRESULT WINAPI IShellLink_SetDescription(LPSHELLLINK, LPCSTR);
51 static HRESULT WINAPI IShellLink_GetWorkingDirectory(LPSHELLLINK, LPSTR,INT32);
52 static HRESULT WINAPI IShellLink_SetWorkingDirectory(LPSHELLLINK, LPCSTR);
53 static HRESULT WINAPI IShellLink_GetArguments(LPSHELLLINK, LPSTR,INT32);
54 static HRESULT WINAPI IShellLink_SetArguments(LPSHELLLINK, LPCSTR);
55 static HRESULT WINAPI IShellLink_GetHotkey(LPSHELLLINK, WORD *);
56 static HRESULT WINAPI IShellLink_SetHotkey(LPSHELLLINK, WORD);
57 static HRESULT WINAPI IShellLink_GetShowCmd(LPSHELLLINK, INT32 *);
58 static HRESULT WINAPI IShellLink_SetShowCmd(LPSHELLLINK, INT32);
59 static HRESULT WINAPI IShellLink_GetIconLocation(LPSHELLLINK, LPSTR,INT32,INT32 *);
60 static HRESULT WINAPI IShellLink_SetIconLocation(LPSHELLLINK, LPCSTR,INT32);
61 static HRESULT WINAPI IShellLink_SetRelativePath(LPSHELLLINK, LPCSTR, DWORD);
62 static HRESULT WINAPI IShellLink_Resolve(LPSHELLLINK, HWND32, DWORD);
63 static HRESULT WINAPI IShellLink_SetPath(LPSHELLLINK, LPCSTR);
66 /***********************************************************************
67 * IExtractIcon implementation
69 static struct IExtractIcon_VTable eivt =
70 { IExtractIcon_QueryInterface,
71 IExtractIcon_AddRef,
72 IExtractIcon_Release,
73 IExtractIcon_GetIconLocation,
74 IExtractIcon_Extract
76 /**************************************************************************
77 * IExtractIcon_Constructor
79 LPEXTRACTICON IExtractIcon_Constructor(LPCITEMIDLIST pidl)
80 { LPEXTRACTICON ei;
81 ei=(LPEXTRACTICON)HeapAlloc(GetProcessHeap(),0,sizeof(IExtractIcon));
82 ei->ref=1;
83 ei->lpvtbl=&eivt;
84 ei->pidl=ILClone(pidl);
86 TRACE(shell,"(%p)\n",ei);
87 return ei;
89 /**************************************************************************
90 * IExtractIcon_QueryInterface
92 static HRESULT WINAPI IExtractIcon_QueryInterface( LPEXTRACTICON this, REFIID riid, LPVOID *ppvObj)
93 { char xriid[50];
94 WINE_StringFromCLSID((LPCLSID)riid,xriid);
95 TRACE(shell,"(%p)->(\n\tIID:\t%s,%p)\n",this,xriid,ppvObj);
97 *ppvObj = NULL;
99 if(IsEqualIID(riid, &IID_IUnknown)) /*IUnknown*/
100 { *ppvObj = this;
102 else if(IsEqualIID(riid, &IID_IExtractIcon)) /*IExtractIcon*/
103 { *ppvObj = (IExtractIcon*)this;
106 if(*ppvObj)
107 { (*(LPEXTRACTICON*)ppvObj)->lpvtbl->fnAddRef(this);
108 TRACE(shell,"-- Interface: (%p)->(%p)\n",ppvObj,*ppvObj);
109 return S_OK;
111 TRACE(shell,"-- Interface: E_NOINTERFACE\n");
112 return E_NOINTERFACE;
115 /**************************************************************************
116 * IExtractIcon_AddRef
118 static ULONG WINAPI IExtractIcon_AddRef(LPEXTRACTICON this)
119 { TRACE(shell,"(%p)->(count=%lu)\n",this,(this->ref)+1);
120 return ++(this->ref);
122 /**************************************************************************
123 * IExtractIcon_Release
125 static ULONG WINAPI IExtractIcon_Release(LPEXTRACTICON this)
126 { TRACE(shell,"(%p)->()\n",this);
127 if (!--(this->ref))
128 { TRACE(shell," destroying IExtractIcon(%p)\n",this);
129 SHFree(this->pidl);
130 HeapFree(GetProcessHeap(),0,this);
131 return 0;
133 return this->ref;
135 /**************************************************************************
136 * IExtractIcon_GetIconLocation
137 * NOTE
138 * FIXME returns allways the icon no. 3 (closed Folder)
140 static HRESULT WINAPI IExtractIcon_GetIconLocation(LPEXTRACTICON this, UINT32 uFlags, LPSTR szIconFile, UINT32 cchMax, int * piIndex, UINT32 * pwFlags)
141 { FIXME (shell,"(%p) (flags=%u file=%s max=%u %p %p) semi-stub\n", this, uFlags, szIconFile, cchMax, piIndex, pwFlags);
142 if (!szIconFile)
143 { *piIndex = 20;
145 else
146 { *piIndex = 3;
148 *pwFlags = GIL_NOTFILENAME;
150 return NOERROR;
152 /**************************************************************************
153 * IExtractIcon_Extract
155 static HRESULT WINAPI IExtractIcon_Extract(LPEXTRACTICON this, LPCSTR pszFile, UINT32 nIconIndex, HICON32 *phiconLarge, HICON32 *phiconSmall, UINT32 nIconSize)
156 { FIXME (shell,"(%p) (file=%s index=%u %p %p size=%u) semi-stub\n", this, pszFile, nIconIndex, phiconLarge, phiconSmall, nIconSize);
157 *phiconLarge = pImageList_GetIcon(ShellBigIconList, nIconIndex, ILD_TRANSPARENT);
158 *phiconSmall = pImageList_GetIcon(ShellSmallIconList, nIconIndex, ILD_TRANSPARENT);
159 return S_OK;
162 /**************************************************************************
163 * IShellLink Implementation
166 static struct IShellLink_VTable slvt =
167 { IShellLink_QueryInterface,
168 IShellLink_AddRef,
169 IShellLink_Release,
170 IShellLink_GetPath,
171 IShellLink_GetIDList,
172 IShellLink_SetIDList,
173 IShellLink_GetDescription,
174 IShellLink_SetDescription,
175 IShellLink_GetWorkingDirectory,
176 IShellLink_SetWorkingDirectory,
177 IShellLink_GetArguments,
178 IShellLink_SetArguments,
179 IShellLink_GetHotkey,
180 IShellLink_SetHotkey,
181 IShellLink_GetShowCmd,
182 IShellLink_SetShowCmd,
183 IShellLink_GetIconLocation,
184 IShellLink_SetIconLocation,
185 IShellLink_SetRelativePath,
186 IShellLink_Resolve,
187 IShellLink_SetPath
190 /**************************************************************************
191 * IShellLink_Constructor
193 LPSHELLLINK IShellLink_Constructor()
194 { LPSHELLLINK sl;
196 sl = (LPSHELLLINK)HeapAlloc(GetProcessHeap(),0,sizeof(IShellLink));
197 sl->ref = 1;
198 sl->lpvtbl = &slvt;
199 TRACE(shell,"(%p)->()\n",sl);
200 return sl;
203 /**************************************************************************
204 * IShellLink::QueryInterface
206 static HRESULT WINAPI IShellLink_QueryInterface(
207 LPSHELLLINK this, REFIID riid, LPVOID *ppvObj)
208 { char xriid[50];
209 WINE_StringFromCLSID((LPCLSID)riid,xriid);
210 TRACE(shell,"(%p)->(\n\tIID:\t%s)\n",this,xriid);
212 *ppvObj = NULL;
214 if(IsEqualIID(riid, &IID_IUnknown)) /*IUnknown*/
215 { *ppvObj = this;
217 else if(IsEqualIID(riid, &IID_IShellLink)) /*IShellLink*/
218 { *ppvObj = (LPSHELLLINK)this;
221 if(*ppvObj)
222 { (*(LPSHELLLINK*)ppvObj)->lpvtbl->fnAddRef(this);
223 TRACE(shell,"-- Interface: (%p)->(%p)\n",ppvObj,*ppvObj);
224 return S_OK;
226 TRACE(shell,"-- Interface: E_NOINTERFACE\n");
227 return E_NOINTERFACE;
229 /******************************************************************************
230 * IShellLink_AddRef
232 static ULONG WINAPI IShellLink_AddRef(LPSHELLLINK this)
233 { TRACE(shell,"(%p)->(count=%lu)\n",this,this->ref);
234 return ++(this->ref);
236 /******************************************************************************
237 * IClassFactory_Release
239 static ULONG WINAPI IShellLink_Release(LPSHELLLINK this)
240 { TRACE(shell,"(%p)->(count=%lu)\n",this,this->ref);
241 if (!--(this->ref))
242 { TRACE(shell,"-- destroying IShellLink(%p)\n",this);
243 HeapFree(GetProcessHeap(),0,this);
244 return 0;
246 return this->ref;
249 static HRESULT WINAPI IShellLink_GetPath(LPSHELLLINK this, LPSTR pszFile,INT32 cchMaxPath, WIN32_FIND_DATA32A *pfd, DWORD fFlags)
250 { FIXME(shell,"(%p)->(pfile=%p len=%u find_data=%p flags=%lu)\n",this, pszFile, cchMaxPath, pfd, fFlags);
251 strncpy(pszFile,"c:\\foo.bar", cchMaxPath);
252 return NOERROR;
254 static HRESULT WINAPI IShellLink_GetIDList(LPSHELLLINK this, LPITEMIDLIST * ppidl)
255 { FIXME(shell,"(%p)->(ppidl=%p)\n",this, ppidl);
256 *ppidl = _ILCreateDesktop();
257 return NOERROR;
259 static HRESULT WINAPI IShellLink_SetIDList(LPSHELLLINK this, LPCITEMIDLIST pidl)
260 { FIXME(shell,"(%p)->(pidl=%p)\n",this, pidl);
261 return NOERROR;
263 static HRESULT WINAPI IShellLink_GetDescription(LPSHELLLINK this, LPSTR pszName,INT32 cchMaxName)
264 { FIXME(shell,"(%p)->(%p len=%u)\n",this, pszName, cchMaxName);
265 strncpy(pszName,"Description, FIXME",cchMaxName);
266 return NOERROR;
268 static HRESULT WINAPI IShellLink_SetDescription(LPSHELLLINK this, LPCSTR pszName)
269 { FIXME(shell,"(%p)->(desc=%s)\n",this, pszName);
270 return NOERROR;
272 static HRESULT WINAPI IShellLink_GetWorkingDirectory(LPSHELLLINK this, LPSTR pszDir,INT32 cchMaxPath)
273 { FIXME(shell,"(%p)->()\n",this);
274 strncpy(pszDir,"c:\\", cchMaxPath);
275 return NOERROR;
277 static HRESULT WINAPI IShellLink_SetWorkingDirectory(LPSHELLLINK this, LPCSTR pszDir)
278 { FIXME(shell,"(%p)->(dir=%s)\n",this, pszDir);
279 return NOERROR;
281 static HRESULT WINAPI IShellLink_GetArguments(LPSHELLLINK this, LPSTR pszArgs,INT32 cchMaxPath)
282 { FIXME(shell,"(%p)->(%p len=%u)\n",this, pszArgs, cchMaxPath);
283 strncpy(pszArgs, "", cchMaxPath);
284 return NOERROR;
286 static HRESULT WINAPI IShellLink_SetArguments(LPSHELLLINK this, LPCSTR pszArgs)
287 { FIXME(shell,"(%p)->(args=%s)\n",this, pszArgs);
288 return NOERROR;
290 static HRESULT WINAPI IShellLink_GetHotkey(LPSHELLLINK this, WORD *pwHotkey)
291 { FIXME(shell,"(%p)->(%p)\n",this, pwHotkey);
292 *pwHotkey=0x0;
293 return NOERROR;
295 static HRESULT WINAPI IShellLink_SetHotkey(LPSHELLLINK this, WORD wHotkey)
296 { FIXME(shell,"(%p)->(hotkey=%x)\n",this, wHotkey);
297 return NOERROR;
299 static HRESULT WINAPI IShellLink_GetShowCmd(LPSHELLLINK this, INT32 *piShowCmd)
300 { FIXME(shell,"(%p)->(%p)\n",this, piShowCmd);
301 *piShowCmd=0;
302 return NOERROR;
304 static HRESULT WINAPI IShellLink_SetShowCmd(LPSHELLLINK this, INT32 iShowCmd)
305 { FIXME(shell,"(%p)->(showcmd=%x)\n",this, iShowCmd);
306 return NOERROR;
308 static HRESULT WINAPI IShellLink_GetIconLocation(LPSHELLLINK this, LPSTR pszIconPath,INT32 cchIconPath,INT32 *piIcon)
309 { FIXME(shell,"(%p)->(%p len=%u iicon=%p)\n",this, pszIconPath, cchIconPath, piIcon);
310 strncpy(pszIconPath,"shell32.dll",cchIconPath);
311 *piIcon=1;
312 return NOERROR;
314 static HRESULT WINAPI IShellLink_SetIconLocation(LPSHELLLINK this, LPCSTR pszIconPath,INT32 iIcon)
315 { FIXME(shell,"(%p)->(path=%s iicon=%u)\n",this, pszIconPath, iIcon);
316 return NOERROR;
318 static HRESULT WINAPI IShellLink_SetRelativePath(LPSHELLLINK this, LPCSTR pszPathRel, DWORD dwReserved)
319 { FIXME(shell,"(%p)->(path=%s %lx)\n",this, pszPathRel, dwReserved);
320 return NOERROR;
322 static HRESULT WINAPI IShellLink_Resolve(LPSHELLLINK this, HWND32 hwnd, DWORD fFlags)
323 { FIXME(shell,"(%p)->(hwnd=%x flags=%lx)\n",this, hwnd, fFlags);
324 return NOERROR;
326 static HRESULT WINAPI IShellLink_SetPath(LPSHELLLINK this, LPCSTR pszFile)
327 { FIXME(shell,"(%p)->(path=%s)\n",this, pszFile);
328 return NOERROR;