Commit f3301c6b authored by Juan Lang's avatar Juan Lang Committed by Alexandre Julliard

- comment fixes

- improved error checking and conformance with Windows - remove some spurious error messages
parent 78f1224f
......@@ -131,7 +131,7 @@ HRESULT WINAPI IControlPanel_Constructor(IUnknown* pUnkOuter, REFIID riid, LPVOI
sf->lpVtblPersistFolder2 = &vt_PersistFolder2;
sf->lpVtblShellExecuteHookW = &vt_ShellExecuteHookW;
sf->lpVtblShellExecuteHookA = &vt_ShellExecuteHookA;
sf->pidlRoot = _ILCreateControl(); /* my qualified pidl */
sf->pidlRoot = _ILCreateControlPanel(); /* my qualified pidl */
sf->pUnkOuter = pUnkOuter ? pUnkOuter : _IUnknown_ (sf);
if (!SUCCEEDED(IUnknown_QueryInterface(_IUnknown_(sf), riid, ppv))) {
......
......@@ -1080,94 +1080,6 @@ LPITEMIDLIST WINAPI SHSimpleIDListFromPathAW(LPCVOID lpszPath)
}
/*************************************************************************
* SHGetSpecialFolderLocation [SHELL32.@]
*
* gets the folder locations from the registry and creates a pidl
* creates missing reg keys and directories
*
* PARAMS
* hwndOwner [I]
* nFolder [I] CSIDL_xxxxx
* ppidl [O] PIDL of a special folder
*
* NOTES
* In NT5, SHGetSpecialFolderLocation needs the <winntdir>/Recent
* directory. If the directory is missing it returns a x80070002.
*/
HRESULT WINAPI SHGetSpecialFolderLocation(
HWND hwndOwner,
INT nFolder,
LPITEMIDLIST * ppidl)
{
CHAR szPath[MAX_PATH];
HRESULT hr = E_INVALIDARG;
TRACE_(shell)("(%p,0x%x,%p)\n", hwndOwner,nFolder,ppidl);
if (ppidl)
{
*ppidl = NULL;
switch (nFolder)
{
case CSIDL_DESKTOP:
*ppidl = _ILCreateDesktop();
break;
case CSIDL_DRIVES:
*ppidl = _ILCreateMyComputer();
break;
case CSIDL_NETWORK:
*ppidl = _ILCreateNetwork ();
break;
case CSIDL_CONTROLS:
*ppidl = _ILCreateControl ();
break;
case CSIDL_PRINTERS:
*ppidl = _ILCreatePrinter ();
break;
case CSIDL_BITBUCKET:
*ppidl = _ILCreateBitBucket ();
break;
default:
if (SHGetSpecialFolderPathA(hwndOwner, szPath, nFolder, TRUE))
{
DWORD attributes=0;
TRACE_(shell)("Value=%s\n",szPath);
hr = SHILCreateFromPathA(szPath, ppidl, &attributes);
}
}
if(*ppidl) hr = NOERROR;
}
TRACE_(shell)("-- (new pidl %p)\n",*ppidl);
return hr;
}
/*************************************************************************
* SHGetFolderLocation [SHELL32.@]
*
* NOTES
* the pidl can be a simple one. since we can't get the path out of the pidl
* we have to take all data from the pidl
*/
HRESULT WINAPI SHGetFolderLocation(
HWND hwnd,
int csidl,
HANDLE hToken,
DWORD dwFlags,
LPITEMIDLIST *ppidl)
{
FIXME("%p 0x%08x %p 0x%08lx %p\n",
hwnd, csidl, hToken, dwFlags, ppidl);
return SHGetSpecialFolderLocation(hwnd, csidl, ppidl);
}
/*************************************************************************
* SHGetDataFromIDListA [SHELL32.247]
*
* NOTES
......@@ -1517,12 +1429,6 @@ HRESULT WINAPI SHBindToParent(LPCITEMIDLIST pidl, REFIID riid, LPVOID *ppv, LPCI
* ### 1. section creating pidls ###
*
*************************************************************************
* _ILCreateDesktop()
* _ILCreateIExplore()
* _ILCreateMyComputer()
* _ILCreateDrive()
* _ILCreateFolder()
* _ILCreateValue()
*/
LPITEMIDLIST _ILCreateDesktop()
{ TRACE("()\n");
......@@ -1539,16 +1445,42 @@ LPITEMIDLIST _ILCreateIExplore()
return _ILCreateGuid(PT_GUID, &CLSID_Internet);
}
LPITEMIDLIST _ILCreateControl()
{ TRACE("()\n");
/* FIXME: needs to be child of MyComputer */
return _ILCreateGuid(PT_SHELLEXT, &CLSID_ControlPanel);
LPITEMIDLIST _ILCreateControlPanel()
{
LPITEMIDLIST parent = _ILCreateGuid(PT_GUID, &CLSID_MyComputer), ret = NULL;
TRACE("()\n");
if (parent)
{
LPITEMIDLIST cpl = _ILCreateGuid(PT_GUID, &CLSID_ControlPanel);
if (cpl)
{
ret = ILCombine(parent, cpl);
SHFree(cpl);
}
SHFree(parent);
}
return ret;
}
LPITEMIDLIST _ILCreatePrinter()
{ TRACE("()\n");
/* FIXME: needs to be child of MyComputer */
return _ILCreateGuid(PT_SHELLEXT, &CLSID_Printers);
LPITEMIDLIST _ILCreatePrinters()
{
LPITEMIDLIST parent = _ILCreateGuid(PT_GUID, &CLSID_MyComputer), ret = NULL;
TRACE("()\n");
if (parent)
{
LPITEMIDLIST printers = _ILCreateGuid(PT_GUID, &CLSID_ControlPanel);
if (printers)
{
ret = ILCombine(parent, printers);
SHFree(printers);
}
SHFree(parent);
}
return ret;
}
LPITEMIDLIST _ILCreateNetwork()
......@@ -1561,11 +1493,6 @@ LPITEMIDLIST _ILCreateBitBucket()
return _ILCreateGuid(PT_GUID, &CLSID_RecycleBin);
}
/**************************************************************************
* _ILCreateGuid()
* Creates a new PIDL with type type (which can be one of PT_SHELLEXT or
* PT_GUID) with the given GUID data.
*/
LPITEMIDLIST _ILCreateGuid(PIDLTYPE type, REFIID guid)
{
LPITEMIDLIST pidlOut;
......@@ -1621,10 +1548,6 @@ LPITEMIDLIST _ILCreateWithTypeAndSize(PIDLTYPE type, UINT size)
return pidlOut;
}
/**************************************************************************
* _ILCreateFromFindDataA()
* Creates a new PIDL from stffile
*/
LPITEMIDLIST _ILCreateFromFindDataA(WIN32_FIND_DATAA * stffile )
{
char buff[MAX_PATH + 14 +1]; /* see WIN32_FIND_DATA */
......
......@@ -77,10 +77,10 @@
*
* (1) dummy byte is used, attributes are empty
* (2) IID_MyComputer = 20D04FE0L-3AEA-1069-A2D8-08002B30309D
* (3) two strings "workgroup" "microsoft network"
* (4) one string "\\sirius"
* (5) one string "whole network"
* (6) one string "\\sirius\c"
* (3) two strings "workgroup" "Microsoft Network"
* (4) two strings "\\sirius" "Microsoft Network"
* (5) one string "Entire Network"
* (6) two strings "\\sirius\c" "Microsoft Network"
* (7) contains string "mk:@MSITStore:C:\path\file.chm::/path/filename.htm"
* GUID 871C5380-42A0-1069-A2EA-08002B30309D
*/
......@@ -136,7 +136,7 @@ typedef struct tagPIDLDATA
WORD uFileTime; /*08*/
WORD uFileAttribs; /*10*/
CHAR szNames[1]; /*12*/
/* Here are comming two strings. The first is the long name.
/* Here are coming two strings. The first is the long name.
The second the dos name when needed or just 0x00 */
} file, folder, generic;
struct
......@@ -204,8 +204,8 @@ LPITEMIDLIST _ILCreateFromPathA (LPCSTR szPath);
/* Other helpers */
LPITEMIDLIST _ILCreateMyComputer (void);
LPITEMIDLIST _ILCreateIExplore (void);
LPITEMIDLIST _ILCreateControl (void);
LPITEMIDLIST _ILCreatePrinter (void);
LPITEMIDLIST _ILCreateControlPanel (void);
LPITEMIDLIST _ILCreatePrinters (void);
LPITEMIDLIST _ILCreateNetwork (void);
LPITEMIDLIST _ILCreateBitBucket (void);
LPITEMIDLIST _ILCreateDrive (LPCSTR);
......
......@@ -40,6 +40,7 @@
#include "shlobj.h"
#include "shell32_main.h"
#include "undocshell.h"
#include "pidl.h"
#include "wine/unicode.h"
#include "shlwapi.h"
......@@ -714,9 +715,10 @@ typedef struct
#define HKLM HKEY_LOCAL_MACHINE
#define HKCU HKEY_CURRENT_USER
#define HKEY_DISALLOWED (HKEY)0
#define HKEY_UNIMPLEMENTED (HKEY)1
#define HKEY_WINDOWSPATH (HKEY)2
#define HKEY_EMPTY (HKEY)3
#define HKEY_NONEXISTENT (HKEY)3
static const CSIDL_DATA CSIDL_Data[] =
{
{ /* CSIDL_DESKTOP */
......@@ -725,14 +727,14 @@ static const CSIDL_DATA CSIDL_Data[] =
"Desktop"
},
{ /* CSIDL_INTERNET */
0, HKEY_UNIMPLEMENTED, /* FIXME */
0, HKEY_DISALLOWED,
NULL,
NULL,
},
{ /* CSIDL_PROGRAMS */
9, HKCU,
"Programs",
"Start Menu\\Programs"
0, HKEY_DISALLOWED,
NULL,
NULL,
},
{ /* CSIDL_CONTROLS (.CPL files) */
10, HKLM,
......@@ -770,9 +772,9 @@ static const CSIDL_DATA CSIDL_Data[] =
"SendTo"
},
{ /* CSIDL_BITBUCKET - Recycle Bin */
0, HKEY_UNIMPLEMENTED, /* FIXME */
0, HKEY_DISALLOWED,
NULL,
NULL,
"recycled"
},
{ /* CSIDL_STARTMENU */
9, HKCU,
......@@ -789,7 +791,7 @@ static const CSIDL_DATA CSIDL_Data[] =
"My Music",
"My Documents\\My Music"
},
{ /* CSIDL_MYMUSIC */
{ /* CSIDL_MYVIDEO */
1, HKCU,
"My Video",
"My Documents\\My Video"
......@@ -805,14 +807,14 @@ static const CSIDL_DATA CSIDL_Data[] =
"Desktop"
},
{ /* CSIDL_DRIVES */
0, HKEY_UNIMPLEMENTED, /* FIXME */
0, HKEY_DISALLOWED,
NULL,
NULL,
"My Computer"
},
{ /* CSIDL_NETWORK */
0, HKEY_EMPTY,
0, HKEY_DISALLOWED,
NULL,
NULL,
"Network Neighborhood"
},
{ /* CSIDL_NETHOOD */
9, HKCU,
......@@ -865,12 +867,12 @@ static const CSIDL_DATA CSIDL_Data[] =
"Local Settings\\Application Data",
},
{ /* CSIDL_ALTSTARTUP */
0, HKEY_UNIMPLEMENTED, /* FIXME */
0, HKEY_NONEXISTENT,
NULL,
NULL
},
{ /* CSIDL_COMMON_ALTSTARTUP */
0, HKEY_UNIMPLEMENTED, /* FIXME */
0, HKEY_NONEXISTENT,
NULL,
NULL
},
......@@ -965,22 +967,22 @@ static const CSIDL_DATA CSIDL_Data[] =
"Start Menu\\Programs\\Administrative Tools"
},
{ /* CSIDL_CONNECTIONS */
0, 0, /* FIXME */
0, HKEY_DISALLOWED,
NULL,
NULL
},
{ /* unassigned 32 */
0, 0,
0, HKEY_DISALLOWED,
NULL,
NULL
},
{ /* unassigned 33 */
0, 0,
0, HKEY_DISALLOWED,
NULL,
NULL
},
{ /* unassigned 34 */
0, 0,
0, HKEY_DISALLOWED,
NULL,
NULL
},
......@@ -1056,22 +1058,20 @@ HRESULT WINAPI SHGetFolderPathW(
TRACE("%p,%p,csidl=0x%04x\n", hwndOwner,pszPath,csidl);
if (!pszPath)
return E_INVALIDARG;
*pszPath = '\0';
if ((folder >= sizeof(CSIDL_Data) / sizeof(CSIDL_Data[0])) ||
(CSIDL_Data[folder].hRootKey == 0))
{
ERR("folder 0x%04lx unknown or not allowed\n", folder);
return E_FAIL;
}
(CSIDL_Data[folder].hRootKey == HKEY_DISALLOWED))
return E_INVALIDARG;
if (CSIDL_Data[folder].hRootKey == HKEY_UNIMPLEMENTED)
{
FIXME("folder 0x%04lx unknown, please add.\n", folder);
return E_FAIL;
}
if (CSIDL_Data[folder].hRootKey == HKEY_EMPTY)
{
*pszPath = '\0';
return S_OK;
}
if (CSIDL_Data[folder].hRootKey == HKEY_NONEXISTENT)
return S_FALSE;
/* Special case for some values that don't exist in registry */
if (CSIDL_Data[folder].hRootKey == HKEY_WINDOWSPATH)
......@@ -1212,19 +1212,21 @@ HRESULT WINAPI SHGetFolderPathA(
DWORD dwFlags,
LPSTR pszPath)
{
WCHAR szTemp[MAX_PATH];
HRESULT hr;
WCHAR szTemp[MAX_PATH];
HRESULT hr;
hr = SHGetFolderPathW(hwndOwner, csidl, hToken, dwFlags, szTemp);
if (hr == S_OK)
{
if (!WideCharToMultiByte( CP_ACP, 0, szTemp, -1, pszPath, MAX_PATH, NULL, NULL ))
pszPath[MAX_PATH - 1] = 0;
}
if (!pszPath)
return E_INVALIDARG;
TRACE("%p,%p,csidl=0x%04x\n",hwndOwner,pszPath,csidl);
*pszPath = '\0';
hr = SHGetFolderPathW(hwndOwner, csidl, hToken, dwFlags, szTemp);
if (SUCCEEDED(hr))
WideCharToMultiByte(CP_ACP, 0, szTemp, -1, pszPath, MAX_PATH, NULL,
NULL);
return hr;
TRACE("%p,%p,csidl=0x%04x\n",hwndOwner,pszPath,csidl);
return hr;
}
/*************************************************************************
......@@ -1275,3 +1277,130 @@ BOOL WINAPI SHGetSpecialFolderPathAW (
return SHGetSpecialFolderPathW (hwndOwner, szPath, csidl, bCreate);
return SHGetSpecialFolderPathA (hwndOwner, szPath, csidl, bCreate);
}
/*************************************************************************
* SHGetSpecialFolderLocation [SHELL32.@]
*
* gets the folder locations from the registry and creates a pidl
* creates missing reg keys and directories
*
* PARAMS
* hwndOwner [I]
* nFolder [I] CSIDL_xxxxx
* ppidl [O] PIDL of a special folder
*
* NOTES
* In NT5, SHGetSpecialFolderLocation needs the <winntdir>/Recent
* directory. If the directory is missing it returns a x80070002.
* In most cases, this forwards to SHGetSpecialFolderPath, but
* CSIDLs with virtual folders (not real paths) must be handled
* here.
*/
HRESULT WINAPI SHGetSpecialFolderLocation(
HWND hwndOwner,
INT nFolder,
LPITEMIDLIST * ppidl)
{
HRESULT hr = E_INVALIDARG;
TRACE("(%p,0x%x,%p)\n", hwndOwner,nFolder,ppidl);
if (!ppidl)
return E_INVALIDARG;
*ppidl = NULL;
switch (nFolder)
{
case CSIDL_DESKTOP:
*ppidl = _ILCreateDesktop();
break;
case CSIDL_INTERNET:
*ppidl = _ILCreateIExplore();
break;
case CSIDL_CONTROLS:
*ppidl = _ILCreateControlPanel();
break;
case CSIDL_PRINTERS:
*ppidl = _ILCreatePrinters();
break;
case CSIDL_BITBUCKET:
*ppidl = _ILCreateBitBucket();
break;
case CSIDL_DRIVES:
*ppidl = _ILCreateMyComputer();
break;
case CSIDL_NETWORK:
*ppidl = _ILCreateNetwork();
break;
case CSIDL_ALTSTARTUP:
case CSIDL_COMMON_ALTSTARTUP:
hr = E_FAIL;
break;
case CSIDL_COMPUTERSNEARME:
hr = E_FAIL;
break;
default:
{
WCHAR szPath[MAX_PATH];
if (SHGetSpecialFolderPathW(hwndOwner, szPath, nFolder, TRUE))
{
DWORD attributes=0;
TRACE("Value=%s\n", debugstr_w(szPath));
hr = SHILCreateFromPathW(szPath, ppidl, &attributes);
}
}
}
if(*ppidl)
hr = NOERROR;
TRACE("-- (new pidl %p)\n",*ppidl);
return hr;
}
/*************************************************************************
* SHGetFolderLocation [SHELL32.@]
*
* NOTES
* the pidl can be a simple one. since we can't get the path out of the pidl
* we have to take all data from the pidl
* Mostly we forward to SHGetSpecialFolderLocation, but a few special cases
* we handle here.
*/
HRESULT WINAPI SHGetFolderLocation(
HWND hwnd,
int csidl,
HANDLE hToken,
DWORD dwFlags,
LPITEMIDLIST *ppidl)
{
HRESULT hr;
TRACE_(shell)("%p 0x%08x %p 0x%08lx %p\n",
hwnd, csidl, hToken, dwFlags, ppidl);
if (!ppidl)
return E_INVALIDARG;
switch (csidl)
{
case CSIDL_ALTSTARTUP:
case CSIDL_COMMON_ALTSTARTUP:
*ppidl = NULL;
hr = S_FALSE;
break;
default:
hr = SHGetSpecialFolderLocation(hwnd, csidl, ppidl);
}
return hr;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment