[SHELL32][SDK] Implement PathIsSlowA and SHSetFolderPathA (#5841)

- Implement PathIsSlowA and SHSetFolderPathA functions.
- Add PathIsSlow and SHSetFolderPath prototypes to <shlobj.h>.
- Fix some <shlobj.h>'s bugs.
- Improve SHOpenPropSheetA function.
This commit is contained in:
Katayama Hirofumi MZ 2023-10-28 09:59:12 +09:00 committed by GitHub
parent dcc9a2d8f3
commit 9dfb3e8e05
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 103 additions and 55 deletions

View file

@ -225,13 +225,13 @@ SHGetSetFolderCustomSettingsA(LPSHFOLDERCUSTOMSETTINGSA pfcs,
*/ */
BOOL WINAPI BOOL WINAPI
SHOpenPropSheetW( SHOpenPropSheetW(
_In_opt_z_ LPCWSTR pszCaption, _In_opt_ LPCWSTR pszCaption,
_In_opt_ HKEY *ahKeys, _In_opt_ HKEY *ahKeys,
_In_ UINT cKeys, _In_ UINT cKeys,
_In_ const CLSID *pclsidDefault, _In_ const CLSID *pclsidDefault,
_In_ IDataObject *pDataObject, _In_ IDataObject *pDataObject,
_In_opt_ IShellBrowser *pShellBrowser, _In_opt_ IShellBrowser *pShellBrowser,
_In_opt_z_ LPCWSTR pszStartPage) _In_opt_ LPCWSTR pszStartPage)
{ {
FIXME("SHOpenPropSheetW() stub\n"); FIXME("SHOpenPropSheetW() stub\n");
return FALSE; return FALSE;
@ -1028,24 +1028,11 @@ FirstUserLogon(LPWSTR lpUnknown1, LPWSTR lpUnknown2)
*/ */
EXTERN_C HRESULT EXTERN_C HRESULT
WINAPI WINAPI
SHSetFolderPathA(int csidl, SHSetFolderPathW(
HANDLE hToken, _In_ INT csidl,
DWORD dwFlags, _In_ HANDLE hToken,
LPCSTR pszPath) _In_ DWORD dwFlags,
{ _In_ LPCWSTR pszPath)
FIXME("SHSetFolderPathA() stub\n");
return E_FAIL;
}
/*
* Unimplemented
*/
EXTERN_C HRESULT
WINAPI
SHSetFolderPathW(int csidl,
HANDLE hToken,
DWORD dwFlags,
LPCWSTR pszPath)
{ {
FIXME("SHSetFolderPathW() stub\n"); FIXME("SHSetFolderPathW() stub\n");
return E_FAIL; return E_FAIL;
@ -1089,23 +1076,14 @@ SHShouldShowWizards(LPVOID lpUnknown)
*/ */
EXTERN_C BOOL EXTERN_C BOOL
WINAPI WINAPI
PathIsSlowW(LPCWSTR pszFile, DWORD dwFileAttr) PathIsSlowW(
_In_ LPCWSTR pszFile,
_In_ DWORD dwAttr)
{ {
FIXME("PathIsSlowW() stub\n"); FIXME("PathIsSlowW() stub\n");
return FALSE; return FALSE;
} }
/*
* Unimplemented
*/
EXTERN_C BOOL
WINAPI
PathIsSlowA(LPCSTR pszFile, DWORD dwFileAttr)
{
FIXME("PathIsSlowA() stub\n");
return FALSE;
}
/* /*
* Unimplemented * Unimplemented
*/ */

View file

@ -9,7 +9,10 @@
WINE_DEFAULT_DEBUG_CHANNEL(shell); WINE_DEFAULT_DEBUG_CHANNEL(shell);
static BOOL OpenEffectiveToken(DWORD DesiredAccess, HANDLE *phToken) static BOOL
OpenEffectiveToken(
_In_ DWORD DesiredAccess,
_Out_ HANDLE *phToken)
{ {
BOOL ret; BOOL ret;
@ -28,6 +31,40 @@ static BOOL OpenEffectiveToken(DWORD DesiredAccess, HANDLE *phToken)
return ret; return ret;
} }
/*************************************************************************
* SHSetFolderPathA (SHELL32.231)
*
* @see https://learn.microsoft.com/en-us/windows/win32/api/shlobj_core/nf-shlobj_core-shsetfolderpatha
*/
EXTERN_C
HRESULT WINAPI
SHSetFolderPathA(
_In_ INT csidl,
_In_ HANDLE hToken,
_In_ DWORD dwFlags,
_In_ LPCSTR pszPath)
{
TRACE("(%d, %p, 0x%X, %s)\n", csidl, hToken, dwFlags, debugstr_a(pszPath));
CStringW strPathW(pszPath);
return SHSetFolderPathW(csidl, hToken, dwFlags, strPathW);
}
/*************************************************************************
* PathIsSlowA (SHELL32.240)
*
* @see https://learn.microsoft.com/en-us/windows/win32/api/shlobj/nf-shlobj-pathisslowa
*/
EXTERN_C
BOOL WINAPI
PathIsSlowA(
_In_ LPCSTR pszFile,
_In_ DWORD dwAttr)
{
TRACE("(%s, 0x%X)\n", debugstr_a(pszFile), dwAttr);
CStringW strFileW(pszFile);
return PathIsSlowW(strFileW, dwAttr);
}
/************************************************************************* /*************************************************************************
* SHOpenEffectiveToken (SHELL32.235) * SHOpenEffectiveToken (SHELL32.235)
*/ */
@ -68,7 +105,7 @@ EXTERN_C DWORD WINAPI SHGetUserSessionId(_In_opt_ HANDLE hToken)
EXTERN_C EXTERN_C
HRESULT WINAPI HRESULT WINAPI
SHInvokePrivilegedFunctionW( SHInvokePrivilegedFunctionW(
_In_z_ LPCWSTR pszName, _In_ LPCWSTR pszName,
_In_ PRIVILEGED_FUNCTION fn, _In_ PRIVILEGED_FUNCTION fn,
_In_opt_ LPARAM lParam) _In_opt_ LPARAM lParam)
{ {
@ -110,7 +147,9 @@ SHInvokePrivilegedFunctionW(
*/ */
EXTERN_C EXTERN_C
BOOL WINAPI BOOL WINAPI
SHTestTokenPrivilegeW(_In_opt_ HANDLE hToken, _In_z_ LPCWSTR lpName) SHTestTokenPrivilegeW(
_In_opt_ HANDLE hToken,
_In_ LPCWSTR lpName)
{ {
LUID Luid; LUID Luid;
DWORD dwLength; DWORD dwLength;
@ -314,7 +353,7 @@ SHFindComputer(LPCITEMIDLIST pidlRoot, LPCITEMIDLIST pidlSavedSearch)
static HRESULT static HRESULT
Int64ToStr( Int64ToStr(
_In_ LONGLONG llValue, _In_ LONGLONG llValue,
_Out_writes_z_(cchValue) LPWSTR pszValue, _Out_writes_(cchValue) LPWSTR pszValue,
_In_ UINT cchValue) _In_ UINT cchValue)
{ {
WCHAR szBuff[40]; WCHAR szBuff[40];
@ -361,9 +400,9 @@ Int64GetNumFormat(
_Out_ NUMBERFMTW *pDest, _Out_ NUMBERFMTW *pDest,
_In_opt_ const NUMBERFMTW *pSrc, _In_opt_ const NUMBERFMTW *pSrc,
_In_ DWORD dwNumberFlags, _In_ DWORD dwNumberFlags,
_Out_writes_z_(cchDecimal) LPWSTR pszDecimal, _Out_writes_(cchDecimal) LPWSTR pszDecimal,
_In_ INT cchDecimal, _In_ INT cchDecimal,
_Out_writes_z_(cchThousand) LPWSTR pszThousand, _Out_writes_(cchThousand) LPWSTR pszThousand,
_In_ INT cchThousand) _In_ INT cchThousand)
{ {
WCHAR szBuff[20]; WCHAR szBuff[20];
@ -419,7 +458,7 @@ EXTERN_C
INT WINAPI INT WINAPI
Int64ToString( Int64ToString(
_In_ LONGLONG llValue, _In_ LONGLONG llValue,
_Out_writes_z_(cchOut) LPWSTR pszOut, _Out_writes_(cchOut) LPWSTR pszOut,
_In_ UINT cchOut, _In_ UINT cchOut,
_In_ BOOL bUseFormat, _In_ BOOL bUseFormat,
_In_opt_ const NUMBERFMTW *pNumberFormat, _In_opt_ const NUMBERFMTW *pNumberFormat,
@ -457,7 +496,7 @@ EXTERN_C
INT WINAPI INT WINAPI
LargeIntegerToString( LargeIntegerToString(
_In_ const LARGE_INTEGER *pLargeInt, _In_ const LARGE_INTEGER *pLargeInt,
_Out_writes_z_(cchOut) LPWSTR pszOut, _Out_writes_(cchOut) LPWSTR pszOut,
_In_ UINT cchOut, _In_ UINT cchOut,
_In_ BOOL bUseFormat, _In_ BOOL bUseFormat,
_In_opt_ const NUMBERFMTW *pNumberFormat, _In_opt_ const NUMBERFMTW *pNumberFormat,
@ -475,30 +514,30 @@ LargeIntegerToString(
EXTERN_C EXTERN_C
BOOL WINAPI BOOL WINAPI
SHOpenPropSheetA( SHOpenPropSheetA(
_In_opt_z_ LPCSTR pszCaption, _In_opt_ LPCSTR pszCaption,
_In_opt_ HKEY *ahKeys, _In_opt_ HKEY *ahKeys,
_In_ UINT cKeys, _In_ UINT cKeys,
_In_ const CLSID *pclsidDefault, _In_ const CLSID *pclsidDefault,
_In_ IDataObject *pDataObject, _In_ IDataObject *pDataObject,
_In_opt_ IShellBrowser *pShellBrowser, _In_opt_ IShellBrowser *pShellBrowser,
_In_opt_z_ LPCSTR pszStartPage) _In_opt_ LPCSTR pszStartPage)
{ {
WCHAR szStartPageW[MAX_PATH], szCaptionW[MAX_PATH]; CStringW strStartPageW, strCaptionW;
LPCWSTR pszCaptionW = NULL, pszStartPageW = NULL; LPCWSTR pszCaptionW = NULL, pszStartPageW = NULL;
TRACE("(%s, %p, %u, %p, %p, %p, %s)", pszCaption, ahKeys, cKeys, pclsidDefault, pDataObject, TRACE("(%s, %p, %u, %p, %p, %p, %s)", debugstr_a(pszCaption), ahKeys, cKeys, pclsidDefault,
pShellBrowser, pszStartPage); pDataObject, pShellBrowser, debugstr_a(pszStartPage));
if (pszCaption) if (pszCaption)
{ {
SHAnsiToUnicode(pszCaption, szCaptionW, _countof(szCaptionW)); strStartPageW = pszCaption;
pszCaptionW = szCaptionW; pszCaptionW = strCaptionW;
} }
if (pszStartPage) if (pszStartPage)
{ {
SHAnsiToUnicode(pszStartPage, szStartPageW, _countof(szStartPageW)); strStartPageW = pszStartPage;
pszStartPageW = szStartPageW; pszStartPageW = strStartPageW;
} }
return SHOpenPropSheetW(pszCaptionW, ahKeys, cKeys, pclsidDefault, return SHOpenPropSheetW(pszCaptionW, ahKeys, cKeys, pclsidDefault,

View file

@ -190,7 +190,35 @@ SHGetFolderPathAndSubDirW(
_In_opt_ LPCWSTR, _In_opt_ LPCWSTR,
_Out_writes_(MAX_PATH) LPWSTR); _Out_writes_(MAX_PATH) LPWSTR);
#define SHGetFolderPathAndSubDir WINELIB_NAME_AW(SHGetFolderPathAndSubDir); #define SHGetFolderPathAndSubDir WINELIB_NAME_AW(SHGetFolderPathAndSubDir)
HRESULT WINAPI
SHSetFolderPathA(
_In_ INT csidl,
_In_ HANDLE hToken,
_In_ DWORD dwFlags,
_In_ LPCSTR pszPath);
HRESULT WINAPI
SHSetFolderPathW(
_In_ INT csidl,
_In_ HANDLE hToken,
_In_ DWORD dwFlags,
_In_ LPCWSTR pszPath);
#define SHSetFolderPath WINELIB_NAME_AW(SHSetFolderPath)
BOOL WINAPI
PathIsSlowA(
_In_ LPCSTR pszFile,
_In_ DWORD dwAttr);
BOOL WINAPI
PathIsSlowW(
_In_ LPCWSTR pszFile,
_In_ DWORD dwAttr);
#define PathIsSlow WINELIB_NAME_AW(PathIsSlow)
_Success_(return != 0) _Success_(return != 0)
BOOL BOOL
@ -242,7 +270,7 @@ SHPathPrepareForWriteW(
_In_opt_ IUnknown*, _In_opt_ IUnknown*,
_In_ LPCWSTR, DWORD); _In_ LPCWSTR, DWORD);
#define SHPathPrepareForWrite WINELIB_NAME_AW(SHPathPrepareForWrite); #define SHPathPrepareForWrite WINELIB_NAME_AW(SHPathPrepareForWrite)
UINT UINT
WINAPI WINAPI
@ -342,22 +370,25 @@ HINSTANCE WINAPI SHGetShellStyleHInstance(VOID);
BOOL WINAPI BOOL WINAPI
SHOpenPropSheetA( SHOpenPropSheetA(
_In_opt_z_ LPCSTR pszCaption, _In_opt_ LPCSTR pszCaption,
_In_opt_ HKEY *ahKeys, _In_opt_ HKEY *ahKeys,
_In_ UINT cKeys, _In_ UINT cKeys,
_In_ const CLSID *pclsidDefault, _In_ const CLSID *pclsidDefault,
_In_ IDataObject *pDataObject, _In_ IDataObject *pDataObject,
_In_opt_ IShellBrowser *pShellBrowser, _In_opt_ IShellBrowser *pShellBrowser,
_In_opt_z_ LPCSTR pszStartPage); _In_opt_ LPCSTR pszStartPage);
BOOL WINAPI BOOL WINAPI
SHOpenPropSheetW( SHOpenPropSheetW(
_In_opt_z_ LPCWSTR pszCaption, _In_opt_ LPCWSTR pszCaption,
_In_opt_ HKEY *ahKeys, _In_opt_ HKEY *ahKeys,
_In_ UINT cKeys, _In_ UINT cKeys,
_In_ const CLSID *pclsidDefault, _In_ const CLSID *pclsidDefault,
_In_ IDataObject *pDataObject, _In_ IDataObject *pDataObject,
_In_opt_ IShellBrowser *pShellBrowser, _In_opt_ IShellBrowser *pShellBrowser,
_In_opt_z_ LPCWSTR pszStartPage); _In_opt_ LPCWSTR pszStartPage);
#define SHOpenPropSheet WINELIB_NAME_AW(SHOpenPropSheet)
/***************************************************************************** /*****************************************************************************
* IContextMenu interface * IContextMenu interface