Mariusz Pluciński : shell32: Add IKnownFolder::SetPath () implementation.
Alexandre Julliard
julliard at winehq.org
Fri Jun 24 13:54:02 CDT 2011
Module: wine
Branch: master
Commit: 1c7240ba4ed3fe7050f64e0f6e8159df0f7b88b9
URL: http://source.winehq.org/git/wine.git/?a=commit;h=1c7240ba4ed3fe7050f64e0f6e8159df0f7b88b9
Author: Mariusz Pluciński <vshader at gmail.com>
Date: Thu Jun 23 18:50:09 2011 +0200
shell32: Add IKnownFolder::SetPath() implementation.
---
dlls/shell32/shellpath.c | 32 ++++++++++++++++++++++++++++++--
dlls/shell32/tests/shellpath.c | 3 +--
2 files changed, 31 insertions(+), 4 deletions(-)
diff --git a/dlls/shell32/shellpath.c b/dlls/shell32/shellpath.c
index bd77031..8f4378f 100644
--- a/dlls/shell32/shellpath.c
+++ b/dlls/shell32/shellpath.c
@@ -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(
diff --git a/dlls/shell32/tests/shellpath.c b/dlls/shell32/tests/shellpath.c
index b58b5c2..825cca3 100644
--- a/dlls/shell32/tests/shellpath.c
+++ b/dlls/shell32/tests/shellpath.c
@@ -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);
More information about the wine-cvs
mailing list