ReactOS 0.4.16-dev-1056-gbe87e00
shellpath.c File Reference
#include <wine/config.h>
#include <windef.h>
#include <winbase.h>
#include <shlobj.h>
#include <undocshell.h>
#include <shlwapi.h>
#include <sddl.h>
#include <strsafe.h>
#include <wine/debug.h>
#include <wine/unicode.h>
#include <assert.h>
#include <shlwapi_undoc.h>
#include <shellutils.h>
#include <userenv.h>
#include "pidl.h"
#include "shell32_main.h"
#include "shresdef.h"
Include dependency graph for shellpath.c:

Go to the source code of this file.

Classes

struct  CSIDL_DATA
 

Macros

#define WIN32_NO_STATUS
 
#define _INC_WINDOWS
 
#define COBJMACROS
 
#define _WIN32_WINNT   _WIN32_WINNT_WS03
 
#define VALID_SHORT_PATH_CHAR_CLASSES
 
#define MSDOS_8DOT3_LEN   12 /* MS-DOS 8.3 filename == length 12 */
 
#define CSIDL_CONTACTS   0x0043
 
#define CSIDL_DOWNLOADS   0x0047
 
#define CSIDL_LINKS   0x004d
 
#define CSIDL_APPDATA_LOCALLOW   0x004e
 
#define CSIDL_SAVED_GAMES   0x0062
 
#define CSIDL_SEARCHES   0x0063
 

Typedefs

typedef enum _NT_PRODUCT_TYPE NT_PRODUCT_TYPE
 
typedef enum _NT_PRODUCT_TYPEPNT_PRODUCT_TYPE
 
typedef enum _CSIDL_Type CSIDL_Type
 

Enumerations

enum  _NT_PRODUCT_TYPE {
  NtProductWinNt = 1 , NtProductLanManNt , NtProductServer , NtProductWinNt = 1 ,
  NtProductLanManNt , NtProductServer
}
 
enum  _CSIDL_Type {
  CSIDL_Type_User , CSIDL_Type_AllUsers , CSIDL_Type_CurrVer , CSIDL_Type_Disallowed ,
  CSIDL_Type_NonExistent , CSIDL_Type_WindowsPath , CSIDL_Type_SystemPath , CSIDL_Type_SystemX86Path
}
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (shell)
 
static BOOL DoGetProductType (PNT_PRODUCT_TYPE ProductType)
 
BOOL APIENTRY IsRemovableDrive (DWORD iDrive)
 
static BOOL WINAPI PathSearchOnExtensionsW (_Inout_ LPWSTR pszPath, _In_opt_ LPCWSTR *ppszDirs, _In_ BOOL bDoSearch, _In_ DWORD dwWhich)
 
static BOOL WINAPI PathIsAbsoluteW (_In_ LPCWSTR path)
 
static BOOL WINAPI PathMakeAbsoluteW (_Inout_ LPWSTR path)
 
BOOL WINAPI IsLFNDriveW (LPCWSTR lpszPath)
 
static VOID WINAPI PathQualifyExW (_Inout_ LPWSTR pszPath, _Inout_opt_ LPCWSTR pszDir, _In_ DWORD dwFlags)
 
BOOL WINAPI PathAppendAW (LPVOID lpszPath1, LPCVOID lpszPath2)
 
static LPSTR PathGetExtensionA (LPCSTR lpszPath)
 
static LPWSTR PathGetExtensionW (LPCWSTR lpszPath)
 
LPVOID WINAPI SHPathGetExtensionW (LPCWSTR lpszPath, DWORD void1, DWORD void2)
 
BOOL WINAPI PathRemoveFileSpecAW (LPVOID lpszPath)
 
static void PathGetShortPathA (LPSTR pszPath)
 
static void PathGetShortPathW (LPWSTR pszPath)
 
VOID WINAPI PathGetShortPathAW (LPVOID pszPath)
 
BOOL WINAPI PathIsRootAW (LPCVOID lpszPath)
 
static BOOL PathIsExeA (LPCSTR lpszPath)
 
BOOL PathIsExeW (LPCWSTR lpszPath)
 
BOOL WINAPI PathIsExeAW (LPCVOID path)
 
BOOL WINAPI PathFileExistsAW (LPCVOID lpszPath)
 
BOOL WINAPI IsLFNDriveA (LPCSTR lpszPath)
 
BOOL WINAPI IsLFNDriveAW (LPCVOID lpszPath)
 
static BOOL PathMakeUniqueNameA (LPSTR lpszBuffer, DWORD dwBuffSize, LPCSTR lpszShortName, LPCSTR lpszLongName, LPCSTR lpszPathName)
 
static BOOL PathMakeUniqueNameW (LPWSTR lpszBuffer, DWORD dwBuffSize, LPCWSTR lpszShortName, LPCWSTR lpszLongName, LPCWSTR lpszPathName)
 
BOOL WINAPI PathMakeUniqueNameAW (LPVOID lpszBuffer, DWORD dwBuffSize, LPCVOID lpszShortName, LPCVOID lpszLongName, LPCVOID lpszPathName)
 
BOOL WINAPI PathYetAnotherMakeUniqueName (LPWSTR buffer, LPCWSTR path, LPCWSTR shortname, LPCWSTR longname)
 
int WINAPI PathCleanupSpec (LPCWSTR lpszPathW, LPWSTR lpszFileW)
 
VOID WINAPI PathQualifyA (LPSTR pszPath)
 
VOID WINAPI PathQualifyW (LPWSTR pszPath)
 
VOID WINAPI PathQualifyAW (LPVOID pszPath)
 
BOOL WINAPI PathResolveA (LPSTR path, LPCSTR *dirs, DWORD flags)
 
BOOL WINAPI PathResolveW (_Inout_ LPWSTR path, _Inout_opt_ LPCWSTR *dirs, _In_ DWORD flags)
 
BOOL WINAPI PathResolveAW (LPVOID path, LPCVOID *paths, DWORD flags)
 
static LONG PathProcessCommandA (LPCSTR lpszPath, LPSTR lpszBuff, DWORD dwBuffSize, DWORD dwFlags)
 
static LONG PathProcessCommandW (LPCWSTR lpszPath, LPWSTR lpszBuff, DWORD dwBuffSize, DWORD dwFlags)
 
LONG WINAPI PathProcessCommandAW (LPCVOID lpszPath, LPVOID lpszBuff, DWORD dwBuffSize, DWORD dwFlags)
 
INT SHGetSpecialFolderID (_In_ LPCWSTR pszName)
 
INT Shell_ParseSpecialFolder (_In_ LPCWSTR pszStart, _Out_ LPWSTR *ppch, _Out_ INT *pcch)
 
static HRESULT _SHExpandEnvironmentStrings (LPCWSTR szSrc, LPWSTR szDest)
 
static HRESULT _SHGetUserShellFolderPath (HKEY rootKey, LPCWSTR userPrefix, LPCWSTR value, LPWSTR path)
 
BOOL _SHGetUserProfileDirectoryW (HANDLE hToken, LPWSTR szPath, LPDWORD lpcchPath)
 
static HRESULT _SHGetDefaultValue (BYTE folder, LPWSTR pszPath)
 
static HRESULT _SHGetCurrentVersionPath (DWORD dwFlags, BYTE folder, LPWSTR pszPath)
 
static LPWSTR _GetUserSidStringFromToken (HANDLE Token)
 
static HRESULT _SHGetUserProfilePath (HANDLE hToken, DWORD dwFlags, BYTE folder, LPWSTR pszPath)
 
static HRESULT _SHGetAllUsersProfilePath (DWORD dwFlags, BYTE folder, LPWSTR pszPath)
 
static HRESULT _SHOpenProfilesKey (PHKEY pKey)
 
static HRESULT _SHGetProfilesValue (HKEY profilesKey, LPCWSTR szValueName, LPWSTR szValue, LPCWSTR szDefault)
 
HRESULT WINAPI SHGetFolderPathW (HWND hwndOwner, int nFolder, HANDLE hToken, DWORD dwFlags, LPWSTR pszPath)
 
HRESULT WINAPI SHGetFolderPathAndSubDirA (HWND hwndOwner, int nFolder, HANDLE hToken, DWORD dwFlags, LPCSTR pszSubPath, LPSTR pszPath)
 
HRESULT WINAPI SHGetFolderPathAndSubDirW (HWND hwndOwner, int nFolder, HANDLE hToken, DWORD dwFlags, LPCWSTR pszSubPath, LPWSTR pszPath)
 
HRESULT WINAPI SHGetFolderPathA (HWND hwndOwner, int nFolder, HANDLE hToken, DWORD dwFlags, LPSTR pszPath)
 
static HRESULT _SHRegisterFolders (HKEY hRootKey, HANDLE hToken, LPCWSTR szUserShellFolderPath, LPCWSTR szShellFolderPath, const UINT folders[], UINT foldersLen)
 
static HRESULT _SHRegisterUserShellFolders (BOOL bDefault)
 
static HRESULT _SHRegisterCommonShellFolders (void)
 
HRESULT SHELL_RegisterShellFolders (void)
 
BOOL WINAPI SHGetSpecialFolderPathA (HWND hwndOwner, LPSTR szPath, int nFolder, BOOL bCreate)
 
BOOL WINAPI SHGetSpecialFolderPathW (HWND hwndOwner, LPWSTR szPath, int nFolder, BOOL bCreate)
 
HRESULT WINAPI SHGetFolderLocation (HWND hwndOwner, int nFolder, HANDLE hToken, DWORD dwReserved, LPITEMIDLIST *ppidl)
 
HRESULT WINAPI SHGetSpecialFolderLocation (HWND hwndOwner, INT nFolder, LPITEMIDLIST *ppidl)
 

Variables

static const BOOL is_win64 = sizeof(void *) > sizeof(int)
 
static const WCHAR Application_DataW [] = L"Application Data"
 
static const WCHAR Local_Settings_Application_DataW [] = L"Local Settings\\Application Data"
 
static const WCHAR Local_Settings_HistoryW [] = L"Local Settings\\History"
 
static const WCHAR Local_Settings_Temporary_Internet_FilesW [] = L"Local Settings\\Temporary Internet Files"
 
static const WCHAR MusicW [] = L"Music"
 
static const WCHAR PicturesW [] = L"Pictures"
 
static const WCHAR Program_FilesW [] = L"Program Files"
 
static const WCHAR Program_Files_Common_FilesW [] = L"Program Files\\Common Files"
 
static const WCHAR Start_Menu_ProgramsW [] = L"Start Menu\\Programs"
 
static const WCHAR Start_Menu_Admin_ToolsW [] = L"Start Menu\\Programs\\Administrative Tools"
 
static const WCHAR Start_Menu_StartupW [] = L"Start Menu\\Programs\\StartUp"
 
static const WCHAR szSHFolders [] = L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders"
 
static const WCHAR szSHUserFolders [] = L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders"
 
static const WCHAR szKnownFolderDescriptions [] = L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\FolderDescriptions"
 
static const WCHAR szKnownFolderRedirections [] = L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders"
 
static const CSIDL_DATA CSIDL_Data []
 

Macro Definition Documentation

◆ _INC_WINDOWS

#define _INC_WINDOWS

Definition at line 29 of file shellpath.c.

◆ _WIN32_WINNT

#define _WIN32_WINNT   _WIN32_WINNT_WS03

Definition at line 55 of file shellpath.c.

◆ COBJMACROS

#define COBJMACROS

Definition at line 30 of file shellpath.c.

◆ CSIDL_APPDATA_LOCALLOW

#define CSIDL_APPDATA_LOCALLOW   0x004e

Definition at line 1211 of file shellpath.c.

◆ CSIDL_CONTACTS

#define CSIDL_CONTACTS   0x0043

Definition at line 1208 of file shellpath.c.

◆ CSIDL_DOWNLOADS

#define CSIDL_DOWNLOADS   0x0047

Definition at line 1209 of file shellpath.c.

◆ CSIDL_LINKS

#define CSIDL_LINKS   0x004d

Definition at line 1210 of file shellpath.c.

◆ CSIDL_SAVED_GAMES

#define CSIDL_SAVED_GAMES   0x0062

Definition at line 1212 of file shellpath.c.

◆ CSIDL_SEARCHES

#define CSIDL_SEARCHES   0x0063

Definition at line 1213 of file shellpath.c.

◆ MSDOS_8DOT3_LEN

#define MSDOS_8DOT3_LEN   12 /* MS-DOS 8.3 filename == length 12 */

◆ VALID_SHORT_PATH_CHAR_CLASSES

#define VALID_SHORT_PATH_CHAR_CLASSES
Value:
( \
)
#define PATH_CHAR_CLASS_OTHER_VALID
Definition: path.c:4316
#define PATH_CHAR_CLASS_COLON
Definition: path.c:4312
#define PATH_CHAR_CLASS_BACKSLASH
Definition: path.c:4311
#define PATH_CHAR_CLASS_DOT
Definition: path.c:4310

◆ WIN32_NO_STATUS

#define WIN32_NO_STATUS

Definition at line 28 of file shellpath.c.

Typedef Documentation

◆ CSIDL_Type

◆ NT_PRODUCT_TYPE

◆ PNT_PRODUCT_TYPE

Enumeration Type Documentation

◆ _CSIDL_Type

Enumerator
CSIDL_Type_User 
CSIDL_Type_AllUsers 
CSIDL_Type_CurrVer 
CSIDL_Type_Disallowed 
CSIDL_Type_NonExistent 
CSIDL_Type_WindowsPath 
CSIDL_Type_SystemPath 
CSIDL_Type_SystemX86Path 

Definition at line 1192 of file shellpath.c.

1192 {
1194#ifdef __REACTOS__
1195 CSIDL_Type_InMyDocuments,
1196#endif
1204} CSIDL_Type;
enum _CSIDL_Type CSIDL_Type
@ CSIDL_Type_CurrVer
Definition: shellpath.c:1198
@ CSIDL_Type_AllUsers
Definition: shellpath.c:1197
@ CSIDL_Type_WindowsPath
Definition: shellpath.c:1201
@ CSIDL_Type_Disallowed
Definition: shellpath.c:1199
@ CSIDL_Type_SystemX86Path
Definition: shellpath.c:1203
@ CSIDL_Type_SystemPath
Definition: shellpath.c:1202
@ CSIDL_Type_User
Definition: shellpath.c:1193
@ CSIDL_Type_NonExistent
Definition: shellpath.c:1200

◆ _NT_PRODUCT_TYPE

Enumerator
NtProductWinNt 
NtProductLanManNt 
NtProductServer 
NtProductWinNt 
NtProductLanManNt 
NtProductServer 

Definition at line 62 of file shellpath.c.

63{
enum _NT_PRODUCT_TYPE NT_PRODUCT_TYPE
enum _NT_PRODUCT_TYPE * PNT_PRODUCT_TYPE
@ NtProductWinNt
Definition: shellpath.c:64
@ NtProductLanManNt
Definition: shellpath.c:65
@ NtProductServer
Definition: shellpath.c:66

Function Documentation

◆ _GetUserSidStringFromToken()

static LPWSTR _GetUserSidStringFromToken ( HANDLE  Token)
static

Definition at line 2329 of file shellpath.c.

2330{
2331 char InfoBuffer[64];
2332 PTOKEN_USER UserInfo;
2333 DWORD InfoSize;
2334 LPWSTR SidStr;
2335
2336 UserInfo = (PTOKEN_USER) InfoBuffer;
2337 if (! GetTokenInformation(Token, TokenUser, InfoBuffer, sizeof(InfoBuffer),
2338 &InfoSize))
2339 {
2341 return NULL;
2342 UserInfo = HeapAlloc(GetProcessHeap(), 0, InfoSize);
2343 if (UserInfo == NULL)
2344 return NULL;
2345 if (! GetTokenInformation(Token, TokenUser, UserInfo, InfoSize,
2346 &InfoSize))
2347 {
2348 HeapFree(GetProcessHeap(), 0, UserInfo);
2349 return NULL;
2350 }
2351 }
2352
2353 if (! ConvertSidToStringSidW(UserInfo->User.Sid, &SidStr))
2354 SidStr = NULL;
2355
2356 if (UserInfo != (PTOKEN_USER) InfoBuffer)
2357 HeapFree(GetProcessHeap(), 0, UserInfo);
2358
2359 return SidStr;
2360}
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10
#define NULL
Definition: types.h:112
BOOL WINAPI GetTokenInformation(HANDLE TokenHandle, TOKEN_INFORMATION_CLASS TokenInformationClass, LPVOID TokenInformation, DWORD TokenInformationLength, PDWORD ReturnLength)
Definition: security.c:411
BOOL WINAPI ConvertSidToStringSidW(PSID Sid, LPWSTR *StringSid)
Definition: security.c:3583
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define HeapFree(x, y, z)
Definition: compat.h:735
unsigned long DWORD
Definition: ntddk_ex.h:95
SID_AND_ATTRIBUTES User
Definition: setypes.h:1010
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
struct _TOKEN_USER * PTOKEN_USER
@ TokenUser
Definition: setypes.h:966
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by _SHGetUserProfilePath().

◆ _SHExpandEnvironmentStrings()

static HRESULT _SHExpandEnvironmentStrings ( LPCWSTR  szSrc,
LPWSTR  szDest 
)
static

Definition at line 2564 of file shellpath.c.

2568{
2569 HRESULT hr;
2570#ifndef __REACTOS__
2571 WCHAR szTemp[MAX_PATH], szProfilesPrefix[MAX_PATH] = { 0 };
2572 HKEY key = NULL;
2573#else
2574 WCHAR szTemp[MAX_PATH];
2575#endif
2576
2577 TRACE("%s, %p\n", debugstr_w(szSrc), szDest);
2578
2579 if (!szSrc || !szDest) return E_INVALIDARG;
2580
2581 /* short-circuit if there's nothing to expand */
2582 if (szSrc[0] != '%')
2583 {
2584 strcpyW(szDest, szSrc);
2585 hr = S_OK;
2586 goto end;
2587 }
2588#ifndef __REACTOS__
2589 /* Get the profile prefix, we'll probably be needing it */
2591 if (SUCCEEDED(hr))
2592 {
2593 WCHAR def_val[MAX_PATH];
2594
2595 /* get the system drive */
2596 GetSystemDirectoryW(def_val, MAX_PATH);
2597 strcpyW( def_val + 3, L"Users" );
2598
2599 hr = _SHGetProfilesValue(key, L"ProfilesDirectory", szProfilesPrefix, def_val );
2600 }
2601#else
2602 hr = S_OK;
2603#endif
2604
2605 *szDest = 0;
2606 strcpyW(szTemp, szSrc);
2607 while (SUCCEEDED(hr) && szTemp[0] == '%')
2608 {
2609 if (!strncmpiW(szTemp, L"%ALLUSERSPROFILE%", ARRAY_SIZE(L"%ALLUSERSPROFILE%")-1))
2610 {
2611#ifndef __REACTOS__
2612 WCHAR szAllUsers[MAX_PATH];
2613
2614 strcpyW(szDest, szProfilesPrefix);
2615 hr = _SHGetProfilesValue(key, L"AllUsersProfile", szAllUsers, L"Public");
2616 PathAppendW(szDest, szAllUsers);
2617#else
2618 DWORD cchSize = cchDest;
2619 if (!GetAllUsersProfileDirectoryW(szDest, &cchSize))
2620 goto fallback_expand;
2621#endif
2622 PathAppendW(szDest, szTemp + ARRAY_SIZE(L"%ALLUSERSPROFILE%")-1);
2623 }
2624#ifndef __REACTOS__
2625 else if (!strncmpiW(szTemp, L"%PUBLIC%", ARRAY_SIZE(L"%PUBLIC%")-1))
2626 {
2627 WCHAR szAllUsers[MAX_PATH], def_val[MAX_PATH];
2628
2629 GetSystemDirectoryW(def_val, MAX_PATH);
2630 strcpyW( def_val + 3, L"Users\\Public" );
2631
2632 hr = _SHGetProfilesValue(key, L"Public", szAllUsers, def_val);
2633 PathAppendW(szDest, szAllUsers);
2634 PathAppendW(szDest, szTemp + ARRAY_SIZE(L"%PUBLIC%")-1);
2635 }
2636#endif
2637 else if (!strncmpiW(szTemp, L"%USERPROFILE%", ARRAY_SIZE(L"%USERPROFILE%")-1))
2638 {
2639#ifndef __REACTOS__
2641 DWORD userLen = MAX_PATH;
2642
2643 strcpyW(szDest, szProfilesPrefix);
2644 GetUserNameW(userName, &userLen);
2645 PathAppendW(szDest, userName);
2646#else
2647 DWORD cchSize = cchDest;
2648 if (!_SHGetUserProfileDirectoryW(hToken, szDest, &cchSize))
2649 goto fallback_expand;
2650#endif
2651 PathAppendW(szDest, szTemp + ARRAY_SIZE(L"%USERPROFILE%")-1);
2652 }
2653 else if (!strncmpiW(szTemp, L"%SystemDrive%", ARRAY_SIZE(L"%SystemDrive%")-1))
2654 {
2655#ifndef __REACTOS__
2657#else
2658 if (!GetSystemDirectoryW(szDest, cchDest))
2659 goto fallback_expand;
2660#endif
2661 strcpyW(szDest + 3, szTemp + ARRAY_SIZE(L"%SystemDrive%")-1 + 1);
2662 }
2663 else
2664#ifdef __REACTOS__
2665fallback_expand:
2666#endif
2667 {
2668#ifndef __REACTOS__
2669 DWORD ret = ExpandEnvironmentStringsW(szTemp, szDest, MAX_PATH);
2670#else
2671 DWORD ret = SHExpandEnvironmentStringsForUserW(hToken, szTemp, szDest, cchDest);
2672#endif
2673
2674#ifndef __REACTOS__
2675 if (ret > MAX_PATH)
2676#else
2677 if (ret > cchDest)
2678#endif
2680 else if (ret == 0)
2682 else if (!strcmpW( szTemp, szDest )) break; /* nothing expanded */
2683 }
2684 if (SUCCEEDED(hr)) strcpyW(szTemp, szDest);
2685 }
2686end:
2687#ifndef __REACTOS__
2688 if (key)
2690#endif
2691 TRACE("returning 0x%08x (input was %s, output is %s)\n", hr,
2692 debugstr_w(szSrc), debugstr_w(szDest));
2693 return hr;
2694}
static _In_ LPCWSTR _In_ DWORD _In_ int _In_ int cchDest
#define ARRAY_SIZE(A)
Definition: main.h:20
#define RegCloseKey(hKey)
Definition: registry.h:49
#define E_INVALIDARG
Definition: ddrawi.h:101
BOOL WINAPI GetUserNameW(LPWSTR lpszName, LPDWORD lpSize)
Definition: misc.c:291
#define MAX_PATH
Definition: compat.h:34
DWORD WINAPI ExpandEnvironmentStringsW(IN LPCWSTR lpSrc, IN LPWSTR lpDst, IN DWORD nSize)
Definition: environ.c:519
UINT WINAPI GetSystemDirectoryW(OUT LPWSTR lpBuffer, IN UINT uSize)
Definition: path.c:2313
static HRESULT _SHOpenProfilesKey(PHKEY pKey)
Definition: shellpath.c:2499
static HRESULT _SHGetProfilesValue(HKEY profilesKey, LPCWSTR szValueName, LPWSTR szValue, LPCWSTR szDefault)
Definition: shellpath.c:2514
BOOL _SHGetUserProfileDirectoryW(HANDLE hToken, LPWSTR szPath, LPDWORD lpcchPath)
Definition: shellpath.c:2108
BOOL WINAPI GetAllUsersProfileDirectoryW(_Out_opt_ LPWSTR lpProfileDir, _Inout_ LPDWORD lpcchSize)
Definition: profile.c:1310
GLuint GLuint end
Definition: gl.h:1545
#define S_OK
Definition: intsafe.h:52
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define debugstr_w
Definition: kernel32.h:32
#define L(x)
Definition: ntvdm.h:50
#define PathAppendW
Definition: pathcch.h:309
#define strncmpiW(s1, s2, n)
Definition: unicode.h:46
#define strcmpW(s1, s2)
Definition: unicode.h:44
#define strcpyW(d, s)
Definition: unicode.h:35
HRESULT hr
Definition: shlfolder.c:183
#define TRACE(s)
Definition: solgame.cpp:4
Definition: copy.c:22
int ret
#define E_NOT_SUFFICIENT_BUFFER
Definition: winerror.h:2345
#define HRESULT_FROM_WIN32(x)
Definition: winerror.h:92
static const WCHAR userName[]
Definition: wnet.c:2156
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by _SHGetUserShellFolderPath(), and SHGetFolderPathAndSubDirW().

◆ _SHGetAllUsersProfilePath()

static HRESULT _SHGetAllUsersProfilePath ( DWORD  dwFlags,
BYTE  folder,
LPWSTR  pszPath 
)
static

Definition at line 2459 of file shellpath.c.

2461{
2462 HRESULT hr;
2463
2464 TRACE("0x%08x,0x%02x,%p\n", dwFlags, folder, pszPath);
2465
2467 return E_INVALIDARG;
2469 return E_INVALIDARG;
2470 if (!pszPath)
2471 return E_INVALIDARG;
2472
2474#ifndef __REACTOS__
2475 hr = _SHGetDefaultValue(folder, pszPath);
2476#else
2477 hr = _SHGetDefaultValue(NULL, folder, pszPath);
2478#endif
2479 else
2480 {
2481#ifndef __REACTOS__
2483#else
2485#endif
2486 CSIDL_Data[folder].szValueName, pszPath);
2487 if (FAILED(hr))
2488#ifndef __REACTOS__
2489 hr = _SHGetDefaultValue(folder, pszPath);
2490#else
2491 hr = _SHGetDefaultValue(NULL, folder, pszPath);
2492#endif
2493 }
2494 TRACE("returning 0x%08x (output path is %s)\n", hr, debugstr_w(pszPath));
2495 return hr;
2496}
static HRESULT _SHGetDefaultValue(BYTE folder, LPWSTR pszPath)
Definition: shellpath.c:2144
static const CSIDL_DATA CSIDL_Data[]
Definition: shellpath.c:1225
static HRESULT _SHGetUserShellFolderPath(HKEY rootKey, LPCWSTR userPrefix, LPCWSTR value, LPWSTR path)
Definition: shellpath.c:2025
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
#define FAILED(hr)
Definition: intsafe.h:51
@ SHGFP_TYPE_DEFAULT
Definition: shlobj.h:2158
Definition: fci.c:116
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1176
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12

Referenced by _SHRegisterFolders(), and SHGetFolderPathAndSubDirW().

◆ _SHGetCurrentVersionPath()

static HRESULT _SHGetCurrentVersionPath ( DWORD  dwFlags,
BYTE  folder,
LPWSTR  pszPath 
)
static

Definition at line 2260 of file shellpath.c.

2262{
2263 HRESULT hr;
2264
2265 TRACE("0x%08x,0x%02x,%p\n", dwFlags, folder, pszPath);
2266
2268 return E_INVALIDARG;
2270 return E_INVALIDARG;
2271 if (!pszPath)
2272 return E_INVALIDARG;
2273
2275#ifndef __REACTOS__
2276 hr = _SHGetDefaultValue(folder, pszPath);
2277#else
2278 hr = _SHGetDefaultValue(NULL, folder, pszPath);
2279#endif
2280 else
2281 {
2282 HKEY hKey;
2283
2284 if (RegCreateKeyW(HKEY_LOCAL_MACHINE, L"Software\\Microsoft\\Windows\\CurrentVersion", &hKey))
2285 hr = E_FAIL;
2286 else
2287 {
2288 DWORD dwType, dwPathLen = MAX_PATH * sizeof(WCHAR);
2289
2290 if (RegQueryValueExW(hKey, CSIDL_Data[folder].szValueName, NULL,
2291 &dwType, (LPBYTE)pszPath, &dwPathLen) ||
2292 (dwType != REG_SZ && dwType != REG_EXPAND_SZ))
2293 {
2294#ifndef __REACTOS__
2295 hr = _SHGetDefaultValue(folder, pszPath);
2296#else
2297 hr = _SHGetDefaultValue(NULL, folder, pszPath);
2298#endif
2299 dwType = REG_EXPAND_SZ;
2300 switch (folder)
2301 {
2304 /* these two should never be set on 32-bit setups */
2305 if (!is_win64)
2306 {
2307 BOOL is_wow64;
2309 if (!is_wow64) break;
2310 }
2311 /* fall through */
2312 default:
2313 RegSetValueExW(hKey, CSIDL_Data[folder].szValueName, 0, dwType,
2314 (LPBYTE)pszPath, (strlenW(pszPath)+1)*sizeof(WCHAR));
2315 }
2316 }
2317 else
2318 {
2319 pszPath[dwPathLen / sizeof(WCHAR)] = '\0';
2320 hr = S_OK;
2321 }
2323 }
2324 }
2325 TRACE("returning 0x%08x (output path is %s)\n", hr, debugstr_w(pszPath));
2326 return hr;
2327}
#define E_FAIL
Definition: ddrawi.h:102
LONG WINAPI RegSetValueExW(_In_ HKEY hKey, _In_ LPCWSTR lpValueName, _In_ DWORD Reserved, _In_ DWORD dwType, _In_ CONST BYTE *lpData, _In_ DWORD cbData)
Definition: reg.c:4882
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4103
LONG WINAPI RegCreateKeyW(HKEY hKey, LPCWSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:1201
#define GetCurrentProcess()
Definition: compat.h:759
#define IsWow64Process
Definition: compat.h:760
BOOL is_wow64
Definition: msi.c:52
static const BOOL is_win64
Definition: shellpath.c:59
unsigned int BOOL
Definition: ntddk_ex.h:94
FxAutoRegKey hKey
#define REG_SZ
Definition: layer.c:22
#define REG_EXPAND_SZ
Definition: nt_native.h:1494
#define strlenW(s)
Definition: unicode.h:34
#define CSIDL_PROGRAM_FILES_COMMONX86
Definition: shlobj.h:2224
#define CSIDL_PROGRAM_FILESX86
Definition: shlobj.h:2222
unsigned char * LPBYTE
Definition: typedefs.h:53

Referenced by SHGetFolderPathAndSubDirW().

◆ _SHGetDefaultValue()

static HRESULT _SHGetDefaultValue ( BYTE  folder,
LPWSTR  pszPath 
)
static

Definition at line 2144 of file shellpath.c.

2148{
2149 HRESULT hr;
2150 WCHAR resourcePath[MAX_PATH];
2151#ifdef __REACTOS__
2152 NT_PRODUCT_TYPE ProductType;
2153#endif
2154
2155 TRACE("0x%02x,%p\n", folder, pszPath);
2156
2158 return E_INVALIDARG;
2159
2160 if (!pszPath)
2161 return E_INVALIDARG;
2162
2163#ifdef __REACTOS__
2164 if (hToken != NULL && hToken != (HANDLE)-1)
2165 {
2166 FIXME("unsupported for user other than current or default\n");
2167 }
2168#endif
2169
2170 if (!is_win64)
2171 {
2172 BOOL is_wow64;
2173
2174 switch (folder)
2175 {
2180 break;
2185 break;
2186 }
2187 }
2188
2189 switch (CSIDL_Data[folder].type)
2190 {
2191 case CSIDL_Type_User:
2192 strcpyW(pszPath, L"%USERPROFILE%");
2193 break;
2194#ifdef __REACTOS__
2195 case CSIDL_Type_InMyDocuments:
2196 strcpyW(pszPath, L"%USERPROFILE%");
2197 if (DoGetProductType(&ProductType) && ProductType == NtProductWinNt)
2198 {
2199 if (IS_INTRESOURCE(CSIDL_Data[CSIDL_MYDOCUMENTS].szDefaultPath))
2200 {
2201 WCHAR szItem[MAX_PATH];
2203 LOWORD(CSIDL_Data[CSIDL_MYDOCUMENTS].szDefaultPath),
2204 szItem, ARRAY_SIZE(szItem));
2205 PathAppendW(pszPath, szItem);
2206 }
2207 else
2208 {
2209 PathAppendW(pszPath, CSIDL_Data[CSIDL_MYDOCUMENTS].szDefaultPath);
2210 }
2211 }
2212 break;
2213#endif
2215#ifndef __REACTOS__
2216 strcpyW(pszPath, L"%PUBLIC%");
2217#else
2218 strcpyW(pszPath, L"%ALLUSERSPROFILE%");
2219#endif
2220 break;
2221 case CSIDL_Type_CurrVer:
2222 strcpyW(pszPath, L"%SystemDrive%");
2223 break;
2224 default:
2225 ; /* no corresponding env. var, do nothing */
2226 }
2227
2228 hr = S_OK;
2229 if (CSIDL_Data[folder].szDefaultPath)
2230 {
2231 if (IS_INTRESOURCE(CSIDL_Data[folder].szDefaultPath))
2232 {
2234 LOWORD(CSIDL_Data[folder].szDefaultPath), resourcePath, MAX_PATH))
2235 {
2236 PathAppendW(pszPath, resourcePath);
2237 }
2238 else
2239 {
2240 ERR("(%d,%s), LoadString failed, missing translation?\n", folder,
2241 debugstr_w(pszPath));
2242 hr = E_FAIL;
2243 }
2244 }
2245 else
2246 {
2247 PathAppendW(pszPath, CSIDL_Data[folder].szDefaultPath);
2248 }
2249 }
2250 TRACE("returning 0x%08x\n", hr);
2251 return hr;
2252}
#define shell32_hInstance
#define FIXME(fmt,...)
Definition: precomp.h:53
#define ERR(fmt,...)
Definition: precomp.h:57
static BOOL DoGetProductType(PNT_PRODUCT_TYPE ProductType)
Definition: shellpath.c:71
#define LOWORD(l)
Definition: pedump.c:82
#define CSIDL_PROGRAM_FILES
Definition: shlobj.h:2218
#define CSIDL_MYDOCUMENTS
Definition: shlobj.h:2193
#define CSIDL_PROGRAM_FILES_COMMON
Definition: shlobj.h:2223
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
#define IS_INTRESOURCE(i)
Definition: winuser.h:580

Referenced by _SHGetAllUsersProfilePath(), _SHGetCurrentVersionPath(), and _SHGetUserProfilePath().

◆ _SHGetProfilesValue()

static HRESULT _SHGetProfilesValue ( HKEY  profilesKey,
LPCWSTR  szValueName,
LPWSTR  szValue,
LPCWSTR  szDefault 
)
static

Definition at line 2514 of file shellpath.c.

2516{
2517 HRESULT hr;
2518 DWORD type, dwPathLen = MAX_PATH * sizeof(WCHAR);
2519 LONG lRet;
2520
2521 TRACE("%p,%s,%p,%s\n", profilesKey, debugstr_w(szValueName), szValue,
2522 debugstr_w(szDefault));
2523 lRet = RegQueryValueExW(profilesKey, szValueName, NULL, &type,
2524 (LPBYTE)szValue, &dwPathLen);
2525 if (!lRet && (type == REG_SZ || type == REG_EXPAND_SZ) && dwPathLen
2526 && *szValue)
2527 {
2528 dwPathLen /= sizeof(WCHAR);
2529 szValue[dwPathLen] = '\0';
2530 hr = S_OK;
2531 }
2532 else
2533 {
2534 /* Missing or invalid value, set a default */
2535 lstrcpynW(szValue, szDefault, MAX_PATH);
2536 TRACE("Setting missing value %s to %s\n", debugstr_w(szValueName),
2537 debugstr_w(szValue));
2538 lRet = RegSetValueExW(profilesKey, szValueName, 0, REG_EXPAND_SZ,
2539 (LPBYTE)szValue,
2540 (strlenW(szValue) + 1) * sizeof(WCHAR));
2541 if (lRet)
2542 hr = HRESULT_FROM_WIN32(lRet);
2543 else
2544 hr = S_OK;
2545 }
2546 TRACE("returning 0x%08x (output value is %s)\n", hr, debugstr_w(szValue));
2547 return hr;
2548}
#define lstrcpynW
Definition: compat.h:738
long LONG
Definition: pedump.c:60

Referenced by _SHExpandEnvironmentStrings().

◆ _SHGetUserProfileDirectoryW()

BOOL _SHGetUserProfileDirectoryW ( HANDLE  hToken,
LPWSTR  szPath,
LPDWORD  lpcchPath 
)

Definition at line 2108 of file shellpath.c.

2109{
2110 BOOL result;
2111 if (!hToken)
2112 {
2114 result = GetUserProfileDirectoryW(hToken, szPath, lpcchPath);
2115 CloseHandle(hToken);
2116 }
2117 else if ((INT) hToken == -1)
2118 {
2120 }
2121 else
2122 {
2123 result = GetUserProfileDirectoryW(hToken, szPath, lpcchPath);
2124 }
2125 TRACE("_SHGetUserProfileDirectoryW returning %S\n", szPath);
2126 return result;
2127}
BOOL WINAPI OpenProcessToken(HANDLE ProcessHandle, DWORD DesiredAccess, PHANDLE TokenHandle)
Definition: security.c:294
#define CloseHandle
Definition: compat.h:739
BOOL WINAPI GetDefaultUserProfileDirectoryW(_Out_opt_ LPWSTR lpProfileDir, _Inout_ LPDWORD lpcchSize)
Definition: profile.c:1443
BOOL WINAPI GetUserProfileDirectoryW(_In_ HANDLE hToken, _Out_opt_ LPWSTR lpProfileDir, _Inout_ LPDWORD lpcchSize)
Definition: profile.c:1792
GLuint64EXT * result
Definition: glext.h:11304
LPCWSTR szPath
Definition: env.c:37
int32_t INT
Definition: typedefs.h:58
#define TOKEN_QUERY
Definition: setypes.h:928

Referenced by _SHExpandEnvironmentStrings().

◆ _SHGetUserProfilePath()

static HRESULT _SHGetUserProfilePath ( HANDLE  hToken,
DWORD  dwFlags,
BYTE  folder,
LPWSTR  pszPath 
)
static

Definition at line 2370 of file shellpath.c.

2372{
2373 const WCHAR *szValueName;
2374 WCHAR buffer[40];
2375 HRESULT hr;
2376
2377 TRACE("%p,0x%08x,0x%02x,%p\n", hToken, dwFlags, folder, pszPath);
2378
2380 return E_INVALIDARG;
2381#ifdef __REACTOS__
2383 CSIDL_Data[folder].type != CSIDL_Type_InMyDocuments)
2384#else
2386#endif
2387 {
2388 return E_INVALIDARG;
2389 }
2390 if (!pszPath)
2391 return E_INVALIDARG;
2392
2394 {
2395#ifndef __REACTOS__
2396 hr = _SHGetDefaultValue(folder, pszPath);
2397#else
2398 hr = _SHGetDefaultValue(hToken, folder, pszPath);
2399#endif
2400 }
2401 else
2402 {
2403 static const WCHAR DefaultW[] = L".Default";
2404 LPCWSTR userPrefix = NULL;
2405 HKEY hRootKey;
2406
2407 if (hToken == (HANDLE)-1)
2408 {
2409 hRootKey = HKEY_USERS;
2410 userPrefix = DefaultW;
2411 }
2412 else if (hToken == NULL)
2413 hRootKey = HKEY_CURRENT_USER;
2414 else
2415 {
2416 hRootKey = HKEY_USERS;
2417 userPrefix = _GetUserSidStringFromToken(hToken);
2418 if (userPrefix == NULL)
2419 {
2420 hr = E_FAIL;
2421 goto error;
2422 }
2423 }
2424
2425 /* For CSIDL_Type_User we also use the GUID if no szValueName is provided */
2426 szValueName = CSIDL_Data[folder].szValueName;
2427 if (!szValueName)
2428 {
2430 szValueName = &buffer[0];
2431 }
2432
2433#ifndef __REACTOS__
2434 hr = _SHGetUserShellFolderPath(hRootKey, userPrefix, szValueName, pszPath);
2435 if (FAILED(hr) && hRootKey != HKEY_LOCAL_MACHINE)
2436 hr = _SHGetUserShellFolderPath(HKEY_LOCAL_MACHINE, NULL, szValueName, pszPath);
2437 if (FAILED(hr))
2438 hr = _SHGetDefaultValue(folder, pszPath);
2439#else
2440 hr = _SHGetUserShellFolderPath(hRootKey, hToken, userPrefix, szValueName, pszPath);
2441 if (FAILED(hr) && hRootKey != HKEY_LOCAL_MACHINE)
2442 hr = _SHGetUserShellFolderPath(HKEY_LOCAL_MACHINE, hToken, NULL, szValueName, pszPath);
2443 if (FAILED(hr))
2444 hr = _SHGetDefaultValue(hToken, folder, pszPath);
2445#endif
2446 if (userPrefix != NULL && userPrefix != DefaultW)
2447 LocalFree((HLOCAL) userPrefix);
2448 }
2449error:
2450 TRACE("returning 0x%08x (output path is %s)\n", hr, debugstr_w(pszPath));
2451 return hr;
2452}
INT WINAPI StringFromGUID2(REFGUID id, LPOLESTR str, INT cmax)
Definition: compobj.c:2434
static LPWSTR _GetUserSidStringFromToken(HANDLE Token)
Definition: shellpath.c:2329
GLuint buffer
Definition: glext.h:5915
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1594
#define error(str)
Definition: mkdosfs.c:1605
LPCWSTR szValueName
Definition: shellpath.c:1220
#define HKEY_CURRENT_USER
Definition: winreg.h:11
#define HKEY_USERS
Definition: winreg.h:13
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185

Referenced by _SHRegisterFolders(), and SHGetFolderPathAndSubDirW().

◆ _SHGetUserShellFolderPath()

static HRESULT _SHGetUserShellFolderPath ( HKEY  rootKey,
LPCWSTR  userPrefix,
LPCWSTR  value,
LPWSTR  path 
)
static

Definition at line 2025 of file shellpath.c.

2030{
2031 HRESULT hr;
2032 WCHAR shellFolderPath[MAX_PATH], userShellFolderPath[MAX_PATH];
2033 LPCWSTR pShellFolderPath, pUserShellFolderPath;
2034 HKEY userShellFolderKey, shellFolderKey;
2035 DWORD dwType, dwPathLen;
2036
2037 TRACE("%p,%s,%s,%p\n",rootKey, debugstr_w(userPrefix), debugstr_w(value),
2038 path);
2039
2040 if (userPrefix)
2041 {
2042 strcpyW(shellFolderPath, userPrefix);
2043 PathAddBackslashW(shellFolderPath);
2044 strcatW(shellFolderPath, szSHFolders);
2045 pShellFolderPath = shellFolderPath;
2046 strcpyW(userShellFolderPath, userPrefix);
2047 PathAddBackslashW(userShellFolderPath);
2048 strcatW(userShellFolderPath, szSHUserFolders);
2049 pUserShellFolderPath = userShellFolderPath;
2050 }
2051 else
2052 {
2053 pUserShellFolderPath = szSHUserFolders;
2054 pShellFolderPath = szSHFolders;
2055 }
2056
2057 if (RegCreateKeyW(rootKey, pShellFolderPath, &shellFolderKey))
2058 {
2059 TRACE("Failed to create %s\n", debugstr_w(pShellFolderPath));
2060 return E_FAIL;
2061 }
2062 if (RegCreateKeyW(rootKey, pUserShellFolderPath, &userShellFolderKey))
2063 {
2064 TRACE("Failed to create %s\n",
2065 debugstr_w(pUserShellFolderPath));
2066 RegCloseKey(shellFolderKey);
2067 return E_FAIL;
2068 }
2069
2070 dwPathLen = MAX_PATH * sizeof(WCHAR);
2071 if (!RegQueryValueExW(userShellFolderKey, value, NULL, &dwType,
2072 (LPBYTE)path, &dwPathLen) && (dwType == REG_EXPAND_SZ || dwType == REG_SZ))
2073 {
2074 LONG ret;
2075
2076 path[dwPathLen / sizeof(WCHAR)] = '\0';
2077 if (dwType == REG_EXPAND_SZ && path[0] == '%')
2078 {
2079 WCHAR szTemp[MAX_PATH];
2080
2081#ifndef __REACTOS__
2083#else
2084 hr = _SHExpandEnvironmentStrings(hToken, path, szTemp, _countof(szTemp));
2085 if (FAILED(hr))
2086 goto end;
2087#endif
2088 lstrcpynW(path, szTemp, MAX_PATH);
2089 }
2090 ret = RegSetValueExW(shellFolderKey, value, 0, REG_SZ, (LPBYTE)path,
2091 (strlenW(path) + 1) * sizeof(WCHAR));
2092 if (ret != ERROR_SUCCESS)
2094 else
2095 hr = S_OK;
2096 }
2097 else
2098 hr = E_FAIL;
2099#ifdef __REACTOS__
2100end:
2101#endif
2102 RegCloseKey(shellFolderKey);
2103 RegCloseKey(userShellFolderKey);
2104 TRACE("returning 0x%08x\n", hr);
2105 return hr;
2106}
#define ERROR_SUCCESS
Definition: deptool.c:10
static const WCHAR szSHUserFolders[]
Definition: shellpath.c:1186
static HRESULT _SHExpandEnvironmentStrings(LPCWSTR szSrc, LPWSTR szDest)
Definition: shellpath.c:2564
static const WCHAR szSHFolders[]
Definition: shellpath.c:1185
#define PathAddBackslashW
Definition: pathcch.h:301
#define strcatW(d, s)
Definition: unicode.h:36
#define _countof(array)
Definition: sndvol32.h:70
Definition: pdh_main.c:96

Referenced by _SHGetAllUsersProfilePath(), and _SHGetUserProfilePath().

◆ _SHOpenProfilesKey()

static HRESULT _SHOpenProfilesKey ( PHKEY  pKey)
static

Definition at line 2499 of file shellpath.c.

2500{
2501 LONG lRet;
2502 DWORD disp;
2503
2504 lRet = RegCreateKeyExW(HKEY_LOCAL_MACHINE, L"Software\\Microsoft\\Windows NT\\CurrentVersion\\ProfileList", 0, NULL, 0,
2505 KEY_ALL_ACCESS, NULL, pKey, &disp);
2506 return HRESULT_FROM_WIN32(lRet);
2507}
LONG WINAPI RegCreateKeyExW(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey, _In_ DWORD Reserved, _In_opt_ LPWSTR lpClass, _In_ DWORD dwOptions, _In_ REGSAM samDesired, _In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes, _Out_ PHKEY phkResult, _Out_opt_ LPDWORD lpdwDisposition)
Definition: reg.c:1096
FxRegKey * pKey
#define KEY_ALL_ACCESS
Definition: nt_native.h:1041

Referenced by _SHExpandEnvironmentStrings().

◆ _SHRegisterCommonShellFolders()

static HRESULT _SHRegisterCommonShellFolders ( void  )
static

Definition at line 3163 of file shellpath.c.

3164{
3165 static const UINT folders[] = {
3178 };
3179 HRESULT hr;
3180
3181 TRACE("\n");
3183 szSHFolders, folders, ARRAY_SIZE(folders));
3184 TRACE("returning 0x%08x\n", hr);
3185 return hr;
3186}
static HRESULT _SHRegisterFolders(HKEY hRootKey, HANDLE hToken, LPCWSTR szUserShellFolderPath, LPCWSTR szShellFolderPath, const UINT folders[], UINT foldersLen)
Definition: shellpath.c:2993
unsigned int UINT
Definition: ndis.h:50
#define CSIDL_COMMON_TEMPLATES
Definition: shlobj.h:2225
#define CSIDL_COMMON_DESKTOPDIRECTORY
Definition: shlobj.h:2205
#define CSIDL_COMMON_STARTMENU
Definition: shlobj.h:2202
#define CSIDL_COMMON_APPDATA
Definition: shlobj.h:2215
#define CSIDL_COMMON_PROGRAMS
Definition: shlobj.h:2203
#define CSIDL_COMMON_FAVORITES
Definition: shlobj.h:2211
#define CSIDL_COMMON_MUSIC
Definition: shlobj.h:2230
#define CSIDL_COMMON_VIDEO
Definition: shlobj.h:2232
#define CSIDL_COMMON_PICTURES
Definition: shlobj.h:2231
#define CSIDL_COMMON_STARTUP
Definition: shlobj.h:2204
#define CSIDL_COMMON_DOCUMENTS
Definition: shlobj.h:2226
#define CSIDL_COMMON_ADMINTOOLS
Definition: shlobj.h:2227

Referenced by SHELL_RegisterShellFolders().

◆ _SHRegisterFolders()

static HRESULT _SHRegisterFolders ( HKEY  hRootKey,
HANDLE  hToken,
LPCWSTR  szUserShellFolderPath,
LPCWSTR  szShellFolderPath,
const UINT  folders[],
UINT  foldersLen 
)
static

Definition at line 2993 of file shellpath.c.

2996{
2997 const WCHAR *szValueName;
2998 WCHAR buffer[40];
2999 UINT i;
3001 HRESULT hr = S_OK;
3002 HKEY hUserKey = NULL, hKey = NULL;
3003 DWORD dwType, dwPathLen;
3004 LONG ret;
3005
3006 TRACE("%p,%p,%s,%p,%u\n", hRootKey, hToken,
3007 debugstr_w(szUserShellFolderPath), folders, foldersLen);
3008
3009 ret = RegCreateKeyW(hRootKey, szUserShellFolderPath, &hUserKey);
3010 if (ret)
3012 else
3013 {
3014 ret = RegCreateKeyW(hRootKey, szShellFolderPath, &hKey);
3015 if (ret)
3017 }
3018 for (i = 0; SUCCEEDED(hr) && i < foldersLen; i++)
3019 {
3020 dwPathLen = MAX_PATH * sizeof(WCHAR);
3021
3022 /* For CSIDL_Type_User we also use the GUID if no szValueName is provided */
3023 szValueName = CSIDL_Data[folders[i]].szValueName;
3024#ifdef __REACTOS__
3025 if (!szValueName &&
3026 (CSIDL_Data[folders[i]].type == CSIDL_Type_User ||
3027 CSIDL_Data[folders[i]].type == CSIDL_Type_InMyDocuments))
3028#else
3029 if (!szValueName && CSIDL_Data[folders[i]].type == CSIDL_Type_User)
3030#endif
3031 {
3032 StringFromGUID2( CSIDL_Data[folders[i]].id, buffer, 39 );
3033 szValueName = &buffer[0];
3034 }
3035
3036 if (!RegQueryValueExW(hUserKey, szValueName, NULL,
3037 &dwType, (LPBYTE)path, &dwPathLen) &&
3038 (dwType == REG_SZ || dwType == REG_EXPAND_SZ))
3039 {
3041 hToken, SHGFP_TYPE_CURRENT, path);
3042 }
3043 else
3044 {
3045 *path = '\0';
3046#ifdef __REACTOS__
3047 if (CSIDL_Data[folders[i]].type == CSIDL_Type_User ||
3048 CSIDL_Data[folders[i]].type == CSIDL_Type_InMyDocuments)
3049#else
3050 if (CSIDL_Data[folders[i]].type == CSIDL_Type_User)
3051#endif
3052 _SHGetUserProfilePath(hToken, SHGFP_TYPE_CURRENT, folders[i],
3053 path);
3054 else if (CSIDL_Data[folders[i]].type == CSIDL_Type_AllUsers)
3056 else if (CSIDL_Data[folders[i]].type == CSIDL_Type_WindowsPath)
3057 {
3059 if (CSIDL_Data[folders[i]].szDefaultPath &&
3060 !IS_INTRESOURCE(CSIDL_Data[folders[i]].szDefaultPath))
3061 {
3063 strcatW(path, CSIDL_Data[folders[i]].szDefaultPath);
3064 }
3065 }
3066 else
3067 hr = E_FAIL;
3068 if (*path)
3069 {
3070 ret = RegSetValueExW(hUserKey, szValueName, 0, REG_EXPAND_SZ,
3071 (LPBYTE)path, (strlenW(path) + 1) * sizeof(WCHAR));
3072 if (ret)
3074 else
3075 {
3077 hToken, SHGFP_TYPE_CURRENT, path);
3078 ret = RegSetValueExW(hKey, szValueName, 0, REG_SZ,
3079 (LPBYTE)path, (strlenW(path) + 1) * sizeof(WCHAR));
3080 if (ret)
3082 }
3083 }
3084 }
3085 }
3086 if (hUserKey)
3087 RegCloseKey(hUserKey);
3088 if (hKey)
3090
3091 TRACE("returning 0x%08x\n", hr);
3092 return hr;
3093}
UINT WINAPI GetWindowsDirectoryW(OUT LPWSTR lpBuffer, IN UINT uSize)
Definition: path.c:2352
HRESULT WINAPI SHGetFolderPathW(HWND hwndOwner, int nFolder, HANDLE hToken, DWORD dwFlags, LPWSTR pszPath)
Definition: shellpath.c:2716
static HRESULT _SHGetAllUsersProfilePath(DWORD dwFlags, BYTE folder, LPWSTR pszPath)
Definition: shellpath.c:2459
static HRESULT _SHGetUserProfilePath(HANDLE hToken, DWORD dwFlags, BYTE folder, LPWSTR pszPath)
Definition: shellpath.c:2370
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define CSIDL_FLAG_CREATE
@ SHGFP_TYPE_CURRENT
Definition: shlobj.h:2157

Referenced by _SHRegisterCommonShellFolders(), and _SHRegisterUserShellFolders().

◆ _SHRegisterUserShellFolders()

static HRESULT _SHRegisterUserShellFolders ( BOOL  bDefault)
static

Definition at line 3095 of file shellpath.c.

3096{
3097 static const UINT folders[] = {
3119/* Cannot use #if _WIN32_WINNT >= 0x0600 because _WIN32_WINNT == 0x0600 here. */
3120#ifndef __REACTOS__
3127#endif
3128 };
3129 WCHAR userShellFolderPath[MAX_PATH], shellFolderPath[MAX_PATH];
3130 LPCWSTR pUserShellFolderPath, pShellFolderPath;
3131 HRESULT hr = S_OK;
3132 HKEY hRootKey;
3133 HANDLE hToken;
3134
3135 TRACE("%s\n", bDefault ? "TRUE" : "FALSE");
3136 if (bDefault)
3137 {
3138 hToken = (HANDLE)-1;
3139 hRootKey = HKEY_USERS;
3140 strcpyW(userShellFolderPath, L".Default");
3141 PathAddBackslashW(userShellFolderPath);
3142 strcatW(userShellFolderPath, szSHUserFolders);
3143 pUserShellFolderPath = userShellFolderPath;
3144 strcpyW(shellFolderPath, L".Default");
3145 PathAddBackslashW(shellFolderPath);
3146 strcatW(shellFolderPath, szSHFolders);
3147 pShellFolderPath = shellFolderPath;
3148 }
3149 else
3150 {
3151 hToken = NULL;
3152 hRootKey = HKEY_CURRENT_USER;
3153 pUserShellFolderPath = szSHUserFolders;
3154 pShellFolderPath = szSHFolders;
3155 }
3156
3157 hr = _SHRegisterFolders(hRootKey, hToken, pUserShellFolderPath,
3158 pShellFolderPath, folders, ARRAY_SIZE(folders));
3159 TRACE("returning 0x%08x\n", hr);
3160 return hr;
3161}
#define CSIDL_LINKS
Definition: shellpath.c:1210
#define CSIDL_APPDATA_LOCALLOW
Definition: shellpath.c:1211
#define CSIDL_DOWNLOADS
Definition: shellpath.c:1209
#define CSIDL_SEARCHES
Definition: shellpath.c:1213
#define CSIDL_SAVED_GAMES
Definition: shellpath.c:1212
#define CSIDL_CONTACTS
Definition: shellpath.c:1208
#define CSIDL_TEMPLATES
Definition: shlobj.h:2201
#define CSIDL_INTERNET_CACHE
Definition: shlobj.h:2212
#define CSIDL_DESKTOPDIRECTORY
Definition: shlobj.h:2196
#define CSIDL_SENDTO
Definition: shlobj.h:2190
#define CSIDL_RECENT
Definition: shlobj.h:2189
#define CSIDL_ADMINTOOLS
Definition: shlobj.h:2228
#define CSIDL_FONTS
Definition: shlobj.h:2200
#define CSIDL_PERSONAL
Definition: shlobj.h:2186
#define CSIDL_FAVORITES
Definition: shlobj.h:2187
#define CSIDL_MYPICTURES
Definition: shlobj.h:2219
#define CSIDL_COOKIES
Definition: shlobj.h:2213
#define CSIDL_HISTORY
Definition: shlobj.h:2214
#define CSIDL_LOCAL_APPDATA
Definition: shlobj.h:2208
#define CSIDL_STARTMENU
Definition: shlobj.h:2192
#define CSIDL_PROGRAMS
Definition: shlobj.h:2183
#define CSIDL_APPDATA
Definition: shlobj.h:2206
#define CSIDL_PRINTHOOD
Definition: shlobj.h:2207
#define CSIDL_STARTUP
Definition: shlobj.h:2188
#define CSIDL_MYMUSIC
Definition: shlobj.h:2194
#define CSIDL_NETHOOD
Definition: shlobj.h:2199
#define CSIDL_MYVIDEO
Definition: shlobj.h:2195
PVOID HANDLE
Definition: typedefs.h:73

Referenced by SHELL_RegisterShellFolders().

◆ DoGetProductType()

static BOOL DoGetProductType ( PNT_PRODUCT_TYPE  ProductType)
static

Definition at line 71 of file shellpath.c.

72{
73 HKEY hKey;
74 LONG error;
75 WCHAR szValue[9];
76 DWORD cbValue;
77 static DWORD s_dwProductType = 0;
78
79 if (s_dwProductType != 0)
80 {
81 *ProductType = s_dwProductType;
82 return TRUE;
83 }
84
85 *ProductType = NtProductServer;
86
87 error = RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"SYSTEM\\CurrentControlSet\\Control\\ProductOptions", 0, KEY_READ, &hKey);
88 if (error)
89 return FALSE;
90
91 cbValue = sizeof(szValue);
92 error = RegGetValueW(hKey, NULL, L"ProductType", RRF_RT_REG_SZ, NULL, (PVOID)szValue, &cbValue);
93 if (!error)
94 {
95 if (lstrcmpW(szValue, L"WinNT") == 0)
96 *ProductType = NtProductWinNt;
97 else if (lstrcmpW(szValue, L"LanmanNT") == 0)
98 *ProductType = NtProductLanManNt;
99 }
100
101 s_dwProductType = *ProductType;
102
104 return TRUE;
105}
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3333
LSTATUS WINAPI RegGetValueW(HKEY hKey, LPCWSTR pszSubKey, LPCWSTR pszValue, DWORD dwFlags, LPDWORD pdwType, PVOID pvData, LPDWORD pcbData)
Definition: reg.c:1931
int WINAPI lstrcmpW(LPCWSTR str1, LPCWSTR str2)
Definition: locale.c:4243
#define RRF_RT_REG_SZ
Definition: driver.c:575
#define KEY_READ
Definition: nt_native.h:1023

Referenced by _SHGetDefaultValue().

◆ IsLFNDriveA()

BOOL WINAPI IsLFNDriveA ( LPCSTR  lpszPath)

Definition at line 577 of file shellpath.c.

578{
579 WCHAR szBuffW[MAX_PATH], *pszW = NULL;
580 if (lpszPath)
581 {
582 SHAnsiToUnicode(lpszPath, szBuffW, _countof(szBuffW));
583 pszW = szBuffW;
584 }
585 return IsLFNDriveW(pszW);
586}
BOOL WINAPI IsLFNDriveW(LPCWSTR lpszPath)
Definition: shellpath.c:591
DWORD WINAPI SHAnsiToUnicode(LPCSTR lpSrcStr, LPWSTR lpDstStr, int iLen)
Definition: string.c:2673

Referenced by IsLFNDriveAW().

◆ IsLFNDriveAW()

BOOL WINAPI IsLFNDriveAW ( LPCVOID  lpszPath)

Definition at line 639 of file shellpath.c.

640{
641 if (SHELL_OsIsUnicode())
642 return IsLFNDriveW(lpszPath);
643 return IsLFNDriveA(lpszPath);
644}
BOOL WINAPI IsLFNDriveA(LPCSTR lpszPath)
Definition: shellpath.c:577
static __inline BOOL SHELL_OsIsUnicode(void)
Definition: shell32_main.h:155

◆ IsLFNDriveW()

BOOL WINAPI IsLFNDriveW ( LPCWSTR  lpszPath)

Definition at line 591 of file shellpath.c.

592{
593 DWORD cchMaxFileName, iDrive;
594 WCHAR szRoot[MAX_PATH];
595
596 if (lpszPath == NULL || lpszPath[0] == UNICODE_NULL)
597 {
598 szRoot[0] = 0;
599 GetWindowsDirectoryW(szRoot, _countof(szRoot));
600 lpszPath = szRoot;
601 }
602
603 if (PathIsUNCW(lpszPath))
604 {
605 StringCchCopyW(szRoot, _countof(szRoot), lpszPath);
606 PathStripToRootW(szRoot);
607
608 if (StrChrW(szRoot + 2, L'\\') == NULL)
609 return TRUE; /* LFN */
610
611 StringCchCatW(szRoot, _countof(szRoot), L"\\"); /* Add a backslash */
612 }
613 else
614 {
615 iDrive = ((lpszPath[0] - L'A') & 0x1F);
616 PathBuildRootW(szRoot, iDrive);
617
618 if (!IsRemovableDrive(iDrive))
619 {
620 /* FIXME: Cache correctly */
621 }
622 }
623
624#define MSDOS_8DOT3_LEN 12 /* MS-DOS 8.3 filename == length 12 */
625
626 /* GetVolumeInformation requires a root path */
627 if (!GetVolumeInformationW(szRoot, NULL, 0, NULL, &cchMaxFileName, NULL, NULL, 0))
628 {
629 /* Don't return FALSE when GetVolumeInformationW fails. */
630 return TRUE;
631 }
632
633 return cchMaxFileName > MSDOS_8DOT3_LEN;
634}
LPWSTR WINAPI StrChrW(LPCWSTR lpszStr, WCHAR ch)
Definition: string.c:464
BOOL WINAPI GetVolumeInformationW(IN LPCWSTR lpRootPathName, IN LPWSTR lpVolumeNameBuffer, IN DWORD nVolumeNameSize, OUT LPDWORD lpVolumeSerialNumber OPTIONAL, OUT LPDWORD lpMaximumComponentLength OPTIONAL, OUT LPDWORD lpFileSystemFlags OPTIONAL, OUT LPWSTR lpFileSystemNameBuffer OPTIONAL, IN DWORD nFileSystemNameSize)
Definition: volume.c:226
BOOL APIENTRY IsRemovableDrive(DWORD iDrive)
Definition: shellpath.c:107
#define MSDOS_8DOT3_LEN
BOOL WINAPI PathStripToRootW(LPWSTR lpszPath)
Definition: path.c:733
LPWSTR WINAPI PathBuildRootW(LPWSTR lpszPath, int drive)
Definition: path.c:348
BOOL WINAPI PathIsUNCW(LPCWSTR lpszPath)
Definition: path.c:2272
#define UNICODE_NULL
STRSAFEAPI StringCchCatW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:325
STRSAFEAPI StringCchCopyW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:149

Referenced by IsLFNDriveA(), IsLFNDriveAW(), and PathQualifyExW().

◆ IsRemovableDrive()

BOOL APIENTRY IsRemovableDrive ( DWORD  iDrive)

Definition at line 107 of file shellpath.c.

108{
109 WCHAR szRoot[] = L"C:\\";
110 assert(L'A' + iDrive <= L'Z');
111 szRoot[0] = (WCHAR)(L'A' + iDrive);
112 return GetDriveTypeW(szRoot) == DRIVE_REMOVABLE;
113}
UINT WINAPI GetDriveTypeW(IN LPCWSTR lpRootPathName)
Definition: disk.c:497
#define assert(x)
Definition: debug.h:53
#define DRIVE_REMOVABLE
Definition: winbase.h:277

Referenced by IsLFNDriveW().

◆ PathAppendAW()

BOOL WINAPI PathAppendAW ( LPVOID  lpszPath1,
LPCVOID  lpszPath2 
)

Definition at line 407 of file shellpath.c.

410{
411 if (SHELL_OsIsUnicode())
412 return PathAppendW(lpszPath1, lpszPath2);
413 return PathAppendA(lpszPath1, lpszPath2);
414}
#define PathAppendA
Definition: pathcch.h:308

◆ PathCleanupSpec()

int WINAPI PathCleanupSpec ( LPCWSTR  lpszPathW,
LPWSTR  lpszFileW 
)

Definition at line 885 of file shellpath.c.

886{
887 int i = 0;
888 DWORD rc = 0;
889 int length = 0;
890
891 if (SHELL_OsIsUnicode())
892 {
893 LPWSTR p = lpszFileW;
894
895 TRACE("Cleanup %s\n",debugstr_w(lpszFileW));
896
897 if (lpszPathW)
898 length = strlenW(lpszPathW);
899
900 while (*p)
901 {
902 int gct = PathGetCharTypeW(*p);
903 if (gct == GCT_INVALID || gct == GCT_WILD || gct == GCT_SEPARATOR)
904 {
905 lpszFileW[i]='-';
906 rc |= PCS_REPLACEDCHAR;
907 }
908 else
909 lpszFileW[i]=*p;
910 i++;
911 p++;
912 if (length + i == MAX_PATH)
913 {
915 break;
916 }
917 }
918 lpszFileW[i]=0;
919 }
920 else
921 {
922 LPSTR lpszFileA = (LPSTR)lpszFileW;
923 LPCSTR lpszPathA = (LPCSTR)lpszPathW;
924 LPSTR p = lpszFileA;
925
926 TRACE("Cleanup %s\n",debugstr_a(lpszFileA));
927
928 if (lpszPathA)
929 length = strlen(lpszPathA);
930
931 while (*p)
932 {
933 int gct = PathGetCharTypeA(*p);
934 if (gct == GCT_INVALID || gct == GCT_WILD || gct == GCT_SEPARATOR)
935 {
936 lpszFileA[i]='-';
937 rc |= PCS_REPLACEDCHAR;
938 }
939 else
940 lpszFileA[i]=*p;
941 i++;
942 p++;
943 if (length + i == MAX_PATH)
944 {
946 break;
947 }
948 }
949 lpszFileA[i]=0;
950 }
951 return rc;
952}
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
UINT WINAPI PathGetCharTypeA(UCHAR ch)
Definition: path.c:3032
UINT WINAPI PathGetCharTypeW(WCHAR ch)
Definition: path.c:3042
GLuint GLsizei GLsizei * length
Definition: glext.h:6040
GLfloat GLfloat p
Definition: glext.h:8902
#define debugstr_a
Definition: kernel32.h:31
#define PCS_REPLACEDCHAR
Definition: shlobj.h:367
#define PCS_PATHTOOLONG
Definition: shlobj.h:370
#define PCS_FATAL
Definition: shlobj.h:366
#define GCT_SEPARATOR
Definition: shlwapi.h:814
#define GCT_INVALID
Definition: shlwapi.h:810
#define GCT_WILD
Definition: shlwapi.h:813
const char * LPCSTR
Definition: xmlstorage.h:183
char * LPSTR
Definition: xmlstorage.h:182

Referenced by FinishDlgProc().

◆ PathFileExistsAW()

BOOL WINAPI PathFileExistsAW ( LPCVOID  lpszPath)

Definition at line 567 of file shellpath.c.

568{
569 if (SHELL_OsIsUnicode())
570 return PathFileExistsW (lpszPath);
571 return PathFileExistsA (lpszPath);
572}
BOOL WINAPI PathFileExistsA(LPCSTR lpszPath)
Definition: path.c:1761
BOOL WINAPI PathFileExistsW(LPCWSTR lpszPath)
Definition: path.c:1783

◆ PathGetExtensionA()

static LPSTR PathGetExtensionA ( LPCSTR  lpszPath)
static

Definition at line 423 of file shellpath.c.

424{
425 TRACE("(%s)\n",lpszPath);
426
427 lpszPath = PathFindExtensionA(lpszPath);
428 return (LPSTR)(*lpszPath?(lpszPath+1):lpszPath);
429}
LPSTR WINAPI PathFindExtensionA(LPCSTR lpszPath)
Definition: path.c:422

Referenced by PathIsExeA().

◆ PathGetExtensionW()

static LPWSTR PathGetExtensionW ( LPCWSTR  lpszPath)
static

Definition at line 434 of file shellpath.c.

435{
436 TRACE("(%s)\n",debugstr_w(lpszPath));
437
438 lpszPath = PathFindExtensionW(lpszPath);
439 return (LPWSTR)(*lpszPath?(lpszPath+1):lpszPath);
440}
LPWSTR WINAPI PathFindExtensionW(LPCWSTR lpszPath)
Definition: path.c:447

Referenced by PathIsExeW(), and SHPathGetExtensionW().

◆ PathGetShortPathA()

static void PathGetShortPathA ( LPSTR  pszPath)
static

Definition at line 467 of file shellpath.c.

468{
470
471 TRACE("%s\n", pszPath);
472
473 if (GetShortPathNameA(pszPath, path, MAX_PATH))
474 {
475 lstrcpyA(pszPath, path);
476 }
477}
DWORD WINAPI GetShortPathNameA(IN LPCSTR lpszLongPath, OUT LPSTR lpszShortPath, IN DWORD cchBuffer)
Definition: path.c:1752
LPSTR WINAPI lstrcpyA(LPSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:100
char CHAR
Definition: xmlstorage.h:175

Referenced by PathGetShortPathAW().

◆ PathGetShortPathAW()

VOID WINAPI PathGetShortPathAW ( LPVOID  pszPath)

Definition at line 497 of file shellpath.c.

498{
500 PathGetShortPathW(pszPath);
501 PathGetShortPathA(pszPath);
502}
static void PathGetShortPathA(LPSTR pszPath)
Definition: shellpath.c:467
static void PathGetShortPathW(LPWSTR pszPath)
Definition: shellpath.c:482

◆ PathGetShortPathW()

static void PathGetShortPathW ( LPWSTR  pszPath)
static

Definition at line 482 of file shellpath.c.

483{
485
486 TRACE("%s\n", debugstr_w(pszPath));
487
488 if (GetShortPathNameW(pszPath, path, MAX_PATH))
489 {
490 lstrcpyW(pszPath, path);
491 }
492}
#define lstrcpyW
Definition: compat.h:749
DWORD WINAPI GetShortPathNameW(IN LPCWSTR lpszLongPath, OUT LPWSTR lpszShortPath, IN DWORD cchBuffer)
Definition: path.c:1833

Referenced by PathGetShortPathAW().

◆ PathIsAbsoluteW()

static BOOL WINAPI PathIsAbsoluteW ( _In_ LPCWSTR  path)
static

Definition at line 136 of file shellpath.c.

137{
138 return PathIsUNCW(path) || (PathGetDriveNumberW(path) != -1 && path[2] == L'\\');
139}
int WINAPI PathGetDriveNumberW(const WCHAR *path)
Definition: path.c:553

Referenced by PathResolveW().

◆ PathIsExeA()

static BOOL PathIsExeA ( LPCSTR  lpszPath)
static

Definition at line 521 of file shellpath.c.

522{
523 LPCSTR lpszExtension = PathGetExtensionA(lpszPath);
524 int i;
525 static const char * const lpszExtensions[] =
526 {"exe", "com", "pif", "cmd", "bat", "scf", "scr", NULL };
527
528 TRACE("path=%s\n",lpszPath);
529
530 for(i=0; lpszExtensions[i]; i++)
531 if (!lstrcmpiA(lpszExtension,lpszExtensions[i])) return TRUE;
532
533 return FALSE;
534}
int WINAPI lstrcmpiA(LPCSTR str1, LPCSTR str2)
Definition: locale.c:4224
static LPSTR PathGetExtensionA(LPCSTR lpszPath)
Definition: shellpath.c:423

Referenced by PathIsExeAW().

◆ PathIsExeAW()

BOOL WINAPI PathIsExeAW ( LPCVOID  path)

Definition at line 557 of file shellpath.c.

558{
559 if (SHELL_OsIsUnicode())
560 return PathIsExeW (path);
561 return PathIsExeA(path);
562}
static BOOL PathIsExeA(LPCSTR lpszPath)
Definition: shellpath.c:521
BOOL PathIsExeW(LPCWSTR lpszPath)
Definition: shellpath.c:539

◆ PathIsExeW()

BOOL PathIsExeW ( LPCWSTR  lpszPath)

Definition at line 539 of file shellpath.c.

540{
541 LPCWSTR lpszExtension = PathGetExtensionW(lpszPath);
542 int i;
543 static const WCHAR lpszExtensions[][4] =
544 {L"exe", L"com", L"pif", L"cmd", L"bat", L"scf", L"scr", L"" };
545
546 TRACE("path=%s\n",debugstr_w(lpszPath));
547
548 for(i=0; lpszExtensions[i][0]; i++)
549 if (!wcsicmp(lpszExtension,lpszExtensions[i])) return TRUE;
550
551 return FALSE;
552}
#define wcsicmp
Definition: compat.h:15
static LPWSTR PathGetExtensionW(LPCWSTR lpszPath)
Definition: shellpath.c:434

Referenced by FileTypesDlg_InsertToLV(), FindExecutableW(), CFileDefExt::InitGeneralPage(), COpenWithMenu::Initialize(), PathIsExeAW(), and SHELL_execute().

◆ PathIsRootAW()

BOOL WINAPI PathIsRootAW ( LPCVOID  lpszPath)

Definition at line 511 of file shellpath.c.

512{
513 if (SHELL_OsIsUnicode())
514 return PathIsRootW(lpszPath);
515 return PathIsRootA(lpszPath);
516}
BOOL WINAPI PathIsRootW(LPCWSTR lpszPath)
Definition: path.c:1648
BOOL WINAPI PathIsRootA(LPCSTR lpszPath)
Definition: path.c:1608

◆ PathMakeAbsoluteW()

static BOOL WINAPI PathMakeAbsoluteW ( _Inout_ LPWSTR  path)
static

Definition at line 141 of file shellpath.c.

142{
144 DWORD cch;
145
146 if (path == NULL)
147 return FALSE;
149 if (!cch || cch > _countof(path1))
150 return FALSE;
151 return (PathCombineW(path, path1, path) != NULL);
152}
#define GetCurrentDirectoryW(x, y)
Definition: compat.h:756
static DWORD DWORD void LPSTR DWORD cch
Definition: str.c:202
static const WCHAR path1[]
Definition: path.c:28
#define PathCombineW
Definition: pathcch.h:317

Referenced by PathResolveW().

◆ PathMakeUniqueNameA()

static BOOL PathMakeUniqueNameA ( LPSTR  lpszBuffer,
DWORD  dwBuffSize,
LPCSTR  lpszShortName,
LPCSTR  lpszLongName,
LPCSTR  lpszPathName 
)
static

Definition at line 652 of file shellpath.c.

658{
659 FIXME("%p %u %s %s %s stub\n",
660 lpszBuffer, dwBuffSize, debugstr_a(lpszShortName),
661 debugstr_a(lpszLongName), debugstr_a(lpszPathName));
662 return TRUE;
663}

Referenced by PathMakeUniqueNameAW().

◆ PathMakeUniqueNameAW()

BOOL WINAPI PathMakeUniqueNameAW ( LPVOID  lpszBuffer,
DWORD  dwBuffSize,
LPCVOID  lpszShortName,
LPCVOID  lpszLongName,
LPCVOID  lpszPathName 
)

Definition at line 833 of file shellpath.c.

839{
840 if (SHELL_OsIsUnicode())
841 return PathMakeUniqueNameW(lpszBuffer,dwBuffSize, lpszShortName,lpszLongName,lpszPathName);
842 return PathMakeUniqueNameA(lpszBuffer,dwBuffSize, lpszShortName,lpszLongName,lpszPathName);
843}
static BOOL PathMakeUniqueNameW(LPWSTR lpszBuffer, DWORD dwBuffSize, LPCWSTR lpszShortName, LPCWSTR lpszLongName, LPCWSTR lpszPathName)
Definition: shellpath.c:816
static BOOL PathMakeUniqueNameA(LPSTR lpszBuffer, DWORD dwBuffSize, LPCSTR lpszShortName, LPCSTR lpszLongName, LPCSTR lpszPathName)
Definition: shellpath.c:652

◆ PathMakeUniqueNameW()

static BOOL PathMakeUniqueNameW ( LPWSTR  lpszBuffer,
DWORD  dwBuffSize,
LPCWSTR  lpszShortName,
LPCWSTR  lpszLongName,
LPCWSTR  lpszPathName 
)
static

Definition at line 816 of file shellpath.c.

822{
823 FIXME("%p %u %s %s %s stub\n",
824 lpszBuffer, dwBuffSize, debugstr_w(lpszShortName),
825 debugstr_w(lpszLongName), debugstr_w(lpszPathName));
826 return TRUE;
827}

Referenced by PathMakeUniqueNameAW().

◆ PathProcessCommandA()

static LONG PathProcessCommandA ( LPCSTR  lpszPath,
LPSTR  lpszBuff,
DWORD  dwBuffSize,
DWORD  dwFlags 
)
static

Definition at line 1120 of file shellpath.c.

1125{
1126 FIXME("%s %p 0x%04x 0x%04x stub\n",
1127 lpszPath, lpszBuff, dwBuffSize, dwFlags);
1128 if(!lpszPath) return -1;
1129 if(lpszBuff) strcpy(lpszBuff, lpszPath);
1130 return strlen(lpszPath);
1131}
strcpy
Definition: string.h:131

Referenced by PathProcessCommandAW().

◆ PathProcessCommandAW()

LONG WINAPI PathProcessCommandAW ( LPCVOID  lpszPath,
LPVOID  lpszBuff,
DWORD  dwBuffSize,
DWORD  dwFlags 
)

Definition at line 1154 of file shellpath.c.

1159{
1160 if (SHELL_OsIsUnicode())
1161 return PathProcessCommandW(lpszPath, lpszBuff, dwBuffSize, dwFlags);
1162 return PathProcessCommandA(lpszPath, lpszBuff, dwBuffSize, dwFlags);
1163}
static LONG PathProcessCommandW(LPCWSTR lpszPath, LPWSTR lpszBuff, DWORD dwBuffSize, DWORD dwFlags)
Definition: shellpath.c:1137
static LONG PathProcessCommandA(LPCSTR lpszPath, LPSTR lpszBuff, DWORD dwBuffSize, DWORD dwFlags)
Definition: shellpath.c:1120

◆ PathProcessCommandW()

static LONG PathProcessCommandW ( LPCWSTR  lpszPath,
LPWSTR  lpszBuff,
DWORD  dwBuffSize,
DWORD  dwFlags 
)
static

Definition at line 1137 of file shellpath.c.

1142{
1143 FIXME("(%s, %p, 0x%04x, 0x%04x) stub\n",
1144 debugstr_w(lpszPath), lpszBuff, dwBuffSize, dwFlags);
1145 if(!lpszPath) return -1;
1146 if(lpszBuff) strcpyW(lpszBuff, lpszPath);
1147 return strlenW(lpszPath);
1148}

Referenced by PathProcessCommandAW().

◆ PathQualifyA()

VOID WINAPI PathQualifyA ( LPSTR  pszPath)

Definition at line 957 of file shellpath.c.

958{
960 TRACE("%s\n",pszPath);
964}
VOID WINAPI PathQualifyW(LPWSTR pszPath)
Definition: shellpath.c:969
INT WINAPI SHUnicodeToAnsi(LPCWSTR lpSrcStr, LPSTR lpDstStr, INT iLen)
Definition: string.c:2797

Referenced by PathQualifyAW().

◆ PathQualifyAW()

VOID WINAPI PathQualifyAW ( LPVOID  pszPath)

Definition at line 978 of file shellpath.c.

979{
980 if (SHELL_OsIsUnicode())
981 PathQualifyW(pszPath);
982 else
983 PathQualifyA(pszPath);
984}
VOID WINAPI PathQualifyA(LPSTR pszPath)
Definition: shellpath.c:957

◆ PathQualifyExW()

static VOID WINAPI PathQualifyExW ( _Inout_ LPWSTR  pszPath,
_Inout_opt_ LPCWSTR  pszDir,
_In_ DWORD  dwFlags 
)
static

Definition at line 158 of file shellpath.c.

159{
160 INT iDrive, cchPathLeft;
161 WCHAR szTemp[MAX_PATH], szRoot[MAX_PATH];
162 PWCHAR pchTemp = szTemp, pchPath;
163 BOOL bLFN;
164
165 TRACE("(%s,%s,0x%08x)\n", debugstr_w(pszPath), debugstr_w(pszDir), dwFlags);
166
167 /* Save pszPath path into szTemp for rebuilding the path later */
168 if (FAILED(StringCchCopyW(szTemp, _countof(szTemp), pszPath)))
169 return;
170
171 /* Replace every '/' by '\' */
172 FixSlashesAndColonW(szTemp);
173
174 cchPathLeft = MAX_PATH;
175
176 /* Build the root-like path on pszPath, and set pchTemp */
177 if (!PathIsUNCW(szTemp))
178 {
179 /*
180 * Non-UNC path.
181 * Determine and normalize the root drive.
182 */
183 iDrive = PathGetDriveNumberW(szTemp);
184 if (iDrive == -1)
185 {
186 /*
187 * No drive was specified in the path. Try to find one from the
188 * optional directory (if this fails, fall back to the one of the
189 * Windows directory).
190 */
191 if (!pszDir || FAILED(StringCchCopyW(szRoot, _countof(szRoot), pszDir)))
192 {
193 /* pszDir was invalid or NULL. Fall back to the
194 * Windows directory and find its root. */
195 szRoot[0] = UNICODE_NULL;
196 GetWindowsDirectoryW(szRoot, _countof(szRoot));
197 iDrive = PathGetDriveNumberW(szRoot);
198 if (iDrive != -1)
199 PathBuildRootW(szRoot, iDrive);
200 }
201
202 if (szTemp[0] == L'\\')
203 {
204 PathStripToRootW(szRoot);
205 }
206 }
207 else
208 {
209 /*
210 * A drive is specified in the path, that can be either of the
211 * form 'C:\xxx' or of the form 'C:xxx' (relative path). Isolate
212 * the root part 'C:' and the rest of the path 'xxx' in pchTemp.
213 */
214 PathBuildRootW(szRoot, iDrive);
215 pchTemp += 2;
216 if (*pchTemp == L'\\')
217 ++pchTemp;
218 }
219
220 bLFN = IsLFNDriveW(szRoot);
221 if (!bLFN)
222 {
223 PWCHAR pch;
224 for (pch = pchTemp; *pch != UNICODE_NULL; ++pch)
225 {
226#define VALID_SHORT_PATH_CHAR_CLASSES ( \
227 PATH_CHAR_CLASS_DOT | \
228 PATH_CHAR_CLASS_BACKSLASH | \
229 PATH_CHAR_CLASS_COLON | \
230 PATH_CHAR_CLASS_OTHER_VALID \
231)
233 {
234 *pch = L'_';
235 }
236 }
237 }
238
239 StringCchCopyW(pszPath, MAX_PATH, szRoot);
240 cchPathLeft -= lstrlenW(pszPath) + 1;
241 }
242 else /* UNC path: Begins with double backslash */
243 {
244 bLFN = IsLFNDriveW(pchTemp);
245 if (bLFN)
246 {
247 pszPath[2] = UNICODE_NULL; /* Cut off */
248 cchPathLeft -= (2 + 1);
249 pchTemp += 2;
250 }
251 else
252 {
253 PWCHAR pchSlash = StrChrW(pszPath + 2, L'\\');
254 if (pchSlash)
255 pchSlash = StrChrW(pchSlash + 1, L'\\');
256
257 if (pchSlash)
258 {
259 *(pchSlash + 1) = UNICODE_NULL; /* Cut off */
260 pchTemp += pchSlash - pszPath;
261 cchPathLeft -= (INT)(SIZE_T)(pchSlash - pszPath) + 1;
262 }
263 else
264 {
265 bLFN = TRUE;
266 pszPath[2] = UNICODE_NULL; /* Cut off */
267 cchPathLeft -= 2;
268 pchTemp += 2;
269 }
270 }
271 }
272 /* Now pszPath is a root-like path or an empty string. */
273
274 /* Start appending the path components of szTemp to pszPath. */
275 while (*pchTemp && cchPathLeft > 0)
276 {
277 /* Collapse any .\ and ..\ parts in the path */
278 if (*pchTemp == L'.')
279 {
280 BOOL bDots = FALSE; /* '.' or '..' ? */
281
282 if (pchTemp[1] == UNICODE_NULL || pchTemp[1] == L'\\')
283 {
284 /* Component '.' */
285 bDots = TRUE;
286 }
287 else if (pchTemp[1] == L'.' && (pchTemp[2] == UNICODE_NULL || pchTemp[2] == L'\\'))
288 {
289 /* Component '..' */
290 PathRemoveFileSpecW(pszPath); /* Remove the last component from pszPath */
291 bDots = TRUE;
292 }
293
294 /* If a '.' or '..' was encountered, skip to the next component */
295 if (bDots)
296 {
297 while (*pchTemp && *pchTemp != L'\\')
298 {
299 ++pchTemp;
300 }
301
302 while (*pchTemp == L'\\')
303 {
304 ++pchTemp;
305 }
306
307 continue;
308 }
309 }
310
311 /* Otherwise, copy the other path component */
312
313 if (!PathAddBackslashW(pszPath)) /* Append a backslash at the end */
314 break;
315
316 --cchPathLeft;
317
318 pchPath = &pszPath[lstrlenW(pszPath)];
319
320 if (!bLFN) /* Not LFN? */
321 {
322 /* Copy MS-DOS 8.3 filename */
323 PWCHAR pchDot = NULL;
324 INT ich;
325 WCHAR szTitle[8 + 1] = L"";
326 INT cchTitle = 0;
327 WCHAR szDotExtension[1 + 3 + 1] = L"";
328 INT cchDotExtension = 0;
329
330 /* Copy the component to szTitle and szDotExtension... */
331 while (*pchTemp && *pchTemp != L'\\')
332 {
333 if (*pchTemp == L'.')
334 {
335 pchDot = pchTemp; /* Remember the last position */
336
337 /* Clear szDotExtension */
338 cchDotExtension = 0;
339 ZeroMemory(szDotExtension, sizeof(szDotExtension));
340 }
341
342 if (pchDot)
343 {
344 if (cchDotExtension < 1 + 3)
345 szDotExtension[cchDotExtension++] = *pchTemp;
346 }
347 else
348 {
349 if (cchTitle < 8)
350 szTitle[cchTitle++] = *pchTemp;
351 }
352
353 ++pchTemp;
354 }
355
356 /* Add file title 'szTitle' to pchPath */
357 for (ich = 0; szTitle[ich] && cchPathLeft > 0; ++ich)
358 {
359 *pchPath++ = szTitle[ich];
360 --cchPathLeft;
361 }
362
363 /* Add file extension 'szDotExtension' to pchPath */
364 if (pchDot)
365 {
366 for (ich = 0; szDotExtension[ich] && cchPathLeft > 0; ++ich)
367 {
368 *pchPath++ = szDotExtension[ich];
369 --cchPathLeft;
370 }
371 }
372 }
373 else /* LFN */
374 {
375 /* Copy the component up to the next separator */
376 while (*pchTemp != UNICODE_NULL && *pchTemp != L'\\' && cchPathLeft > 0)
377 {
378 *pchPath++ = *pchTemp++;
379 --cchPathLeft;
380 }
381 }
382
383 /* Skip the backslashes */
384 while (*pchTemp == L'\\')
385 {
386 ++pchTemp;
387 }
388
389 /* Keep null-terminated */
390 *pchPath = UNICODE_NULL;
391 }
392
393 /* Remove any trailing backslash */
394 PathRemoveBackslashW(pszPath);
395
396 if (!(dwFlags & 1)) /* Remove the trailing dot? */
397 {
398 pchPath = CharPrevW(pszPath, pszPath + lstrlenW(pszPath));
399 if (*pchPath == L'.')
400 *pchPath = UNICODE_NULL;
401 }
402}
#define lstrlenW
Definition: compat.h:750
#define VALID_SHORT_PATH_CHAR_CLASSES
VOID WINAPI FixSlashesAndColonW(LPWSTR lpwstr)
Definition: ordinal.c:4551
BOOL WINAPI PathRemoveFileSpecW(LPWSTR lpszPath)
Definition: path.c:629
BOOL WINAPI PathIsValidCharW(WCHAR c, DWORD class)
Definition: path.c:4409
LPWSTR WINAPI PathRemoveBackslashW(LPWSTR lpszPath)
Definition: path.c:867
TCHAR szTitle[MAX_LOADSTRING]
Definition: magnifier.c:35
#define pch(ap)
Definition: match.c:418
#define INT
Definition: polytest.cpp:20
_In_ LPCSTR pszDir
Definition: shellapi.h:590
ULONG_PTR SIZE_T
Definition: typedefs.h:80
uint16_t * PWCHAR
Definition: typedefs.h:56
#define ZeroMemory
Definition: winbase.h:1743
LPWSTR WINAPI CharPrevW(_In_ LPCWSTR, _In_ LPCWSTR)

Referenced by PathQualifyW(), and PathResolveW().

◆ PathQualifyW()

VOID WINAPI PathQualifyW ( LPWSTR  pszPath)

Definition at line 969 of file shellpath.c.

970{
971 TRACE("%s\n",debugstr_w(pszPath));
972 PathQualifyExW(pszPath, NULL, 0);
973}
static VOID WINAPI PathQualifyExW(_Inout_ LPWSTR pszPath, _Inout_opt_ LPCWSTR pszDir, _In_ DWORD dwFlags)
Definition: shellpath.c:158

Referenced by PathQualifyA(), and PathQualifyAW().

◆ PathRemoveFileSpecAW()

BOOL WINAPI PathRemoveFileSpecAW ( LPVOID  lpszPath)

Definition at line 453 of file shellpath.c.

454{
455 if (SHELL_OsIsUnicode())
456 return PathRemoveFileSpecW(lpszPath);
457 return PathRemoveFileSpecA(lpszPath);
458}
BOOL WINAPI PathRemoveFileSpecA(LPSTR lpszPath)
Definition: path.c:586

◆ PathResolveA()

BOOL WINAPI PathResolveA ( LPSTR  path,
LPCSTR dirs,
DWORD  flags 
)

Definition at line 986 of file shellpath.c.

987{
988 BOOL ret = FALSE;
989 LPWSTR *dirsW = NULL;
990 DWORD iDir, cDirs, cbDirs;
991 WCHAR pathW[MAX_PATH];
992
993 TRACE("(%s,%p,0x%08x)\n", debugstr_a(path), dirs, flags);
994
995 if (dirs)
996 {
997 for (cDirs = 0; dirs[cDirs]; ++cDirs)
998 ;
999
1000 cbDirs = (cDirs + 1) * sizeof(LPWSTR);
1001 dirsW = SHAlloc(cbDirs);
1002 if (!dirsW)
1003 goto Cleanup;
1004
1005 ZeroMemory(dirsW, cbDirs);
1006 for (iDir = 0; iDir < cDirs; ++iDir)
1007 {
1008 __SHCloneStrAtoW(&dirsW[iDir], dirs[iDir]);
1009 if (dirsW[iDir] == NULL)
1010 goto Cleanup;
1011 }
1012 }
1013
1014 SHAnsiToUnicode(path, pathW, _countof(pathW));
1015
1016 ret = PathResolveW(pathW, (LPCWSTR*)dirsW, flags);
1017 if (ret)
1018 SHUnicodeToAnsi(pathW, path, MAX_PATH);
1019
1020Cleanup:
1021 if (dirsW)
1022 {
1023 for (iDir = 0; iDir < cDirs; ++iDir)
1024 {
1025 SHFree(dirsW[iDir]);
1026 }
1027 SHFree(dirsW);
1028 }
1029 return ret;
1030}
void WINAPI SHFree(LPVOID pv)
Definition: shellole.c:326
LPVOID WINAPI SHAlloc(SIZE_T len)
Definition: shellole.c:304
BOOL WINAPI PathResolveW(_Inout_ LPWSTR path, _Inout_opt_ LPCWSTR *dirs, _In_ DWORD flags)
Definition: shellpath.c:1032
static const WCHAR Cleanup[]
Definition: register.c:80
GLbitfield flags
Definition: glext.h:7161
static __inline LPWSTR __SHCloneStrAtoW(WCHAR **target, const char *source)
Definition: shell32_main.h:185

Referenced by PathResolveAW().

◆ PathResolveAW()

BOOL WINAPI PathResolveAW ( LPVOID  path,
LPCVOID paths,
DWORD  flags 
)

Definition at line 1109 of file shellpath.c.

1110{
1111 if (SHELL_OsIsUnicode())
1112 return PathResolveW(path, (LPCWSTR*)paths, flags);
1113 else
1114 return PathResolveA(path, (LPCSTR*)paths, flags);
1115}
BOOL WINAPI PathResolveA(LPSTR path, LPCSTR *dirs, DWORD flags)
Definition: shellpath.c:986
GLsizei const GLuint * paths
Definition: glext.h:11717

◆ PathResolveW()

BOOL WINAPI PathResolveW ( _Inout_ LPWSTR  path,
_Inout_opt_ LPCWSTR dirs,
_In_ DWORD  flags 
)

Definition at line 1032 of file shellpath.c.

1033{
1034 DWORD dwWhich = WHICH_DEFAULT; /* The extensions to be searched */
1035
1036 TRACE("(%s,%p,0x%08x)\n", debugstr_w(path), dirs, flags);
1037
1038 if (flags & PRF_DONTFINDLNK)
1039 dwWhich &= ~WHICH_LNK; /* Don't search '.LNK' (shortcut) */
1040
1041 if (flags & PRF_VERIFYEXISTS)
1042 SetLastError(ERROR_FILE_NOT_FOUND); /* We set this error code at first in verification */
1043
1045
1046 if (PathIsRootW(path)) /* Root path */
1047 {
1048 if (path[0] == L'\\' && path[1] == UNICODE_NULL) /* '\' only? */
1049 PathQualifyExW(path, ((flags & PRF_FIRSTDIRDEF) ? *dirs : NULL), 0); /* Qualify */
1050
1051 if (flags & PRF_VERIFYEXISTS)
1052 return PathFileExistsAndAttributesW(path, NULL); /* Check the existence */
1053
1054 return TRUE;
1055 }
1056
1057 if (PathIsFileSpecW(path)) /* Filename only */
1058 {
1059 /* Try to find the path with program extensions applied? */
1061 PathSearchOnExtensionsW(path, dirs, TRUE, dwWhich))
1062 {
1063 return TRUE; /* Found */
1064 }
1065
1066 /* Try to find the filename in the directories */
1067 if (PathFindOnPathW(path, dirs))
1068 goto CheckAbsoluteAndFinish;
1069
1070 return FALSE; /* Not found */
1071 }
1072
1073 if (PathIsURLW(path)) /* URL? */
1074 return FALSE;
1075
1076 /* Qualify the path */
1077 PathQualifyExW(path, ((flags & PRF_FIRSTDIRDEF) ? *dirs : NULL), 1);
1078
1079 TRACE("(%s)\n", debugstr_w(path));
1080
1081 if (!(flags & PRF_VERIFYEXISTS)) /* Don't verify the existence? */
1082 return TRUE;
1083
1084 /* Try to find the path with program extensions applied? */
1086 !PathSearchOnExtensionsW(path, dirs, FALSE, dwWhich))
1087 {
1089 return FALSE; /* Not found */
1090 }
1091
1092CheckAbsoluteAndFinish:
1093#if (_WIN32_WINNT >= _WIN32_WINNT_WS03)
1095 return TRUE;
1096
1097 if (!PathMakeAbsoluteW(path))
1098 return FALSE;
1099
1101#else
1102 return TRUE; /* Found */
1103#endif
1104}
#define PRF_VERIFYEXISTS
Definition: PathResolve.cpp:38
#define PRF_TRYPROGRAMEXTENSIONS
Definition: PathResolve.cpp:40
#define PRF_REQUIREABSOLUTE
Definition: PathResolve.cpp:45
#define PRF_FIRSTDIRDEF
Definition: PathResolve.cpp:41
#define PRF_DONTFINDLNK
Definition: PathResolve.cpp:42
#define SetLastError(x)
Definition: compat.h:752
static BOOL WINAPI PathMakeAbsoluteW(_Inout_ LPWSTR path)
Definition: shellpath.c:141
static BOOL WINAPI PathSearchOnExtensionsW(_Inout_ LPWSTR pszPath, _In_opt_ LPCWSTR *ppszDirs, _In_ BOOL bDoSearch, _In_ DWORD dwWhich)
Definition: shellpath.c:120
static BOOL WINAPI PathIsAbsoluteW(_In_ LPCWSTR path)
Definition: shellpath.c:136
BOOL WINAPI PathFindOnPathW(LPWSTR lpszFile, LPCWSTR *lppszOtherDirs)
Definition: path.c:1409
VOID WINAPI PathUnquoteSpacesW(LPWSTR lpszPath)
Definition: path.c:1040
BOOL WINAPI PathIsFileSpecW(LPCWSTR lpszPath)
Definition: path.c:2139
BOOL WINAPI PathFileExistsAndAttributesW(LPCWSTR lpszPath, DWORD *dwAttr)
Definition: path.c:1838
BOOL WINAPI PathIsURLW(LPCWSTR lpstrPath)
Definition: url.c:2432
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
#define WHICH_DEFAULT

Referenced by FindExecutableW(), PathProcessCommandW(), PathResolveA(), PathResolveAW(), CShellLink::SetTargetFromPIDLOrPath(), and SHELL_FindExecutable().

◆ PathSearchOnExtensionsW()

static BOOL WINAPI PathSearchOnExtensionsW ( _Inout_ LPWSTR  pszPath,
_In_opt_ LPCWSTR ppszDirs,
_In_ BOOL  bDoSearch,
_In_ DWORD  dwWhich 
)
static

Definition at line 120 of file shellpath.c.

125{
126 if (*PathFindExtensionW(pszPath) != 0)
127 return FALSE;
128
129 if (bDoSearch)
130 return PathFindOnPathExW(pszPath, ppszDirs, dwWhich);
131 else
132 return PathFileExistsDefExtW(pszPath, dwWhich);
133}
BOOL WINAPI PathFindOnPathExW(LPWSTR lpszFile, LPCWSTR *lppszOtherDirs, DWORD dwWhich)
Definition: path.c:1357
BOOL WINAPI PathFileExistsDefExtW(LPWSTR lpszPath, DWORD dwWhich)
Definition: path.c:1123

Referenced by PathResolveW().

◆ PathYetAnotherMakeUniqueName()

BOOL WINAPI PathYetAnotherMakeUniqueName ( LPWSTR  buffer,
LPCWSTR  path,
LPCWSTR  shortname,
LPCWSTR  longname 
)

Definition at line 848 of file shellpath.c.

849{
850 WCHAR pathW[MAX_PATH], retW[MAX_PATH];
851 const WCHAR *file, *ext;
852 int i = 2;
853
854 TRACE("(%p, %s, %s, %s)\n", buffer, debugstr_w(path), debugstr_w(shortname), debugstr_w(longname));
855
856 file = longname ? longname : shortname;
857 PathCombineW(pathW, path, file);
858 strcpyW(retW, pathW);
860
862
863 /* now try to make it unique */
864 while (PathFileExistsW(retW))
865 {
866 sprintfW(retW, L"%s (%d)%s", pathW, i, ext);
867 i++;
868 }
869
870 strcpyW(buffer, retW);
871 TRACE("ret - %s\n", debugstr_w(buffer));
872
873 return TRUE;
874}
static const WCHAR *const ext[]
Definition: module.c:53
void WINAPI PathRemoveExtensionW(LPWSTR lpszPath)
Definition: path.c:823
#define sprintfW
Definition: unicode.h:64
Definition: fci.c:127

Referenced by BrFolder_NewFolder(), CNewMenu::CreateNewFolder(), CDefaultContextMenu::DoCreateNewFolder(), CDeskLinkDropHandler::Drop(), FinishDlgProc(), loadShell32(), and CNewMenu::NewItemByNonCommand().

◆ Shell_ParseSpecialFolder()

INT Shell_ParseSpecialFolder ( _In_ LPCWSTR  pszStart,
_Out_ LPWSTR ppch,
_Out_ INT pcch 
)

Definition at line 1986 of file shellpath.c.

1987{
1988 LPCWSTR pszPath, pchBackslash;
1990
1991 pchBackslash = StrChrW(pszStart, L'\\');
1992 if (pchBackslash)
1993 {
1994 *ppch = (LPWSTR)(pchBackslash + 1);
1995 *pcch = (pchBackslash - pszStart) + 1;
1996 StrCpyNW(szPath, pszStart, min(*pcch, _countof(szPath)));
1997 pszPath = szPath;
1998 }
1999 else
2000 {
2001 *ppch = NULL;
2002 *pcch = lstrlenW(pszStart);
2003 pszPath = pszStart;
2004 }
2005
2006 return SHGetSpecialFolderID(pszPath);
2007}
INT SHGetSpecialFolderID(_In_ LPCWSTR pszName)
Definition: shellpath.c:1972
LPWSTR WINAPI StrCpyNW(LPWSTR dst, LPCWSTR src, int count)
Definition: string.c:536
#define min(a, b)
Definition: monoChain.cc:55

Referenced by CDesktopFolder::ShellUrlParseDisplayName().

◆ SHELL_RegisterShellFolders()

HRESULT SHELL_RegisterShellFolders ( void  )

Definition at line 3191 of file shellpath.c.

3192{
3193 HRESULT hr;
3194
3196 if (SUCCEEDED(hr))
3198 if (SUCCEEDED(hr))
3200 return hr;
3201}
static HRESULT _SHRegisterUserShellFolders(BOOL bDefault)
Definition: shellpath.c:3095
static HRESULT _SHRegisterCommonShellFolders(void)
Definition: shellpath.c:3163

Referenced by DllRegisterServer().

◆ SHGetFolderLocation()

HRESULT WINAPI SHGetFolderLocation ( HWND  hwndOwner,
int  nFolder,
HANDLE  hToken,
DWORD  dwReserved,
LPITEMIDLIST ppidl 
)

Definition at line 3277 of file shellpath.c.

3283{
3285#ifdef __REACTOS__
3287#endif
3288
3289 TRACE("%p 0x%08x %p 0x%08x %p\n",
3290 hwndOwner, nFolder, hToken, dwReserved, ppidl);
3291
3292 if (!ppidl)
3293 return E_INVALIDARG;
3294 if (dwReserved)
3295 return E_INVALIDARG;
3296
3297#ifdef __REACTOS__
3298 if ((nFolder & CSIDL_FLAG_NO_ALIAS) &&
3300 {
3301 *ppidl = ILCreateFromPathW(szPath);
3302 if (*ppidl)
3303 return S_OK;
3304 }
3305#endif
3306 /* The virtual folders' locations are not user-dependent */
3307 *ppidl = NULL;
3308 switch (nFolder & CSIDL_FOLDER_MASK)
3309 {
3310 case CSIDL_DESKTOP:
3311 *ppidl = _ILCreateDesktop();
3312 break;
3313
3314 case CSIDL_PERSONAL:
3315 *ppidl = _ILCreateMyDocuments();
3316 break;
3317
3318 case CSIDL_INTERNET:
3319 *ppidl = _ILCreateIExplore();
3320 break;
3321
3322 case CSIDL_CONTROLS:
3323 *ppidl = _ILCreateControlPanel();
3324 break;
3325
3326 case CSIDL_PRINTERS:
3327 *ppidl = _ILCreatePrinters();
3328 break;
3329
3330 case CSIDL_BITBUCKET:
3331 *ppidl = _ILCreateBitBucket();
3332 break;
3333
3334 case CSIDL_DRIVES:
3335 *ppidl = _ILCreateMyComputer();
3336 break;
3337
3338 case CSIDL_NETWORK:
3339 *ppidl = _ILCreateNetwork();
3340 break;
3341
3342#ifdef __REACTOS__
3343 case CSIDL_CONNECTIONS:
3344 hr = SHGetFolderLocationHelper(hwndOwner, CSIDL_CONTROLS, &CLSID_NetworkConnections, ppidl);
3345 break;
3346#endif
3347
3348 default:
3349 {
3351
3352 hr = SHGetFolderPathW(hwndOwner, nFolder, hToken,
3354 if (SUCCEEDED(hr))
3355 {
3356 DWORD attributes=0;
3357
3358 TRACE("Value=%s\n", debugstr_w(szPath));
3359 hr = SHILCreateFromPathW(szPath, ppidl, &attributes);
3360 }
3362 {
3363 /* unlike SHGetFolderPath, SHGetFolderLocation in shell32
3364 * version 6.0 returns E_FAIL for nonexistent paths
3365 */
3366 hr = E_FAIL;
3367 }
3368 }
3369 }
3370 if(*ppidl)
3371 hr = S_OK;
3372
3373 TRACE("-- (new pidl %p)\n",*ppidl);
3374 return hr;
3375}
BOOL WINAPI SHGetSpecialFolderPathW(HWND hwndOwner, LPWSTR szPath, int nFolder, BOOL bCreate)
Definition: shellpath.c:3219
_In_ HANDLE _In_ DWORD _In_ DWORD _Inout_opt_ LPOVERLAPPED _In_opt_ LPTRANSMIT_FILE_BUFFERS _In_ DWORD dwReserved
Definition: mswsock.h:95
LPITEMIDLIST _ILCreateMyComputer(void)
Definition: pidl.c:1798
LPITEMIDLIST _ILCreateIExplore(void)
Definition: pidl.c:1810
HRESULT WINAPI SHILCreateFromPathW(LPCWSTR path, LPITEMIDLIST *ppidl, DWORD *attributes)
Definition: pidl.c:403
LPITEMIDLIST _ILCreateDesktop(void)
Definition: pidl.c:1787
LPITEMIDLIST _ILCreateNetwork(void)
Definition: pidl.c:1861
LPITEMIDLIST _ILCreatePrinters(void)
Definition: pidl.c:1834
LPITEMIDLIST _ILCreateControlPanel(void)
Definition: pidl.c:1816
LPITEMIDLIST WINAPI ILCreateFromPathW(LPCWSTR path)
Definition: pidl.c:1101
LPITEMIDLIST _ILCreateMyDocuments(void)
Definition: pidl.c:1804
LPITEMIDLIST _ILCreateBitBucket(void)
Definition: pidl.c:1867
#define CSIDL_FLAG_NO_ALIAS
Definition: shlobj.h:2241
#define CSIDL_CONNECTIONS
Definition: shlobj.h:2229
#define CSIDL_PRINTERS
Definition: shlobj.h:2185
#define CSIDL_FOLDER_MASK
Definition: shlobj.h:2239
#define CSIDL_DESKTOP
Definition: shlobj.h:2181
#define CSIDL_NETWORK
Definition: shlobj.h:2198
#define CSIDL_DRIVES
Definition: shlobj.h:2197
#define CSIDL_INTERNET
Definition: shlobj.h:2182
#define CSIDL_CONTROLS
Definition: shlobj.h:2184
#define CSIDL_BITBUCKET
Definition: shlobj.h:2191
_In_ int nFolder
Definition: shlobj.h:1527

Referenced by CBandSiteMenu::_CreateBuiltInISFBand(), CShellMenuCallback::AddStartMenuItems(), BrFolder_OnInitDialog(), LoadRdpSettingsFromFile(), loadShell32(), SaveRdpSettingsToFile(), SHCreateFromDesktop(), CDesktopFolder::ShellUrlParseDisplayName(), SHEmptyRecycleBinW(), SHGetSpecialFolderLocation(), START_TEST(), TestCommandLine(), and TestCompareIDList().

◆ SHGetFolderPathA()

HRESULT WINAPI SHGetFolderPathA ( HWND  hwndOwner,
int  nFolder,
HANDLE  hToken,
DWORD  dwFlags,
LPSTR  pszPath 
)

Definition at line 2963 of file shellpath.c.

2969{
2970 WCHAR szTemp[MAX_PATH];
2971 HRESULT hr;
2972
2973 TRACE("%p,%d,%p,%#x,%p\n", hwndOwner, nFolder, hToken, dwFlags, pszPath);
2974
2975 if (pszPath)
2976 *pszPath = '\0';
2977 hr = SHGetFolderPathW(hwndOwner, nFolder, hToken, dwFlags, szTemp);
2978 if (SUCCEEDED(hr) && pszPath)
2979 WideCharToMultiByte(CP_ACP, 0, szTemp, -1, pszPath, MAX_PATH, NULL,
2980 NULL);
2981
2982 return hr;
2983}
#define CP_ACP
Definition: compat.h:109
#define WideCharToMultiByte
Definition: compat.h:111

Referenced by ini_absent(), ini_present(), loadShell32(), pf_exists(), ppc_present(), SHGetSpecialFolderPathA(), test_profile_items(), test_SHGetFolderPathA(), and test_SHGetFolderPathAndSubDirA().

◆ SHGetFolderPathAndSubDirA()

HRESULT WINAPI SHGetFolderPathAndSubDirA ( HWND  hwndOwner,
int  nFolder,
HANDLE  hToken,
DWORD  dwFlags,
LPCSTR  pszSubPath,
LPSTR  pszPath 
)

Definition at line 2729 of file shellpath.c.

2736{
2737 int length;
2738 HRESULT hr = S_OK;
2739 LPWSTR pszSubPathW = NULL;
2740 LPWSTR pszPathW = NULL;
2741
2742 TRACE("%p,%#x,%p,%#x,%s,%p\n", hwndOwner, nFolder, hToken, dwFlags, debugstr_a(pszSubPath), pszPath);
2743
2744 if(pszPath) {
2745 pszPathW = HeapAlloc(GetProcessHeap(), 0, MAX_PATH * sizeof(WCHAR));
2746 if(!pszPathW) {
2748 goto cleanup;
2749 }
2750 }
2751 TRACE("%08x,%08x,%s\n",nFolder, dwFlags, debugstr_w(pszSubPathW));
2752
2753 /* SHGetFolderPathAndSubDirW does not distinguish if pszSubPath isn't
2754 * set (null), or an empty string.therefore call it without the parameter set
2755 * if pszSubPath is an empty string
2756 */
2757 if (pszSubPath && pszSubPath[0]) {
2758 length = MultiByteToWideChar(CP_ACP, 0, pszSubPath, -1, NULL, 0);
2759 pszSubPathW = HeapAlloc(GetProcessHeap(), 0, length * sizeof(WCHAR));
2760 if(!pszSubPathW) {
2762 goto cleanup;
2763 }
2764 MultiByteToWideChar(CP_ACP, 0, pszSubPath, -1, pszSubPathW, length);
2765 }
2766
2767 hr = SHGetFolderPathAndSubDirW(hwndOwner, nFolder, hToken, dwFlags, pszSubPathW, pszPathW);
2768
2769 if (SUCCEEDED(hr) && pszPath)
2770 WideCharToMultiByte(CP_ACP, 0, pszPathW, -1, pszPath, MAX_PATH, NULL, NULL);
2771
2772cleanup:
2773 HeapFree(GetProcessHeap(), 0, pszPathW);
2774 HeapFree(GetProcessHeap(), 0, pszSubPathW);
2775 return hr;
2776}
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
#define MultiByteToWideChar
Definition: compat.h:110
static void cleanup(void)
Definition: main.c:1335
HRESULT WINAPI SHGetFolderPathAndSubDirW(HWND hwndOwner, int nFolder, HANDLE hToken, DWORD dwFlags, LPCWSTR pszSubPath, LPWSTR pszPath)
Definition: shellpath.c:2781

Referenced by test_SHGetFolderPathAndSubDirA().

◆ SHGetFolderPathAndSubDirW()

HRESULT WINAPI SHGetFolderPathAndSubDirW ( HWND  hwndOwner,
int  nFolder,
HANDLE  hToken,
DWORD  dwFlags,
LPCWSTR  pszSubPath,
LPWSTR  pszPath 
)

Definition at line 2781 of file shellpath.c.

2788{
2789 HRESULT hr;
2790 WCHAR szBuildPath[MAX_PATH], szTemp[MAX_PATH];
2793 int ret;
2794
2795 TRACE("%p,%#x,%p,%#x,%s,%p\n", hwndOwner, nFolder, hToken, dwFlags, debugstr_w(pszSubPath), pszPath);
2796
2797 /* Windows always NULL-terminates the resulting path regardless of success
2798 * or failure, so do so first
2799 */
2800 if (pszPath)
2801 *pszPath = '\0';
2802
2804 return E_INVALIDARG;
2806 return E_INVALIDARG;
2807 szTemp[0] = 0;
2809 switch (type)
2810 {
2812 hr = E_INVALIDARG;
2813 break;
2815 hr = S_FALSE;
2816 break;
2819 if (CSIDL_Data[folder].szDefaultPath &&
2820 !IS_INTRESOURCE(CSIDL_Data[folder].szDefaultPath) &&
2821 *CSIDL_Data[folder].szDefaultPath)
2822 {
2823 PathAddBackslashW(szTemp);
2824 strcatW(szTemp, CSIDL_Data[folder].szDefaultPath);
2825 }
2826 hr = S_OK;
2827 break;
2830 if (CSIDL_Data[folder].szDefaultPath &&
2831 !IS_INTRESOURCE(CSIDL_Data[folder].szDefaultPath) &&
2832 *CSIDL_Data[folder].szDefaultPath)
2833 {
2834 PathAddBackslashW(szTemp);
2835 strcatW(szTemp, CSIDL_Data[folder].szDefaultPath);
2836 }
2837 hr = S_OK;
2838 break;
2841 if (CSIDL_Data[folder].szDefaultPath &&
2842 !IS_INTRESOURCE(CSIDL_Data[folder].szDefaultPath) &&
2843 *CSIDL_Data[folder].szDefaultPath)
2844 {
2845 PathAddBackslashW(szTemp);
2846 strcatW(szTemp, CSIDL_Data[folder].szDefaultPath);
2847 }
2848 hr = S_OK;
2849 break;
2850 case CSIDL_Type_CurrVer:
2852 break;
2853 case CSIDL_Type_User:
2854#ifdef __REACTOS__
2855 case CSIDL_Type_InMyDocuments:
2856#endif
2857 hr = _SHGetUserProfilePath(hToken, dwFlags, folder, szTemp);
2858 break;
2861 break;
2862 default:
2863 FIXME("bogus type %d, please fix\n", type);
2864 hr = E_INVALIDARG;
2865 break;
2866 }
2867
2868 /* Expand environment strings if necessary */
2869 if (*szTemp == '%')
2870#ifndef __REACTOS__
2871 hr = _SHExpandEnvironmentStrings(szTemp, szBuildPath);
2872#else
2873 hr = _SHExpandEnvironmentStrings(hToken, szTemp, szBuildPath, _countof(szBuildPath));
2874#endif
2875 else
2876 strcpyW(szBuildPath, szTemp);
2877
2878 if (FAILED(hr)) goto end;
2879
2880 if(pszSubPath) {
2881 /* make sure the new path does not exceed the buffer length
2882 * and remember to backslash and terminate it */
2883 if(MAX_PATH < (lstrlenW(szBuildPath) + lstrlenW(pszSubPath) + 2)) {
2885 goto end;
2886 }
2887 PathAppendW(szBuildPath, pszSubPath);
2888 PathRemoveBackslashW(szBuildPath);
2889 }
2890 /* Copy the path if it's available before we might return */
2891 if (SUCCEEDED(hr) && pszPath)
2892 strcpyW(pszPath, szBuildPath);
2893
2894 /* if we don't care about existing directories we are ready */
2896
2897 if (PathFileExistsW(szBuildPath)) goto end;
2898
2899 /* not existing but we are not allowed to create it. The return value
2900 * is verified against shell32 version 6.0.
2901 */
2902 if (!(nFolder & CSIDL_FLAG_CREATE))
2903 {
2905 goto end;
2906 }
2907
2908 /* create directory/directories */
2909 ret = SHCreateDirectoryExW(hwndOwner, szBuildPath, NULL);
2910 if (ret && ret != ERROR_ALREADY_EXISTS)
2911 {
2912 ERR("Failed to create directory %s.\n", debugstr_w(szBuildPath));
2913 hr = E_FAIL;
2914 goto end;
2915 }
2916
2917 TRACE("Created missing system directory %s\n", debugstr_w(szBuildPath));
2918
2919end:
2920#ifdef __REACTOS__
2921 /* create desktop.ini for custom icon */
2922 if ((nFolder & CSIDL_FLAG_CREATE) &&
2923 CSIDL_Data[folder].nShell32IconIndex)
2924 {
2925 WCHAR szIconLocation[MAX_PATH];
2927
2928 /* make the directory a read-only folder */
2929 dwAttributes = GetFileAttributesW(szBuildPath);
2931 SetFileAttributesW(szBuildPath, dwAttributes);
2932
2933 /* build the desktop.ini file path */
2934 PathAppendW(szBuildPath, L"desktop.ini");
2935
2936 /* build the icon location */
2937 StringCchPrintfW(szIconLocation, _countof(szIconLocation),
2938 L"%%SystemRoot%%\\system32\\shell32.dll,%d",
2939 CSIDL_Data[folder].nShell32IconIndex);
2940
2941 /* write desktop.ini */
2942 WritePrivateProfileStringW(L".ShellClassInfo", L"IconResource", szIconLocation, szBuildPath);
2943
2944 /* flush! */
2945 WritePrivateProfileStringW(NULL, NULL, NULL, szBuildPath);
2946
2947 /* make the desktop.ini a system and hidden file */
2948 dwAttributes = GetFileAttributesW(szBuildPath);
2950 SetFileAttributesW(szBuildPath, dwAttributes);
2951 }
2952#endif
2953
2954 TRACE("returning 0x%08x (final path is %s)\n", hr, debugstr_w(szBuildPath));
2955 return hr;
2956}
DWORD WINAPI GetFileAttributesW(LPCWSTR lpFileName)
Definition: fileinfo.c:652
BOOL WINAPI SetFileAttributesW(LPCWSTR lpFileName, DWORD dwFileAttributes)
Definition: fileinfo.c:794
UINT WINAPI GetSystemWow64DirectoryW(OUT LPWSTR lpBuffer, IN UINT uSize)
Definition: path.c:2421
BOOL WINAPI WritePrivateProfileStringW(LPCWSTR section, LPCWSTR entry, LPCWSTR string, LPCWSTR filename)
Definition: profile.c:1453
static HRESULT _SHGetCurrentVersionPath(DWORD dwFlags, BYTE folder, LPWSTR pszPath)
Definition: shellpath.c:2260
#define ERROR_ALREADY_EXISTS
Definition: disk.h:80
#define FILE_ATTRIBUTE_READONLY
Definition: nt_native.h:702
#define FILE_ATTRIBUTE_HIDDEN
Definition: nt_native.h:703
#define FILE_ATTRIBUTE_SYSTEM
Definition: nt_native.h:704
int WINAPI SHCreateDirectoryExW(HWND hWnd, LPCWSTR path, LPSECURITY_ATTRIBUTES sec)
Definition: shlfileop.cpp:1006
#define CSIDL_FLAG_DONT_VERIFY
Definition: shlobj.h:2242
STRSAFEAPI StringCchPrintfW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszFormat,...)
Definition: strsafe.h:530
CSIDL_Type type
Definition: shellpath.c:1219
DWORD dwAttributes
Definition: vdmdbg.h:34
#define S_FALSE
Definition: winerror.h:2357
#define ERROR_PATH_NOT_FOUND
Definition: winerror.h:106
#define ERROR_FILENAME_EXCED_RANGE
Definition: winerror.h:263

Referenced by CBandSiteMenu::_GetQLaunchPidl(), CreateShortcuts(), SHGetFolderPathAndSubDirA(), SHGetFolderPathW(), and ThemePageDlgProc().

◆ SHGetFolderPathW()

◆ SHGetSpecialFolderID()

INT SHGetSpecialFolderID ( _In_ LPCWSTR  pszName)

Definition at line 1972 of file shellpath.c.

1973{
1974 UINT csidl;
1975
1976 for (csidl = 0; csidl < _countof(CSIDL_Data); ++csidl)
1977 {
1978 const CSIDL_DATA *pData = &CSIDL_Data[csidl];
1979 if (pData->szValueName && lstrcmpiW(pszName, pData->szValueName) == 0)
1980 return csidl;
1981 }
1982
1983 return -1;
1984}
int WINAPI lstrcmpiW(LPCWSTR str1, LPCWSTR str2)
Definition: locale.c:4262
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1830

Referenced by Shell_ParseSpecialFolder().

◆ SHGetSpecialFolderLocation()

HRESULT WINAPI SHGetSpecialFolderLocation ( HWND  hwndOwner,
INT  nFolder,
LPITEMIDLIST ppidl 
)

Definition at line 3384 of file shellpath.c.

3388{
3390
3391 TRACE("(%p,0x%x,%p)\n", hwndOwner,nFolder,ppidl);
3392
3393 if (!ppidl)
3394 return E_INVALIDARG;
3395
3396 hr = SHGetFolderLocation(hwndOwner, nFolder, NULL, 0, ppidl);
3397 return hr;
3398}
HRESULT WINAPI SHGetFolderLocation(HWND hwndOwner, int nFolder, HANDLE hToken, DWORD dwReserved, LPITEMIDLIST *ppidl)
Definition: shellpath.c:3277

Referenced by _GetDocumentsPidl(), CShellMenuCallback::AddOrSetMenuItem(), DoGetPidl(), DoInitAliasPIDLs(), DoTestEntry(), DynamicSHGetSpecialFolderPathW(), ebrowser_browse_to_desktop(), FILEDLG95_InitControls(), FILEDLG95_LOOKIN_Init(), FILEDLG95_OnWMCommand(), filedlg_collect_places_pidls(), GetFavoritesFolder(), GetFavsLocation(), GetMergedFolder(), GetParsingName(), CSendToMenu::GetSpecialFolder(), CSearchBar::Invoke(), IShellBrowserImpl_Construct(), loadShell32(), MRUList_PidlList_0(), CACListISF::NextLocation(), CShellMenuCallback::OnGetContextMenu(), PidlBrowse(), CAddressEditBox::PopulateComboBox(), RSHELL_CStartMenu_CreateInstance(), SHAddToRecentDocs(), SHCloneSpecialIDList(), Shell_ParsePrinterName(), SHELL_ShowItemIDListProperties(), SHExplorerParseCmdLine(), CRecycleBinCleaner::ShowProperties(), SpecialFolderPath::SpecialFolderPath(), START_TEST(), test_ACListISF_FAVORITES(), test_ACListISF_MYCOMPUTER(), test_get_file_info_iconlist(), test_namespace(), test_parameters(), test_printers_folder(), test_SHCreateShellItem(), test_SHCreateShellItemArray(), test_ShellItemBindToHandler(), test_ShellItemGetAttributes(), test_SHGetIDListFromObject(), test_SHGetNameFromIDList(), test_SHGetPathFromIDList(), VariantToIdlist(), and WshCollection_Item().

◆ SHGetSpecialFolderPathA()

BOOL WINAPI SHGetSpecialFolderPathA ( HWND  hwndOwner,
LPSTR  szPath,
int  nFolder,
BOOL  bCreate 
)

Definition at line 3206 of file shellpath.c.

3211{
3212 return SHGetFolderPathA(hwndOwner, nFolder + (bCreate ? CSIDL_FLAG_CREATE : 0), NULL, 0,
3213 szPath) == S_OK;
3214}
HRESULT WINAPI SHGetFolderPathA(HWND hwndOwner, int nFolder, HANDLE hToken, DWORD dwFlags, LPSTR pszPath)
Definition: shellpath.c:2963
_In_ int _In_ BOOL bCreate
Definition: shlobj.h:1528

Referenced by get_cache_path(), init_strings(), loadShell32(), main(), test_BindToObject(), test_find_file(), and test_GetDisplayName().

◆ SHGetSpecialFolderPathW()

◆ SHPathGetExtensionW()

LPVOID WINAPI SHPathGetExtensionW ( LPCWSTR  lpszPath,
DWORD  void1,
DWORD  void2 
)

Definition at line 445 of file shellpath.c.

446{
447 return PathGetExtensionW(lpszPath);
448}

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( shell  )

Variable Documentation

◆ Application_DataW

const WCHAR Application_DataW[] = L"Application Data"
static

Definition at line 1171 of file shellpath.c.

◆ CSIDL_Data

◆ is_win64

◆ Local_Settings_Application_DataW

const WCHAR Local_Settings_Application_DataW[] = L"Local Settings\\Application Data"
static

Definition at line 1172 of file shellpath.c.

◆ Local_Settings_HistoryW

const WCHAR Local_Settings_HistoryW[] = L"Local Settings\\History"
static

Definition at line 1173 of file shellpath.c.

◆ Local_Settings_Temporary_Internet_FilesW

const WCHAR Local_Settings_Temporary_Internet_FilesW[] = L"Local Settings\\Temporary Internet Files"
static

Definition at line 1174 of file shellpath.c.

◆ MusicW

const WCHAR MusicW[] = L"Music"
static

Definition at line 1175 of file shellpath.c.

◆ PicturesW

const WCHAR PicturesW[] = L"Pictures"
static

Definition at line 1176 of file shellpath.c.

◆ Program_Files_Common_FilesW

const WCHAR Program_Files_Common_FilesW[] = L"Program Files\\Common Files"
static

Definition at line 1178 of file shellpath.c.

◆ Program_FilesW

const WCHAR Program_FilesW[] = L"Program Files"
static

Definition at line 1177 of file shellpath.c.

◆ Start_Menu_Admin_ToolsW

const WCHAR Start_Menu_Admin_ToolsW[] = L"Start Menu\\Programs\\Administrative Tools"
static

Definition at line 1180 of file shellpath.c.

◆ Start_Menu_ProgramsW

const WCHAR Start_Menu_ProgramsW[] = L"Start Menu\\Programs"
static

Definition at line 1179 of file shellpath.c.

◆ Start_Menu_StartupW

const WCHAR Start_Menu_StartupW[] = L"Start Menu\\Programs\\StartUp"
static

Definition at line 1181 of file shellpath.c.

◆ szKnownFolderDescriptions

const WCHAR szKnownFolderDescriptions[] = L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\FolderDescriptions"
static

Definition at line 1188 of file shellpath.c.

◆ szKnownFolderRedirections

const WCHAR szKnownFolderRedirections[] = L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders"
static

Definition at line 1189 of file shellpath.c.

◆ szSHFolders

◆ szSHUserFolders

const WCHAR szSHUserFolders[] = L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders"
static