shell32: Add IKnownFolder::SetPath() implementation.

This commit is contained in:
Mariusz Pluciński 2011-06-23 18:50:09 +02:00 committed by Alexandre Julliard
parent 5e90301bc2
commit 1c7240ba4e
2 changed files with 31 additions and 4 deletions

View file

@ -3285,8 +3285,36 @@ static HRESULT WINAPI knownfolder_SetPath(
DWORD dwFlags,
LPCWSTR pszPath)
{
FIXME("0x%08x, %p\n", dwFlags, debugstr_w(pszPath));
return E_NOTIMPL;
struct knownfolder *knownfolder = impl_from_IKnownFolder( iface );
HRESULT hr = S_OK;
HKEY hKey;
WCHAR szPath[MAX_PATH];
TRACE("(%p, 0x%08x, %p)\n", knownfolder, dwFlags, debugstr_w(pszPath));
/* check if the known folder is registered */
if(!knownfolder->registryPath)
hr = E_FAIL;
if(SUCCEEDED(hr))
{
if(dwFlags & KF_FLAG_DONT_UNEXPAND)
lstrcpyW(szPath, pszPath);
else
hr = ( ExpandEnvironmentStringsW(pszPath, szPath, sizeof(szPath)/sizeof(szPath[0]))!=0 ? S_OK : HRESULT_FROM_WIN32(GetLastError()));
}
if(SUCCEEDED(hr))
hr = HRESULT_FROM_WIN32(RegOpenKeyExW(HKEY_LOCAL_MACHINE, knownfolder->registryPath, 0, KEY_SET_VALUE, &hKey));
if(SUCCEEDED(hr))
{
hr = HRESULT_FROM_WIN32(RegSetValueExW(hKey, szRelativePath, 0, REG_SZ, (LPBYTE)pszPath, (lstrlenW(pszPath)+1)*sizeof(WCHAR)));
RegCloseKey(hKey);
}
return hr;
}
static HRESULT WINAPI knownfolder_GetIDList(

View file

@ -1190,13 +1190,11 @@ static void test_knownFolders(void)
/* try to set new path for folder */
hr = IKnownFolder_SetPath(folder, 0, sExample2Path);
todo_wine
ok(hr == S_OK, "setting path failed: 0x%0x\n", hr);
/* verify modified path */
hr = IKnownFolder_GetPath(folder, 0, &folderPath);
ok(hr == S_OK, "failed to get path from known folder: 0x%08x\n", hr);
todo_wine
ok(lstrcmpiW(folderPath, sExample2Path)==0, "invalid known folder path retreived: \"%s\" when \"%s\" was expected\n", wine_dbgstr_w(folderPath), wine_dbgstr_w(sExamplePath));
CoTaskMemFree(folderPath);
@ -1208,6 +1206,7 @@ static void test_knownFolders(void)
/* again verify modified path */
hr = IKnownFolder_GetPath(folder, 0, &folderPath);
ok(hr == S_OK, "failed to get path from known folder: 0x%08x\n", hr);
todo_wine
ok(lstrcmpiW(folderPath, sExamplePath)==0, "invalid known folder path retreived: \"%s\" when \"%s\" was expected\n", wine_dbgstr_w(folderPath), wine_dbgstr_w(sExamplePath));
CoTaskMemFree(folderPath);