Commit 859a1d0d authored by Hans Leidekker's avatar Hans Leidekker Committed by Alexandre Julliard

shell32: Implement SHGetFolderPathEx.

parent 678c6776
......@@ -356,6 +356,7 @@
@ stdcall SHGetFileInfoW(ptr long ptr long long)
@ stdcall SHGetFolderLocation(long long long long ptr)
@ stdcall SHGetFolderPathA(long long long long ptr)
@ stdcall SHGetFolderPathEx(ptr long ptr ptr long)
@ stdcall SHGetFolderPathAndSubDirA(long long long long str ptr)
@ stdcall SHGetFolderPathAndSubDirW(long long long long wstr ptr)
@ stdcall SHGetFolderPathW(long long long long ptr)
......
......@@ -2937,3 +2937,29 @@ HRESULT WINAPI SHGetKnownFolderPath(REFKNOWNFOLDERID rfid, DWORD flags, HANDLE t
}
return hr;
}
/*************************************************************************
* SHGetFolderPathEx [SHELL32.@]
*/
HRESULT WINAPI SHGetFolderPathEx(REFKNOWNFOLDERID rfid, DWORD flags, HANDLE token, LPWSTR path, DWORD len)
{
HRESULT hr;
WCHAR *buffer;
TRACE("%s, 0x%08x, %p, %p, %u\n", debugstr_guid(rfid), flags, token, path, len);
if (!path || !len) return E_INVALIDARG;
hr = SHGetKnownFolderPath( rfid, flags, token, &buffer );
if (SUCCEEDED( hr ))
{
if (strlenW( buffer ) + 1 > len)
{
CoTaskMemFree( buffer );
return HRESULT_FROM_WIN32( ERROR_INSUFFICIENT_BUFFER );
}
strcpyW( path, buffer );
CoTaskMemFree( buffer );
}
return hr;
}
......@@ -31,6 +31,7 @@
#include "shlobj.h"
#include "shlwapi.h"
#include "initguid.h"
#include "knownfolders.h"
#include "wine/test.h"
/* CSIDL_MYDOCUMENTS is now the same as CSIDL_PERSONAL, but what we want
......@@ -93,6 +94,9 @@ static LPITEMIDLIST (WINAPI *pILFindLastID)(LPCITEMIDLIST);
static int (WINAPI *pSHFileOperationA)(LPSHFILEOPSTRUCTA);
static HRESULT (WINAPI *pSHGetMalloc)(LPMALLOC *);
static UINT (WINAPI *pGetSystemWow64DirectoryA)(LPSTR,UINT);
static HRESULT (WINAPI *pSHGetKnownFolderPath)(REFKNOWNFOLDERID, DWORD, HANDLE, PWSTR *);
static HRESULT (WINAPI *pSHGetFolderPathEx)(REFKNOWNFOLDERID, DWORD, HANDLE, LPWSTR, DWORD);
static DLLVERSIONINFO shellVersion = { 0 };
static LPMALLOC pMalloc;
static const BYTE guidType[] = { PT_GUID };
......@@ -187,7 +191,9 @@ static void loadShell32(void)
GET_PROC(DllGetVersion)
GET_PROC(SHGetFolderPathA)
GET_PROC(SHGetFolderPathEx)
GET_PROC(SHGetFolderLocation)
GET_PROC(SHGetKnownFolderPath)
GET_PROC(SHGetSpecialFolderPathA)
GET_PROC(SHGetSpecialFolderLocation)
GET_PROC(ILFindLastID)
......@@ -833,6 +839,50 @@ static void test_NonExistentPath(void)
else skip("RegOpenKeyExA(HKEY_CURRENT_USER, %s, ...) failed\n", userShellFolders);
}
static void test_SHGetFolderPathEx(void)
{
HRESULT hr;
WCHAR buffer[MAX_PATH], *path;
DWORD len;
if (!pSHGetKnownFolderPath || !pSHGetFolderPathEx)
{
win_skip("SHGetKnownFolderPath or SHGetFolderPathEx not available\n");
return;
}
if (0) { /* crashes */
hr = pSHGetKnownFolderPath(&FOLDERID_Desktop, 0, NULL, NULL);
ok(hr == E_INVALIDARG, "expected E_INVALIDARG, got 0x%08x\n", hr);
}
path = NULL;
hr = pSHGetKnownFolderPath(&FOLDERID_Desktop, 0, NULL, &path);
ok(hr == S_OK, "expected S_OK, got 0x%08x\n", hr);
ok(path != NULL, "expected path != NULL\n");
hr = pSHGetFolderPathEx(&FOLDERID_Desktop, 0, NULL, buffer, MAX_PATH);
ok(hr == S_OK, "expected S_OK, got 0x%08x\n", hr);
ok(!lstrcmpiW(path, buffer), "expected equal paths\n");
len = lstrlenW(buffer);
CoTaskMemFree(path);
hr = pSHGetFolderPathEx(&FOLDERID_Desktop, 0, NULL, buffer, 0);
ok(hr == E_INVALIDARG, "expected E_INVALIDARG, got 0x%08x\n", hr);
if (0) { /* crashes */
hr = pSHGetFolderPathEx(&FOLDERID_Desktop, 0, NULL, NULL, len + 1);
ok(hr == E_INVALIDARG, "expected E_INVALIDARG, got 0x%08x\n", hr);
hr = pSHGetFolderPathEx(NULL, 0, NULL, buffer, MAX_PATH);
ok(hr == E_INVALIDARG, "expected E_INVALIDARG, got 0x%08x\n", hr);
}
hr = pSHGetFolderPathEx(&FOLDERID_Desktop, 0, NULL, buffer, len);
ok(hr == HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER), "expected 0x8007007a, got 0x%08x\n", hr);
hr = pSHGetFolderPathEx(&FOLDERID_Desktop, 0, NULL, buffer, len + 1);
ok(hr == S_OK, "expected S_OK, got 0x%08x\n", hr);
}
START_TEST(shellpath)
{
if (!init()) return;
......@@ -858,5 +908,6 @@ START_TEST(shellpath)
testWinDir();
testSystemDir();
test_NonExistentPath();
test_SHGetFolderPathEx();
}
}
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