ReactOS 0.4.16-dev-981-g80eb313
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 2353 of file shellpath.c.

2354{
2355 char InfoBuffer[64];
2356 PTOKEN_USER UserInfo;
2357 DWORD InfoSize;
2358 LPWSTR SidStr;
2359
2360 UserInfo = (PTOKEN_USER) InfoBuffer;
2361 if (! GetTokenInformation(Token, TokenUser, InfoBuffer, sizeof(InfoBuffer),
2362 &InfoSize))
2363 {
2365 return NULL;
2366 UserInfo = HeapAlloc(GetProcessHeap(), 0, InfoSize);
2367 if (UserInfo == NULL)
2368 return NULL;
2369 if (! GetTokenInformation(Token, TokenUser, UserInfo, InfoSize,
2370 &InfoSize))
2371 {
2372 HeapFree(GetProcessHeap(), 0, UserInfo);
2373 return NULL;
2374 }
2375 }
2376
2377 if (! ConvertSidToStringSidW(UserInfo->User.Sid, &SidStr))
2378 SidStr = NULL;
2379
2380 if (UserInfo != (PTOKEN_USER) InfoBuffer)
2381 HeapFree(GetProcessHeap(), 0, UserInfo);
2382
2383 return SidStr;
2384}
#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 2588 of file shellpath.c.

2592{
2593 HRESULT hr;
2594#ifndef __REACTOS__
2595 WCHAR szTemp[MAX_PATH], szProfilesPrefix[MAX_PATH] = { 0 };
2596 HKEY key = NULL;
2597#else
2598 WCHAR szTemp[MAX_PATH];
2599#endif
2600
2601 TRACE("%s, %p\n", debugstr_w(szSrc), szDest);
2602
2603 if (!szSrc || !szDest) return E_INVALIDARG;
2604
2605 /* short-circuit if there's nothing to expand */
2606 if (szSrc[0] != '%')
2607 {
2608 strcpyW(szDest, szSrc);
2609 hr = S_OK;
2610 goto end;
2611 }
2612#ifndef __REACTOS__
2613 /* Get the profile prefix, we'll probably be needing it */
2615 if (SUCCEEDED(hr))
2616 {
2617 WCHAR def_val[MAX_PATH];
2618
2619 /* get the system drive */
2620 GetSystemDirectoryW(def_val, MAX_PATH);
2621 strcpyW( def_val + 3, L"Users" );
2622
2623 hr = _SHGetProfilesValue(key, L"ProfilesDirectory", szProfilesPrefix, def_val );
2624 }
2625#else
2626 hr = S_OK;
2627#endif
2628
2629 *szDest = 0;
2630 strcpyW(szTemp, szSrc);
2631 while (SUCCEEDED(hr) && szTemp[0] == '%')
2632 {
2633 if (!strncmpiW(szTemp, L"%ALLUSERSPROFILE%", ARRAY_SIZE(L"%ALLUSERSPROFILE%")-1))
2634 {
2635#ifndef __REACTOS__
2636 WCHAR szAllUsers[MAX_PATH];
2637
2638 strcpyW(szDest, szProfilesPrefix);
2639 hr = _SHGetProfilesValue(key, L"AllUsersProfile", szAllUsers, L"Public");
2640 PathAppendW(szDest, szAllUsers);
2641#else
2642 DWORD cchSize = cchDest;
2643 if (!GetAllUsersProfileDirectoryW(szDest, &cchSize))
2644 goto fallback_expand;
2645#endif
2646 PathAppendW(szDest, szTemp + ARRAY_SIZE(L"%ALLUSERSPROFILE%")-1);
2647 }
2648#ifndef __REACTOS__
2649 else if (!strncmpiW(szTemp, L"%PUBLIC%", ARRAY_SIZE(L"%PUBLIC%")-1))
2650 {
2651 WCHAR szAllUsers[MAX_PATH], def_val[MAX_PATH];
2652
2653 GetSystemDirectoryW(def_val, MAX_PATH);
2654 strcpyW( def_val + 3, L"Users\\Public" );
2655
2656 hr = _SHGetProfilesValue(key, L"Public", szAllUsers, def_val);
2657 PathAppendW(szDest, szAllUsers);
2658 PathAppendW(szDest, szTemp + ARRAY_SIZE(L"%PUBLIC%")-1);
2659 }
2660#endif
2661 else if (!strncmpiW(szTemp, L"%USERPROFILE%", ARRAY_SIZE(L"%USERPROFILE%")-1))
2662 {
2663#ifndef __REACTOS__
2665 DWORD userLen = MAX_PATH;
2666
2667 strcpyW(szDest, szProfilesPrefix);
2668 GetUserNameW(userName, &userLen);
2669 PathAppendW(szDest, userName);
2670#else
2671 DWORD cchSize = cchDest;
2672 if (!_SHGetUserProfileDirectoryW(hToken, szDest, &cchSize))
2673 goto fallback_expand;
2674#endif
2675 PathAppendW(szDest, szTemp + ARRAY_SIZE(L"%USERPROFILE%")-1);
2676 }
2677 else if (!strncmpiW(szTemp, L"%SystemDrive%", ARRAY_SIZE(L"%SystemDrive%")-1))
2678 {
2679#ifndef __REACTOS__
2681#else
2682 if (!GetSystemDirectoryW(szDest, cchDest))
2683 goto fallback_expand;
2684#endif
2685 strcpyW(szDest + 3, szTemp + ARRAY_SIZE(L"%SystemDrive%")-1 + 1);
2686 }
2687 else
2688#ifdef __REACTOS__
2689fallback_expand:
2690#endif
2691 {
2692#ifndef __REACTOS__
2693 DWORD ret = ExpandEnvironmentStringsW(szTemp, szDest, MAX_PATH);
2694#else
2695 DWORD ret = SHExpandEnvironmentStringsForUserW(hToken, szTemp, szDest, cchDest);
2696#endif
2697
2698#ifndef __REACTOS__
2699 if (ret > MAX_PATH)
2700#else
2701 if (ret > cchDest)
2702#endif
2704 else if (ret == 0)
2706 else if (!strcmpW( szTemp, szDest )) break; /* nothing expanded */
2707 }
2708 if (SUCCEEDED(hr)) strcpyW(szTemp, szDest);
2709 }
2710end:
2711#ifndef __REACTOS__
2712 if (key)
2714#endif
2715 TRACE("returning 0x%08x (input was %s, output is %s)\n", hr,
2716 debugstr_w(szSrc), debugstr_w(szDest));
2717 return hr;
2718}
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:2523
static HRESULT _SHGetProfilesValue(HKEY profilesKey, LPCWSTR szValueName, LPWSTR szValue, LPCWSTR szDefault)
Definition: shellpath.c:2538
BOOL _SHGetUserProfileDirectoryW(HANDLE hToken, LPWSTR szPath, LPDWORD lpcchPath)
Definition: shellpath.c:2132
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 2483 of file shellpath.c.

2485{
2486 HRESULT hr;
2487
2488 TRACE("0x%08x,0x%02x,%p\n", dwFlags, folder, pszPath);
2489
2491 return E_INVALIDARG;
2493 return E_INVALIDARG;
2494 if (!pszPath)
2495 return E_INVALIDARG;
2496
2498#ifndef __REACTOS__
2499 hr = _SHGetDefaultValue(folder, pszPath);
2500#else
2501 hr = _SHGetDefaultValue(NULL, folder, pszPath);
2502#endif
2503 else
2504 {
2505#ifndef __REACTOS__
2507#else
2509#endif
2510 CSIDL_Data[folder].szValueName, pszPath);
2511 if (FAILED(hr))
2512#ifndef __REACTOS__
2513 hr = _SHGetDefaultValue(folder, pszPath);
2514#else
2515 hr = _SHGetDefaultValue(NULL, folder, pszPath);
2516#endif
2517 }
2518 TRACE("returning 0x%08x (output path is %s)\n", hr, debugstr_w(pszPath));
2519 return hr;
2520}
static HRESULT _SHGetDefaultValue(BYTE folder, LPWSTR pszPath)
Definition: shellpath.c:2168
static const CSIDL_DATA CSIDL_Data[]
Definition: shellpath.c:1225
static HRESULT _SHGetUserShellFolderPath(HKEY rootKey, LPCWSTR userPrefix, LPCWSTR value, LPWSTR path)
Definition: shellpath.c:2049
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 2284 of file shellpath.c.

2286{
2287 HRESULT hr;
2288
2289 TRACE("0x%08x,0x%02x,%p\n", dwFlags, folder, pszPath);
2290
2292 return E_INVALIDARG;
2294 return E_INVALIDARG;
2295 if (!pszPath)
2296 return E_INVALIDARG;
2297
2299#ifndef __REACTOS__
2300 hr = _SHGetDefaultValue(folder, pszPath);
2301#else
2302 hr = _SHGetDefaultValue(NULL, folder, pszPath);
2303#endif
2304 else
2305 {
2306 HKEY hKey;
2307
2308 if (RegCreateKeyW(HKEY_LOCAL_MACHINE, L"Software\\Microsoft\\Windows\\CurrentVersion", &hKey))
2309 hr = E_FAIL;
2310 else
2311 {
2312 DWORD dwType, dwPathLen = MAX_PATH * sizeof(WCHAR);
2313
2314 if (RegQueryValueExW(hKey, CSIDL_Data[folder].szValueName, NULL,
2315 &dwType, (LPBYTE)pszPath, &dwPathLen) ||
2316 (dwType != REG_SZ && dwType != REG_EXPAND_SZ))
2317 {
2318#ifndef __REACTOS__
2319 hr = _SHGetDefaultValue(folder, pszPath);
2320#else
2321 hr = _SHGetDefaultValue(NULL, folder, pszPath);
2322#endif
2323 dwType = REG_EXPAND_SZ;
2324 switch (folder)
2325 {
2328 /* these two should never be set on 32-bit setups */
2329 if (!is_win64)
2330 {
2331 BOOL is_wow64;
2333 if (!is_wow64) break;
2334 }
2335 /* fall through */
2336 default:
2337 RegSetValueExW(hKey, CSIDL_Data[folder].szValueName, 0, dwType,
2338 (LPBYTE)pszPath, (strlenW(pszPath)+1)*sizeof(WCHAR));
2339 }
2340 }
2341 else
2342 {
2343 pszPath[dwPathLen / sizeof(WCHAR)] = '\0';
2344 hr = S_OK;
2345 }
2347 }
2348 }
2349 TRACE("returning 0x%08x (output path is %s)\n", hr, debugstr_w(pszPath));
2350 return hr;
2351}
#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 2168 of file shellpath.c.

2172{
2173 HRESULT hr;
2174 WCHAR resourcePath[MAX_PATH];
2175#ifdef __REACTOS__
2176 NT_PRODUCT_TYPE ProductType;
2177#endif
2178
2179 TRACE("0x%02x,%p\n", folder, pszPath);
2180
2182 return E_INVALIDARG;
2183
2184 if (!pszPath)
2185 return E_INVALIDARG;
2186
2187#ifdef __REACTOS__
2188 if (hToken != NULL && hToken != (HANDLE)-1)
2189 {
2190 FIXME("unsupported for user other than current or default\n");
2191 }
2192#endif
2193
2194 if (!is_win64)
2195 {
2196 BOOL is_wow64;
2197
2198 switch (folder)
2199 {
2204 break;
2209 break;
2210 }
2211 }
2212
2213 switch (CSIDL_Data[folder].type)
2214 {
2215 case CSIDL_Type_User:
2216 strcpyW(pszPath, L"%USERPROFILE%");
2217 break;
2218#ifdef __REACTOS__
2219 case CSIDL_Type_InMyDocuments:
2220 strcpyW(pszPath, L"%USERPROFILE%");
2221 if (DoGetProductType(&ProductType) && ProductType == NtProductWinNt)
2222 {
2223 if (IS_INTRESOURCE(CSIDL_Data[CSIDL_MYDOCUMENTS].szDefaultPath))
2224 {
2225 WCHAR szItem[MAX_PATH];
2227 LOWORD(CSIDL_Data[CSIDL_MYDOCUMENTS].szDefaultPath),
2228 szItem, ARRAY_SIZE(szItem));
2229 PathAppendW(pszPath, szItem);
2230 }
2231 else
2232 {
2233 PathAppendW(pszPath, CSIDL_Data[CSIDL_MYDOCUMENTS].szDefaultPath);
2234 }
2235 }
2236 break;
2237#endif
2239#ifndef __REACTOS__
2240 strcpyW(pszPath, L"%PUBLIC%");
2241#else
2242 strcpyW(pszPath, L"%ALLUSERSPROFILE%");
2243#endif
2244 break;
2245 case CSIDL_Type_CurrVer:
2246 strcpyW(pszPath, L"%SystemDrive%");
2247 break;
2248 default:
2249 ; /* no corresponding env. var, do nothing */
2250 }
2251
2252 hr = S_OK;
2253 if (CSIDL_Data[folder].szDefaultPath)
2254 {
2255 if (IS_INTRESOURCE(CSIDL_Data[folder].szDefaultPath))
2256 {
2258 LOWORD(CSIDL_Data[folder].szDefaultPath), resourcePath, MAX_PATH))
2259 {
2260 PathAppendW(pszPath, resourcePath);
2261 }
2262 else
2263 {
2264 ERR("(%d,%s), LoadString failed, missing translation?\n", folder,
2265 debugstr_w(pszPath));
2266 hr = E_FAIL;
2267 }
2268 }
2269 else
2270 {
2271 PathAppendW(pszPath, CSIDL_Data[folder].szDefaultPath);
2272 }
2273 }
2274 TRACE("returning 0x%08x\n", hr);
2275 return hr;
2276}
#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 2538 of file shellpath.c.

2540{
2541 HRESULT hr;
2542 DWORD type, dwPathLen = MAX_PATH * sizeof(WCHAR);
2543 LONG lRet;
2544
2545 TRACE("%p,%s,%p,%s\n", profilesKey, debugstr_w(szValueName), szValue,
2546 debugstr_w(szDefault));
2547 lRet = RegQueryValueExW(profilesKey, szValueName, NULL, &type,
2548 (LPBYTE)szValue, &dwPathLen);
2549 if (!lRet && (type == REG_SZ || type == REG_EXPAND_SZ) && dwPathLen
2550 && *szValue)
2551 {
2552 dwPathLen /= sizeof(WCHAR);
2553 szValue[dwPathLen] = '\0';
2554 hr = S_OK;
2555 }
2556 else
2557 {
2558 /* Missing or invalid value, set a default */
2559 lstrcpynW(szValue, szDefault, MAX_PATH);
2560 TRACE("Setting missing value %s to %s\n", debugstr_w(szValueName),
2561 debugstr_w(szValue));
2562 lRet = RegSetValueExW(profilesKey, szValueName, 0, REG_EXPAND_SZ,
2563 (LPBYTE)szValue,
2564 (strlenW(szValue) + 1) * sizeof(WCHAR));
2565 if (lRet)
2566 hr = HRESULT_FROM_WIN32(lRet);
2567 else
2568 hr = S_OK;
2569 }
2570 TRACE("returning 0x%08x (output value is %s)\n", hr, debugstr_w(szValue));
2571 return hr;
2572}
#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 2132 of file shellpath.c.

2133{
2134 BOOL result;
2135 if (!hToken)
2136 {
2138 result = GetUserProfileDirectoryW(hToken, szPath, lpcchPath);
2139 CloseHandle(hToken);
2140 }
2141 else if ((INT) hToken == -1)
2142 {
2144 }
2145 else
2146 {
2147 result = GetUserProfileDirectoryW(hToken, szPath, lpcchPath);
2148 }
2149 TRACE("_SHGetUserProfileDirectoryW returning %S\n", szPath);
2150 return result;
2151}
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 2394 of file shellpath.c.

2396{
2397 const WCHAR *szValueName;
2398 WCHAR buffer[40];
2399 HRESULT hr;
2400
2401 TRACE("%p,0x%08x,0x%02x,%p\n", hToken, dwFlags, folder, pszPath);
2402
2404 return E_INVALIDARG;
2405#ifdef __REACTOS__
2407 CSIDL_Data[folder].type != CSIDL_Type_InMyDocuments)
2408#else
2410#endif
2411 {
2412 return E_INVALIDARG;
2413 }
2414 if (!pszPath)
2415 return E_INVALIDARG;
2416
2418 {
2419#ifndef __REACTOS__
2420 hr = _SHGetDefaultValue(folder, pszPath);
2421#else
2422 hr = _SHGetDefaultValue(hToken, folder, pszPath);
2423#endif
2424 }
2425 else
2426 {
2427 static const WCHAR DefaultW[] = L".Default";
2428 LPCWSTR userPrefix = NULL;
2429 HKEY hRootKey;
2430
2431 if (hToken == (HANDLE)-1)
2432 {
2433 hRootKey = HKEY_USERS;
2434 userPrefix = DefaultW;
2435 }
2436 else if (hToken == NULL)
2437 hRootKey = HKEY_CURRENT_USER;
2438 else
2439 {
2440 hRootKey = HKEY_USERS;
2441 userPrefix = _GetUserSidStringFromToken(hToken);
2442 if (userPrefix == NULL)
2443 {
2444 hr = E_FAIL;
2445 goto error;
2446 }
2447 }
2448
2449 /* For CSIDL_Type_User we also use the GUID if no szValueName is provided */
2450 szValueName = CSIDL_Data[folder].szValueName;
2451 if (!szValueName)
2452 {
2454 szValueName = &buffer[0];
2455 }
2456
2457#ifndef __REACTOS__
2458 hr = _SHGetUserShellFolderPath(hRootKey, userPrefix, szValueName, pszPath);
2459 if (FAILED(hr) && hRootKey != HKEY_LOCAL_MACHINE)
2460 hr = _SHGetUserShellFolderPath(HKEY_LOCAL_MACHINE, NULL, szValueName, pszPath);
2461 if (FAILED(hr))
2462 hr = _SHGetDefaultValue(folder, pszPath);
2463#else
2464 hr = _SHGetUserShellFolderPath(hRootKey, hToken, userPrefix, szValueName, pszPath);
2465 if (FAILED(hr) && hRootKey != HKEY_LOCAL_MACHINE)
2466 hr = _SHGetUserShellFolderPath(HKEY_LOCAL_MACHINE, hToken, NULL, szValueName, pszPath);
2467 if (FAILED(hr))
2468 hr = _SHGetDefaultValue(hToken, folder, pszPath);
2469#endif
2470 if (userPrefix != NULL && userPrefix != DefaultW)
2471 LocalFree((HLOCAL) userPrefix);
2472 }
2473error:
2474 TRACE("returning 0x%08x (output path is %s)\n", hr, debugstr_w(pszPath));
2475 return hr;
2476}
INT WINAPI StringFromGUID2(REFGUID id, LPOLESTR str, INT cmax)
Definition: compobj.c:2434
static LPWSTR _GetUserSidStringFromToken(HANDLE Token)
Definition: shellpath.c:2353
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 2049 of file shellpath.c.

2054{
2055 HRESULT hr;
2056 WCHAR shellFolderPath[MAX_PATH], userShellFolderPath[MAX_PATH];
2057 LPCWSTR pShellFolderPath, pUserShellFolderPath;
2058 HKEY userShellFolderKey, shellFolderKey;
2059 DWORD dwType, dwPathLen;
2060
2061 TRACE("%p,%s,%s,%p\n",rootKey, debugstr_w(userPrefix), debugstr_w(value),
2062 path);
2063
2064 if (userPrefix)
2065 {
2066 strcpyW(shellFolderPath, userPrefix);
2067 PathAddBackslashW(shellFolderPath);
2068 strcatW(shellFolderPath, szSHFolders);
2069 pShellFolderPath = shellFolderPath;
2070 strcpyW(userShellFolderPath, userPrefix);
2071 PathAddBackslashW(userShellFolderPath);
2072 strcatW(userShellFolderPath, szSHUserFolders);
2073 pUserShellFolderPath = userShellFolderPath;
2074 }
2075 else
2076 {
2077 pUserShellFolderPath = szSHUserFolders;
2078 pShellFolderPath = szSHFolders;
2079 }
2080
2081 if (RegCreateKeyW(rootKey, pShellFolderPath, &shellFolderKey))
2082 {
2083 TRACE("Failed to create %s\n", debugstr_w(pShellFolderPath));
2084 return E_FAIL;
2085 }
2086 if (RegCreateKeyW(rootKey, pUserShellFolderPath, &userShellFolderKey))
2087 {
2088 TRACE("Failed to create %s\n",
2089 debugstr_w(pUserShellFolderPath));
2090 RegCloseKey(shellFolderKey);
2091 return E_FAIL;
2092 }
2093
2094 dwPathLen = MAX_PATH * sizeof(WCHAR);
2095 if (!RegQueryValueExW(userShellFolderKey, value, NULL, &dwType,
2096 (LPBYTE)path, &dwPathLen) && (dwType == REG_EXPAND_SZ || dwType == REG_SZ))
2097 {
2098 LONG ret;
2099
2100 path[dwPathLen / sizeof(WCHAR)] = '\0';
2101 if (dwType == REG_EXPAND_SZ && path[0] == '%')
2102 {
2103 WCHAR szTemp[MAX_PATH];
2104
2105#ifndef __REACTOS__
2107#else
2108 hr = _SHExpandEnvironmentStrings(hToken, path, szTemp, _countof(szTemp));
2109 if (FAILED(hr))
2110 goto end;
2111#endif
2112 lstrcpynW(path, szTemp, MAX_PATH);
2113 }
2114 ret = RegSetValueExW(shellFolderKey, value, 0, REG_SZ, (LPBYTE)path,
2115 (strlenW(path) + 1) * sizeof(WCHAR));
2116 if (ret != ERROR_SUCCESS)
2118 else
2119 hr = S_OK;
2120 }
2121 else
2122 hr = E_FAIL;
2123#ifdef __REACTOS__
2124end:
2125#endif
2126 RegCloseKey(shellFolderKey);
2127 RegCloseKey(userShellFolderKey);
2128 TRACE("returning 0x%08x\n", hr);
2129 return hr;
2130}
#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:2588
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 2523 of file shellpath.c.

2524{
2525 LONG lRet;
2526 DWORD disp;
2527
2528 lRet = RegCreateKeyExW(HKEY_LOCAL_MACHINE, L"Software\\Microsoft\\Windows NT\\CurrentVersion\\ProfileList", 0, NULL, 0,
2529 KEY_ALL_ACCESS, NULL, pKey, &disp);
2530 return HRESULT_FROM_WIN32(lRet);
2531}
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 3187 of file shellpath.c.

3188{
3189 static const UINT folders[] = {
3202 };
3203 HRESULT hr;
3204
3205 TRACE("\n");
3207 szSHFolders, folders, ARRAY_SIZE(folders));
3208 TRACE("returning 0x%08x\n", hr);
3209 return hr;
3210}
static HRESULT _SHRegisterFolders(HKEY hRootKey, HANDLE hToken, LPCWSTR szUserShellFolderPath, LPCWSTR szShellFolderPath, const UINT folders[], UINT foldersLen)
Definition: shellpath.c:3017
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 3017 of file shellpath.c.

3020{
3021 const WCHAR *szValueName;
3022 WCHAR buffer[40];
3023 UINT i;
3025 HRESULT hr = S_OK;
3026 HKEY hUserKey = NULL, hKey = NULL;
3027 DWORD dwType, dwPathLen;
3028 LONG ret;
3029
3030 TRACE("%p,%p,%s,%p,%u\n", hRootKey, hToken,
3031 debugstr_w(szUserShellFolderPath), folders, foldersLen);
3032
3033 ret = RegCreateKeyW(hRootKey, szUserShellFolderPath, &hUserKey);
3034 if (ret)
3036 else
3037 {
3038 ret = RegCreateKeyW(hRootKey, szShellFolderPath, &hKey);
3039 if (ret)
3041 }
3042 for (i = 0; SUCCEEDED(hr) && i < foldersLen; i++)
3043 {
3044 dwPathLen = MAX_PATH * sizeof(WCHAR);
3045
3046 /* For CSIDL_Type_User we also use the GUID if no szValueName is provided */
3047 szValueName = CSIDL_Data[folders[i]].szValueName;
3048#ifdef __REACTOS__
3049 if (!szValueName &&
3050 (CSIDL_Data[folders[i]].type == CSIDL_Type_User ||
3051 CSIDL_Data[folders[i]].type == CSIDL_Type_InMyDocuments))
3052#else
3053 if (!szValueName && CSIDL_Data[folders[i]].type == CSIDL_Type_User)
3054#endif
3055 {
3056 StringFromGUID2( CSIDL_Data[folders[i]].id, buffer, 39 );
3057 szValueName = &buffer[0];
3058 }
3059
3060 if (!RegQueryValueExW(hUserKey, szValueName, NULL,
3061 &dwType, (LPBYTE)path, &dwPathLen) &&
3062 (dwType == REG_SZ || dwType == REG_EXPAND_SZ))
3063 {
3065 hToken, SHGFP_TYPE_CURRENT, path);
3066 }
3067 else
3068 {
3069 *path = '\0';
3070#ifdef __REACTOS__
3071 if (CSIDL_Data[folders[i]].type == CSIDL_Type_User ||
3072 CSIDL_Data[folders[i]].type == CSIDL_Type_InMyDocuments)
3073#else
3074 if (CSIDL_Data[folders[i]].type == CSIDL_Type_User)
3075#endif
3076 _SHGetUserProfilePath(hToken, SHGFP_TYPE_CURRENT, folders[i],
3077 path);
3078 else if (CSIDL_Data[folders[i]].type == CSIDL_Type_AllUsers)
3080 else if (CSIDL_Data[folders[i]].type == CSIDL_Type_WindowsPath)
3081 {
3083 if (CSIDL_Data[folders[i]].szDefaultPath &&
3084 !IS_INTRESOURCE(CSIDL_Data[folders[i]].szDefaultPath))
3085 {
3087 strcatW(path, CSIDL_Data[folders[i]].szDefaultPath);
3088 }
3089 }
3090 else
3091 hr = E_FAIL;
3092 if (*path)
3093 {
3094 ret = RegSetValueExW(hUserKey, szValueName, 0, REG_EXPAND_SZ,
3095 (LPBYTE)path, (strlenW(path) + 1) * sizeof(WCHAR));
3096 if (ret)
3098 else
3099 {
3101 hToken, SHGFP_TYPE_CURRENT, path);
3102 ret = RegSetValueExW(hKey, szValueName, 0, REG_SZ,
3103 (LPBYTE)path, (strlenW(path) + 1) * sizeof(WCHAR));
3104 if (ret)
3106 }
3107 }
3108 }
3109 }
3110 if (hUserKey)
3111 RegCloseKey(hUserKey);
3112 if (hKey)
3114
3115 TRACE("returning 0x%08x\n", hr);
3116 return hr;
3117}
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:2740
static HRESULT _SHGetAllUsersProfilePath(DWORD dwFlags, BYTE folder, LPWSTR pszPath)
Definition: shellpath.c:2483
static HRESULT _SHGetUserProfilePath(HANDLE hToken, DWORD dwFlags, BYTE folder, LPWSTR pszPath)
Definition: shellpath.c:2394
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 3119 of file shellpath.c.

3120{
3121 static const UINT folders[] = {
3143/* Cannot use #if _WIN32_WINNT >= 0x0600 because _WIN32_WINNT == 0x0600 here. */
3144#ifndef __REACTOS__
3151#endif
3152 };
3153 WCHAR userShellFolderPath[MAX_PATH], shellFolderPath[MAX_PATH];
3154 LPCWSTR pUserShellFolderPath, pShellFolderPath;
3155 HRESULT hr = S_OK;
3156 HKEY hRootKey;
3157 HANDLE hToken;
3158
3159 TRACE("%s\n", bDefault ? "TRUE" : "FALSE");
3160 if (bDefault)
3161 {
3162 hToken = (HANDLE)-1;
3163 hRootKey = HKEY_USERS;
3164 strcpyW(userShellFolderPath, L".Default");
3165 PathAddBackslashW(userShellFolderPath);
3166 strcatW(userShellFolderPath, szSHUserFolders);
3167 pUserShellFolderPath = userShellFolderPath;
3168 strcpyW(shellFolderPath, L".Default");
3169 PathAddBackslashW(shellFolderPath);
3170 strcatW(shellFolderPath, szSHFolders);
3171 pShellFolderPath = shellFolderPath;
3172 }
3173 else
3174 {
3175 hToken = NULL;
3176 hRootKey = HKEY_CURRENT_USER;
3177 pUserShellFolderPath = szSHUserFolders;
3178 pShellFolderPath = szSHFolders;
3179 }
3180
3181 hr = _SHRegisterFolders(hRootKey, hToken, pUserShellFolderPath,
3182 pShellFolderPath, folders, ARRAY_SIZE(folders));
3183 TRACE("returning 0x%08x\n", hr);
3184 return hr;
3185}
#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:154

◆ 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:585
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:184

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 2010 of file shellpath.c.

2011{
2012 LPCWSTR pszPath, pchBackslash;
2014
2015 pchBackslash = StrChrW(pszStart, L'\\');
2016 if (pchBackslash)
2017 {
2018 *ppch = (LPWSTR)(pchBackslash + 1);
2019 *pcch = (pchBackslash - pszStart) + 1;
2020 StrCpyNW(szPath, pszStart, min(*pcch, _countof(szPath)));
2021 pszPath = szPath;
2022 }
2023 else
2024 {
2025 *ppch = NULL;
2026 *pcch = lstrlenW(pszStart);
2027 pszPath = pszStart;
2028 }
2029
2030 return SHGetSpecialFolderID(pszPath);
2031}
INT SHGetSpecialFolderID(_In_ LPCWSTR pszName)
Definition: shellpath.c:1996
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 3215 of file shellpath.c.

3216{
3217 HRESULT hr;
3218
3220 if (SUCCEEDED(hr))
3222 if (SUCCEEDED(hr))
3224 return hr;
3225}
static HRESULT _SHRegisterUserShellFolders(BOOL bDefault)
Definition: shellpath.c:3119
static HRESULT _SHRegisterCommonShellFolders(void)
Definition: shellpath.c:3187

Referenced by DllRegisterServer().

◆ SHGetFolderLocation()

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

Definition at line 3301 of file shellpath.c.

3307{
3309#ifdef __REACTOS__
3311#endif
3312
3313 TRACE("%p 0x%08x %p 0x%08x %p\n",
3314 hwndOwner, nFolder, hToken, dwReserved, ppidl);
3315
3316 if (!ppidl)
3317 return E_INVALIDARG;
3318 if (dwReserved)
3319 return E_INVALIDARG;
3320
3321#ifdef __REACTOS__
3322 if ((nFolder & CSIDL_FLAG_NO_ALIAS) &&
3324 {
3325 *ppidl = ILCreateFromPathW(szPath);
3326 if (*ppidl)
3327 return S_OK;
3328 }
3329#endif
3330 /* The virtual folders' locations are not user-dependent */
3331 *ppidl = NULL;
3332 switch (nFolder & CSIDL_FOLDER_MASK)
3333 {
3334 case CSIDL_DESKTOP:
3335 *ppidl = _ILCreateDesktop();
3336 break;
3337
3338 case CSIDL_PERSONAL:
3339 *ppidl = _ILCreateMyDocuments();
3340 break;
3341
3342 case CSIDL_INTERNET:
3343 *ppidl = _ILCreateIExplore();
3344 break;
3345
3346 case CSIDL_CONTROLS:
3347 *ppidl = _ILCreateControlPanel();
3348 break;
3349
3350 case CSIDL_PRINTERS:
3351 *ppidl = _ILCreatePrinters();
3352 break;
3353
3354 case CSIDL_BITBUCKET:
3355 *ppidl = _ILCreateBitBucket();
3356 break;
3357
3358 case CSIDL_DRIVES:
3359 *ppidl = _ILCreateMyComputer();
3360 break;
3361
3362 case CSIDL_NETWORK:
3363 *ppidl = _ILCreateNetwork();
3364 break;
3365
3366#ifdef __REACTOS__
3367 case CSIDL_CONNECTIONS:
3368 hr = SHGetFolderLocationHelper(hwndOwner, CSIDL_CONTROLS, &CLSID_NetworkConnections, ppidl);
3369 break;
3370#endif
3371
3372 default:
3373 {
3375
3376 hr = SHGetFolderPathW(hwndOwner, nFolder, hToken,
3378 if (SUCCEEDED(hr))
3379 {
3380 DWORD attributes=0;
3381
3382 TRACE("Value=%s\n", debugstr_w(szPath));
3383 hr = SHILCreateFromPathW(szPath, ppidl, &attributes);
3384 }
3386 {
3387 /* unlike SHGetFolderPath, SHGetFolderLocation in shell32
3388 * version 6.0 returns E_FAIL for nonexistent paths
3389 */
3390 hr = E_FAIL;
3391 }
3392 }
3393 }
3394 if(*ppidl)
3395 hr = S_OK;
3396
3397 TRACE("-- (new pidl %p)\n",*ppidl);
3398 return hr;
3399}
BOOL WINAPI SHGetSpecialFolderPathW(HWND hwndOwner, LPWSTR szPath, int nFolder, BOOL bCreate)
Definition: shellpath.c:3243
_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:1763
LPITEMIDLIST _ILCreateIExplore(void)
Definition: pidl.c:1775
HRESULT WINAPI SHILCreateFromPathW(LPCWSTR path, LPITEMIDLIST *ppidl, DWORD *attributes)
Definition: pidl.c:403
LPITEMIDLIST _ILCreateDesktop(void)
Definition: pidl.c:1752
LPITEMIDLIST _ILCreateNetwork(void)
Definition: pidl.c:1826
LPITEMIDLIST _ILCreatePrinters(void)
Definition: pidl.c:1799
LPITEMIDLIST _ILCreateControlPanel(void)
Definition: pidl.c:1781
LPITEMIDLIST WINAPI ILCreateFromPathW(LPCWSTR path)
Definition: pidl.c:1101
LPITEMIDLIST _ILCreateMyDocuments(void)
Definition: pidl.c:1769
LPITEMIDLIST _ILCreateBitBucket(void)
Definition: pidl.c:1832
#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 2987 of file shellpath.c.

2993{
2994 WCHAR szTemp[MAX_PATH];
2995 HRESULT hr;
2996
2997 TRACE("%p,%d,%p,%#x,%p\n", hwndOwner, nFolder, hToken, dwFlags, pszPath);
2998
2999 if (pszPath)
3000 *pszPath = '\0';
3001 hr = SHGetFolderPathW(hwndOwner, nFolder, hToken, dwFlags, szTemp);
3002 if (SUCCEEDED(hr) && pszPath)
3003 WideCharToMultiByte(CP_ACP, 0, szTemp, -1, pszPath, MAX_PATH, NULL,
3004 NULL);
3005
3006 return hr;
3007}
#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 2753 of file shellpath.c.

2760{
2761 int length;
2762 HRESULT hr = S_OK;
2763 LPWSTR pszSubPathW = NULL;
2764 LPWSTR pszPathW = NULL;
2765
2766 TRACE("%p,%#x,%p,%#x,%s,%p\n", hwndOwner, nFolder, hToken, dwFlags, debugstr_a(pszSubPath), pszPath);
2767
2768 if(pszPath) {
2769 pszPathW = HeapAlloc(GetProcessHeap(), 0, MAX_PATH * sizeof(WCHAR));
2770 if(!pszPathW) {
2772 goto cleanup;
2773 }
2774 }
2775 TRACE("%08x,%08x,%s\n",nFolder, dwFlags, debugstr_w(pszSubPathW));
2776
2777 /* SHGetFolderPathAndSubDirW does not distinguish if pszSubPath isn't
2778 * set (null), or an empty string.therefore call it without the parameter set
2779 * if pszSubPath is an empty string
2780 */
2781 if (pszSubPath && pszSubPath[0]) {
2782 length = MultiByteToWideChar(CP_ACP, 0, pszSubPath, -1, NULL, 0);
2783 pszSubPathW = HeapAlloc(GetProcessHeap(), 0, length * sizeof(WCHAR));
2784 if(!pszSubPathW) {
2786 goto cleanup;
2787 }
2788 MultiByteToWideChar(CP_ACP, 0, pszSubPath, -1, pszSubPathW, length);
2789 }
2790
2791 hr = SHGetFolderPathAndSubDirW(hwndOwner, nFolder, hToken, dwFlags, pszSubPathW, pszPathW);
2792
2793 if (SUCCEEDED(hr) && pszPath)
2794 WideCharToMultiByte(CP_ACP, 0, pszPathW, -1, pszPath, MAX_PATH, NULL, NULL);
2795
2796cleanup:
2797 HeapFree(GetProcessHeap(), 0, pszPathW);
2798 HeapFree(GetProcessHeap(), 0, pszSubPathW);
2799 return hr;
2800}
#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:2805

Referenced by test_SHGetFolderPathAndSubDirA().

◆ SHGetFolderPathAndSubDirW()

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

Definition at line 2805 of file shellpath.c.

2812{
2813 HRESULT hr;
2814 WCHAR szBuildPath[MAX_PATH], szTemp[MAX_PATH];
2817 int ret;
2818
2819 TRACE("%p,%#x,%p,%#x,%s,%p\n", hwndOwner, nFolder, hToken, dwFlags, debugstr_w(pszSubPath), pszPath);
2820
2821 /* Windows always NULL-terminates the resulting path regardless of success
2822 * or failure, so do so first
2823 */
2824 if (pszPath)
2825 *pszPath = '\0';
2826
2828 return E_INVALIDARG;
2830 return E_INVALIDARG;
2831 szTemp[0] = 0;
2833 switch (type)
2834 {
2836 hr = E_INVALIDARG;
2837 break;
2839 hr = S_FALSE;
2840 break;
2843 if (CSIDL_Data[folder].szDefaultPath &&
2844 !IS_INTRESOURCE(CSIDL_Data[folder].szDefaultPath) &&
2845 *CSIDL_Data[folder].szDefaultPath)
2846 {
2847 PathAddBackslashW(szTemp);
2848 strcatW(szTemp, CSIDL_Data[folder].szDefaultPath);
2849 }
2850 hr = S_OK;
2851 break;
2854 if (CSIDL_Data[folder].szDefaultPath &&
2855 !IS_INTRESOURCE(CSIDL_Data[folder].szDefaultPath) &&
2856 *CSIDL_Data[folder].szDefaultPath)
2857 {
2858 PathAddBackslashW(szTemp);
2859 strcatW(szTemp, CSIDL_Data[folder].szDefaultPath);
2860 }
2861 hr = S_OK;
2862 break;
2865 if (CSIDL_Data[folder].szDefaultPath &&
2866 !IS_INTRESOURCE(CSIDL_Data[folder].szDefaultPath) &&
2867 *CSIDL_Data[folder].szDefaultPath)
2868 {
2869 PathAddBackslashW(szTemp);
2870 strcatW(szTemp, CSIDL_Data[folder].szDefaultPath);
2871 }
2872 hr = S_OK;
2873 break;
2874 case CSIDL_Type_CurrVer:
2876 break;
2877 case CSIDL_Type_User:
2878#ifdef __REACTOS__
2879 case CSIDL_Type_InMyDocuments:
2880#endif
2881 hr = _SHGetUserProfilePath(hToken, dwFlags, folder, szTemp);
2882 break;
2885 break;
2886 default:
2887 FIXME("bogus type %d, please fix\n", type);
2888 hr = E_INVALIDARG;
2889 break;
2890 }
2891
2892 /* Expand environment strings if necessary */
2893 if (*szTemp == '%')
2894#ifndef __REACTOS__
2895 hr = _SHExpandEnvironmentStrings(szTemp, szBuildPath);
2896#else
2897 hr = _SHExpandEnvironmentStrings(hToken, szTemp, szBuildPath, _countof(szBuildPath));
2898#endif
2899 else
2900 strcpyW(szBuildPath, szTemp);
2901
2902 if (FAILED(hr)) goto end;
2903
2904 if(pszSubPath) {
2905 /* make sure the new path does not exceed the buffer length
2906 * and remember to backslash and terminate it */
2907 if(MAX_PATH < (lstrlenW(szBuildPath) + lstrlenW(pszSubPath) + 2)) {
2909 goto end;
2910 }
2911 PathAppendW(szBuildPath, pszSubPath);
2912 PathRemoveBackslashW(szBuildPath);
2913 }
2914 /* Copy the path if it's available before we might return */
2915 if (SUCCEEDED(hr) && pszPath)
2916 strcpyW(pszPath, szBuildPath);
2917
2918 /* if we don't care about existing directories we are ready */
2920
2921 if (PathFileExistsW(szBuildPath)) goto end;
2922
2923 /* not existing but we are not allowed to create it. The return value
2924 * is verified against shell32 version 6.0.
2925 */
2926 if (!(nFolder & CSIDL_FLAG_CREATE))
2927 {
2929 goto end;
2930 }
2931
2932 /* create directory/directories */
2933 ret = SHCreateDirectoryExW(hwndOwner, szBuildPath, NULL);
2934 if (ret && ret != ERROR_ALREADY_EXISTS)
2935 {
2936 ERR("Failed to create directory %s.\n", debugstr_w(szBuildPath));
2937 hr = E_FAIL;
2938 goto end;
2939 }
2940
2941 TRACE("Created missing system directory %s\n", debugstr_w(szBuildPath));
2942
2943end:
2944#ifdef __REACTOS__
2945 /* create desktop.ini for custom icon */
2946 if ((nFolder & CSIDL_FLAG_CREATE) &&
2947 CSIDL_Data[folder].nShell32IconIndex)
2948 {
2949 WCHAR szIconLocation[MAX_PATH];
2951
2952 /* make the directory a read-only folder */
2953 dwAttributes = GetFileAttributesW(szBuildPath);
2955 SetFileAttributesW(szBuildPath, dwAttributes);
2956
2957 /* build the desktop.ini file path */
2958 PathAppendW(szBuildPath, L"desktop.ini");
2959
2960 /* build the icon location */
2961 StringCchPrintfW(szIconLocation, _countof(szIconLocation),
2962 L"%%SystemRoot%%\\system32\\shell32.dll,%d",
2963 CSIDL_Data[folder].nShell32IconIndex);
2964
2965 /* write desktop.ini */
2966 WritePrivateProfileStringW(L".ShellClassInfo", L"IconResource", szIconLocation, szBuildPath);
2967
2968 /* flush! */
2969 WritePrivateProfileStringW(NULL, NULL, NULL, szBuildPath);
2970
2971 /* make the desktop.ini a system and hidden file */
2972 dwAttributes = GetFileAttributesW(szBuildPath);
2974 SetFileAttributesW(szBuildPath, dwAttributes);
2975 }
2976#endif
2977
2978 TRACE("returning 0x%08x (final path is %s)\n", hr, debugstr_w(szBuildPath));
2979 return hr;
2980}
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:2284
#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 1996 of file shellpath.c.

1997{
1998 UINT csidl;
1999
2000 for (csidl = 0; csidl < _countof(CSIDL_Data); ++csidl)
2001 {
2002 const CSIDL_DATA *pData = &CSIDL_Data[csidl];
2003 if (pData->szValueName && lstrcmpiW(pszName, pData->szValueName) == 0)
2004 return csidl;
2005 }
2006
2007 return -1;
2008}
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 3408 of file shellpath.c.

3412{
3414
3415 TRACE("(%p,0x%x,%p)\n", hwndOwner,nFolder,ppidl);
3416
3417 if (!ppidl)
3418 return E_INVALIDARG;
3419
3420 hr = SHGetFolderLocation(hwndOwner, nFolder, NULL, 0, ppidl);
3421 return hr;
3422}
HRESULT WINAPI SHGetFolderLocation(HWND hwndOwner, int nFolder, HANDLE hToken, DWORD dwReserved, LPITEMIDLIST *ppidl)
Definition: shellpath.c:3301

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 3230 of file shellpath.c.

3235{
3236 return SHGetFolderPathA(hwndOwner, nFolder + (bCreate ? CSIDL_FLAG_CREATE : 0), NULL, 0,
3237 szPath) == S_OK;
3238}
HRESULT WINAPI SHGetFolderPathA(HWND hwndOwner, int nFolder, HANDLE hToken, DWORD dwFlags, LPSTR pszPath)
Definition: shellpath.c:2987
_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