ReactOS 0.4.16-dev-401-g45b008d
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 1060 of file shellpath.c.

◆ CSIDL_CONTACTS

#define CSIDL_CONTACTS   0x0043

Definition at line 1057 of file shellpath.c.

◆ CSIDL_DOWNLOADS

#define CSIDL_DOWNLOADS   0x0047

Definition at line 1058 of file shellpath.c.

◆ CSIDL_LINKS

#define CSIDL_LINKS   0x004d

Definition at line 1059 of file shellpath.c.

◆ CSIDL_SAVED_GAMES

#define CSIDL_SAVED_GAMES   0x0062

Definition at line 1061 of file shellpath.c.

◆ CSIDL_SEARCHES

#define CSIDL_SEARCHES   0x0063

Definition at line 1062 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:4326
#define PATH_CHAR_CLASS_COLON
Definition: path.c:4322
#define PATH_CHAR_CLASS_BACKSLASH
Definition: path.c:4321
#define PATH_CHAR_CLASS_DOT
Definition: path.c:4320

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

1041 {
1043#ifdef __REACTOS__
1044 CSIDL_Type_InMyDocuments,
1045#endif
1053} CSIDL_Type;
enum _CSIDL_Type CSIDL_Type
@ CSIDL_Type_CurrVer
Definition: shellpath.c:1047
@ CSIDL_Type_AllUsers
Definition: shellpath.c:1046
@ CSIDL_Type_WindowsPath
Definition: shellpath.c:1050
@ CSIDL_Type_Disallowed
Definition: shellpath.c:1048
@ CSIDL_Type_SystemX86Path
Definition: shellpath.c:1052
@ CSIDL_Type_SystemPath
Definition: shellpath.c:1051
@ CSIDL_Type_User
Definition: shellpath.c:1042
@ CSIDL_Type_NonExistent
Definition: shellpath.c:1049

◆ _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 2202 of file shellpath.c.

2203{
2204 char InfoBuffer[64];
2205 PTOKEN_USER UserInfo;
2206 DWORD InfoSize;
2207 LPWSTR SidStr;
2208
2209 UserInfo = (PTOKEN_USER) InfoBuffer;
2210 if (! GetTokenInformation(Token, TokenUser, InfoBuffer, sizeof(InfoBuffer),
2211 &InfoSize))
2212 {
2214 return NULL;
2215 UserInfo = HeapAlloc(GetProcessHeap(), 0, InfoSize);
2216 if (UserInfo == NULL)
2217 return NULL;
2218 if (! GetTokenInformation(Token, TokenUser, UserInfo, InfoSize,
2219 &InfoSize))
2220 {
2221 HeapFree(GetProcessHeap(), 0, UserInfo);
2222 return NULL;
2223 }
2224 }
2225
2226 if (! ConvertSidToStringSidW(UserInfo->User.Sid, &SidStr))
2227 SidStr = NULL;
2228
2229 if (UserInfo != (PTOKEN_USER) InfoBuffer)
2230 HeapFree(GetProcessHeap(), 0, UserInfo);
2231
2232 return SidStr;
2233}
#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 2437 of file shellpath.c.

2441{
2442 HRESULT hr;
2443#ifndef __REACTOS__
2444 WCHAR szTemp[MAX_PATH], szProfilesPrefix[MAX_PATH] = { 0 };
2445 HKEY key = NULL;
2446#else
2447 WCHAR szTemp[MAX_PATH];
2448#endif
2449
2450 TRACE("%s, %p\n", debugstr_w(szSrc), szDest);
2451
2452 if (!szSrc || !szDest) return E_INVALIDARG;
2453
2454 /* short-circuit if there's nothing to expand */
2455 if (szSrc[0] != '%')
2456 {
2457 strcpyW(szDest, szSrc);
2458 hr = S_OK;
2459 goto end;
2460 }
2461#ifndef __REACTOS__
2462 /* Get the profile prefix, we'll probably be needing it */
2464 if (SUCCEEDED(hr))
2465 {
2466 WCHAR def_val[MAX_PATH];
2467
2468 /* get the system drive */
2469 GetSystemDirectoryW(def_val, MAX_PATH);
2470 strcpyW( def_val + 3, L"Users" );
2471
2472 hr = _SHGetProfilesValue(key, L"ProfilesDirectory", szProfilesPrefix, def_val );
2473 }
2474#else
2475 hr = S_OK;
2476#endif
2477
2478 *szDest = 0;
2479 strcpyW(szTemp, szSrc);
2480 while (SUCCEEDED(hr) && szTemp[0] == '%')
2481 {
2482 if (!strncmpiW(szTemp, L"%ALLUSERSPROFILE%", ARRAY_SIZE(L"%ALLUSERSPROFILE%")-1))
2483 {
2484#ifndef __REACTOS__
2485 WCHAR szAllUsers[MAX_PATH];
2486
2487 strcpyW(szDest, szProfilesPrefix);
2488 hr = _SHGetProfilesValue(key, L"AllUsersProfile", szAllUsers, L"Public");
2489 PathAppendW(szDest, szAllUsers);
2490#else
2491 DWORD cchSize = cchDest;
2492 if (!GetAllUsersProfileDirectoryW(szDest, &cchSize))
2493 goto fallback_expand;
2494#endif
2495 PathAppendW(szDest, szTemp + ARRAY_SIZE(L"%ALLUSERSPROFILE%")-1);
2496 }
2497#ifndef __REACTOS__
2498 else if (!strncmpiW(szTemp, L"%PUBLIC%", ARRAY_SIZE(L"%PUBLIC%")-1))
2499 {
2500 WCHAR szAllUsers[MAX_PATH], def_val[MAX_PATH];
2501
2502 GetSystemDirectoryW(def_val, MAX_PATH);
2503 strcpyW( def_val + 3, L"Users\\Public" );
2504
2505 hr = _SHGetProfilesValue(key, L"Public", szAllUsers, def_val);
2506 PathAppendW(szDest, szAllUsers);
2507 PathAppendW(szDest, szTemp + ARRAY_SIZE(L"%PUBLIC%")-1);
2508 }
2509#endif
2510 else if (!strncmpiW(szTemp, L"%USERPROFILE%", ARRAY_SIZE(L"%USERPROFILE%")-1))
2511 {
2512#ifndef __REACTOS__
2514 DWORD userLen = MAX_PATH;
2515
2516 strcpyW(szDest, szProfilesPrefix);
2517 GetUserNameW(userName, &userLen);
2518 PathAppendW(szDest, userName);
2519#else
2520 DWORD cchSize = cchDest;
2521 if (!_SHGetUserProfileDirectoryW(hToken, szDest, &cchSize))
2522 goto fallback_expand;
2523#endif
2524 PathAppendW(szDest, szTemp + ARRAY_SIZE(L"%USERPROFILE%")-1);
2525 }
2526 else if (!strncmpiW(szTemp, L"%SystemDrive%", ARRAY_SIZE(L"%SystemDrive%")-1))
2527 {
2528#ifndef __REACTOS__
2530#else
2531 if (!GetSystemDirectoryW(szDest, cchDest))
2532 goto fallback_expand;
2533#endif
2534 strcpyW(szDest + 3, szTemp + ARRAY_SIZE(L"%SystemDrive%")-1 + 1);
2535 }
2536 else
2537#ifdef __REACTOS__
2538fallback_expand:
2539#endif
2540 {
2541#ifndef __REACTOS__
2542 DWORD ret = ExpandEnvironmentStringsW(szTemp, szDest, MAX_PATH);
2543#else
2544 DWORD ret = SHExpandEnvironmentStringsForUserW(hToken, szTemp, szDest, cchDest);
2545#endif
2546
2547#ifndef __REACTOS__
2548 if (ret > MAX_PATH)
2549#else
2550 if (ret > cchDest)
2551#endif
2553 else if (ret == 0)
2555 else if (!strcmpW( szTemp, szDest )) break; /* nothing expanded */
2556 }
2557 if (SUCCEEDED(hr)) strcpyW(szTemp, szDest);
2558 }
2559end:
2560#ifndef __REACTOS__
2561 if (key)
2563#endif
2564 TRACE("returning 0x%08x (input was %s, output is %s)\n", hr,
2565 debugstr_w(szSrc), debugstr_w(szDest));
2566 return hr;
2567}
#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:2372
static HRESULT _SHGetProfilesValue(HKEY profilesKey, LPCWSTR szValueName, LPWSTR szValue, LPCWSTR szDefault)
Definition: shellpath.c:2387
BOOL _SHGetUserProfileDirectoryW(HANDLE hToken, LPWSTR szPath, LPDWORD lpcchPath)
Definition: shellpath.c:1981
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 2332 of file shellpath.c.

2334{
2335 HRESULT hr;
2336
2337 TRACE("0x%08x,0x%02x,%p\n", dwFlags, folder, pszPath);
2338
2340 return E_INVALIDARG;
2342 return E_INVALIDARG;
2343 if (!pszPath)
2344 return E_INVALIDARG;
2345
2347#ifndef __REACTOS__
2348 hr = _SHGetDefaultValue(folder, pszPath);
2349#else
2350 hr = _SHGetDefaultValue(NULL, folder, pszPath);
2351#endif
2352 else
2353 {
2354#ifndef __REACTOS__
2356#else
2358#endif
2359 CSIDL_Data[folder].szValueName, pszPath);
2360 if (FAILED(hr))
2361#ifndef __REACTOS__
2362 hr = _SHGetDefaultValue(folder, pszPath);
2363#else
2364 hr = _SHGetDefaultValue(NULL, folder, pszPath);
2365#endif
2366 }
2367 TRACE("returning 0x%08x (output path is %s)\n", hr, debugstr_w(pszPath));
2368 return hr;
2369}
static HRESULT _SHGetDefaultValue(BYTE folder, LPWSTR pszPath)
Definition: shellpath.c:2017
static const CSIDL_DATA CSIDL_Data[]
Definition: shellpath.c:1074
static HRESULT _SHGetUserShellFolderPath(HKEY rootKey, LPCWSTR userPrefix, LPCWSTR value, LPWSTR path)
Definition: shellpath.c:1898
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
#define FAILED(hr)
Definition: intsafe.h:51
@ SHGFP_TYPE_DEFAULT
Definition: shlobj.h:2150
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 2133 of file shellpath.c.

2135{
2136 HRESULT hr;
2137
2138 TRACE("0x%08x,0x%02x,%p\n", dwFlags, folder, pszPath);
2139
2141 return E_INVALIDARG;
2143 return E_INVALIDARG;
2144 if (!pszPath)
2145 return E_INVALIDARG;
2146
2148#ifndef __REACTOS__
2149 hr = _SHGetDefaultValue(folder, pszPath);
2150#else
2151 hr = _SHGetDefaultValue(NULL, folder, pszPath);
2152#endif
2153 else
2154 {
2155 HKEY hKey;
2156
2157 if (RegCreateKeyW(HKEY_LOCAL_MACHINE, L"Software\\Microsoft\\Windows\\CurrentVersion", &hKey))
2158 hr = E_FAIL;
2159 else
2160 {
2161 DWORD dwType, dwPathLen = MAX_PATH * sizeof(WCHAR);
2162
2163 if (RegQueryValueExW(hKey, CSIDL_Data[folder].szValueName, NULL,
2164 &dwType, (LPBYTE)pszPath, &dwPathLen) ||
2165 (dwType != REG_SZ && dwType != REG_EXPAND_SZ))
2166 {
2167#ifndef __REACTOS__
2168 hr = _SHGetDefaultValue(folder, pszPath);
2169#else
2170 hr = _SHGetDefaultValue(NULL, folder, pszPath);
2171#endif
2172 dwType = REG_EXPAND_SZ;
2173 switch (folder)
2174 {
2177 /* these two should never be set on 32-bit setups */
2178 if (!is_win64)
2179 {
2180 BOOL is_wow64;
2182 if (!is_wow64) break;
2183 }
2184 /* fall through */
2185 default:
2186 RegSetValueExW(hKey, CSIDL_Data[folder].szValueName, 0, dwType,
2187 (LPBYTE)pszPath, (strlenW(pszPath)+1)*sizeof(WCHAR));
2188 }
2189 }
2190 else
2191 {
2192 pszPath[dwPathLen / sizeof(WCHAR)] = '\0';
2193 hr = S_OK;
2194 }
2196 }
2197 }
2198 TRACE("returning 0x%08x (output path is %s)\n", hr, debugstr_w(pszPath));
2199 return hr;
2200}
#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:2216
#define CSIDL_PROGRAM_FILESX86
Definition: shlobj.h:2214
unsigned char * LPBYTE
Definition: typedefs.h:53

Referenced by SHGetFolderPathAndSubDirW().

◆ _SHGetDefaultValue()

static HRESULT _SHGetDefaultValue ( BYTE  folder,
LPWSTR  pszPath 
)
static

Definition at line 2017 of file shellpath.c.

2021{
2022 HRESULT hr;
2023 WCHAR resourcePath[MAX_PATH];
2024#ifdef __REACTOS__
2025 NT_PRODUCT_TYPE ProductType;
2026#endif
2027
2028 TRACE("0x%02x,%p\n", folder, pszPath);
2029
2031 return E_INVALIDARG;
2032
2033 if (!pszPath)
2034 return E_INVALIDARG;
2035
2036#ifdef __REACTOS__
2037 if (hToken != NULL && hToken != (HANDLE)-1)
2038 {
2039 FIXME("unsupported for user other than current or default\n");
2040 }
2041#endif
2042
2043 if (!is_win64)
2044 {
2045 BOOL is_wow64;
2046
2047 switch (folder)
2048 {
2053 break;
2058 break;
2059 }
2060 }
2061
2062 switch (CSIDL_Data[folder].type)
2063 {
2064 case CSIDL_Type_User:
2065 strcpyW(pszPath, L"%USERPROFILE%");
2066 break;
2067#ifdef __REACTOS__
2068 case CSIDL_Type_InMyDocuments:
2069 strcpyW(pszPath, L"%USERPROFILE%");
2070 if (DoGetProductType(&ProductType) && ProductType == NtProductWinNt)
2071 {
2072 if (IS_INTRESOURCE(CSIDL_Data[CSIDL_MYDOCUMENTS].szDefaultPath))
2073 {
2074 WCHAR szItem[MAX_PATH];
2076 LOWORD(CSIDL_Data[CSIDL_MYDOCUMENTS].szDefaultPath),
2077 szItem, ARRAY_SIZE(szItem));
2078 PathAppendW(pszPath, szItem);
2079 }
2080 else
2081 {
2082 PathAppendW(pszPath, CSIDL_Data[CSIDL_MYDOCUMENTS].szDefaultPath);
2083 }
2084 }
2085 break;
2086#endif
2088#ifndef __REACTOS__
2089 strcpyW(pszPath, L"%PUBLIC%");
2090#else
2091 strcpyW(pszPath, L"%ALLUSERSPROFILE%");
2092#endif
2093 break;
2094 case CSIDL_Type_CurrVer:
2095 strcpyW(pszPath, L"%SystemDrive%");
2096 break;
2097 default:
2098 ; /* no corresponding env. var, do nothing */
2099 }
2100
2101 hr = S_OK;
2102 if (CSIDL_Data[folder].szDefaultPath)
2103 {
2104 if (IS_INTRESOURCE(CSIDL_Data[folder].szDefaultPath))
2105 {
2107 LOWORD(CSIDL_Data[folder].szDefaultPath), resourcePath, MAX_PATH))
2108 {
2109 PathAppendW(pszPath, resourcePath);
2110 }
2111 else
2112 {
2113 ERR("(%d,%s), LoadString failed, missing translation?\n", folder,
2114 debugstr_w(pszPath));
2115 hr = E_FAIL;
2116 }
2117 }
2118 else
2119 {
2120 PathAppendW(pszPath, CSIDL_Data[folder].szDefaultPath);
2121 }
2122 }
2123 TRACE("returning 0x%08x\n", hr);
2124 return hr;
2125}
#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:2210
#define CSIDL_MYDOCUMENTS
Definition: shlobj.h:2185
#define CSIDL_PROGRAM_FILES_COMMON
Definition: shlobj.h:2215
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 2387 of file shellpath.c.

2389{
2390 HRESULT hr;
2391 DWORD type, dwPathLen = MAX_PATH * sizeof(WCHAR);
2392 LONG lRet;
2393
2394 TRACE("%p,%s,%p,%s\n", profilesKey, debugstr_w(szValueName), szValue,
2395 debugstr_w(szDefault));
2396 lRet = RegQueryValueExW(profilesKey, szValueName, NULL, &type,
2397 (LPBYTE)szValue, &dwPathLen);
2398 if (!lRet && (type == REG_SZ || type == REG_EXPAND_SZ) && dwPathLen
2399 && *szValue)
2400 {
2401 dwPathLen /= sizeof(WCHAR);
2402 szValue[dwPathLen] = '\0';
2403 hr = S_OK;
2404 }
2405 else
2406 {
2407 /* Missing or invalid value, set a default */
2408 lstrcpynW(szValue, szDefault, MAX_PATH);
2409 TRACE("Setting missing value %s to %s\n", debugstr_w(szValueName),
2410 debugstr_w(szValue));
2411 lRet = RegSetValueExW(profilesKey, szValueName, 0, REG_EXPAND_SZ,
2412 (LPBYTE)szValue,
2413 (strlenW(szValue) + 1) * sizeof(WCHAR));
2414 if (lRet)
2415 hr = HRESULT_FROM_WIN32(lRet);
2416 else
2417 hr = S_OK;
2418 }
2419 TRACE("returning 0x%08x (output value is %s)\n", hr, debugstr_w(szValue));
2420 return hr;
2421}
#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 1981 of file shellpath.c.

1982{
1983 BOOL result;
1984 if (!hToken)
1985 {
1987 result = GetUserProfileDirectoryW(hToken, szPath, lpcchPath);
1988 CloseHandle(hToken);
1989 }
1990 else if ((INT) hToken == -1)
1991 {
1993 }
1994 else
1995 {
1996 result = GetUserProfileDirectoryW(hToken, szPath, lpcchPath);
1997 }
1998 TRACE("_SHGetUserProfileDirectoryW returning %S\n", szPath);
1999 return result;
2000}
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 2243 of file shellpath.c.

2245{
2246 const WCHAR *szValueName;
2247 WCHAR buffer[40];
2248 HRESULT hr;
2249
2250 TRACE("%p,0x%08x,0x%02x,%p\n", hToken, dwFlags, folder, pszPath);
2251
2253 return E_INVALIDARG;
2254#ifdef __REACTOS__
2256 CSIDL_Data[folder].type != CSIDL_Type_InMyDocuments)
2257#else
2259#endif
2260 {
2261 return E_INVALIDARG;
2262 }
2263 if (!pszPath)
2264 return E_INVALIDARG;
2265
2267 {
2268#ifndef __REACTOS__
2269 hr = _SHGetDefaultValue(folder, pszPath);
2270#else
2271 hr = _SHGetDefaultValue(hToken, folder, pszPath);
2272#endif
2273 }
2274 else
2275 {
2276 static const WCHAR DefaultW[] = L".Default";
2277 LPCWSTR userPrefix = NULL;
2278 HKEY hRootKey;
2279
2280 if (hToken == (HANDLE)-1)
2281 {
2282 hRootKey = HKEY_USERS;
2283 userPrefix = DefaultW;
2284 }
2285 else if (hToken == NULL)
2286 hRootKey = HKEY_CURRENT_USER;
2287 else
2288 {
2289 hRootKey = HKEY_USERS;
2290 userPrefix = _GetUserSidStringFromToken(hToken);
2291 if (userPrefix == NULL)
2292 {
2293 hr = E_FAIL;
2294 goto error;
2295 }
2296 }
2297
2298 /* For CSIDL_Type_User we also use the GUID if no szValueName is provided */
2299 szValueName = CSIDL_Data[folder].szValueName;
2300 if (!szValueName)
2301 {
2303 szValueName = &buffer[0];
2304 }
2305
2306#ifndef __REACTOS__
2307 hr = _SHGetUserShellFolderPath(hRootKey, userPrefix, szValueName, pszPath);
2308 if (FAILED(hr) && hRootKey != HKEY_LOCAL_MACHINE)
2309 hr = _SHGetUserShellFolderPath(HKEY_LOCAL_MACHINE, NULL, szValueName, pszPath);
2310 if (FAILED(hr))
2311 hr = _SHGetDefaultValue(folder, pszPath);
2312#else
2313 hr = _SHGetUserShellFolderPath(hRootKey, hToken, userPrefix, szValueName, pszPath);
2314 if (FAILED(hr) && hRootKey != HKEY_LOCAL_MACHINE)
2315 hr = _SHGetUserShellFolderPath(HKEY_LOCAL_MACHINE, hToken, NULL, szValueName, pszPath);
2316 if (FAILED(hr))
2317 hr = _SHGetDefaultValue(hToken, folder, pszPath);
2318#endif
2319 if (userPrefix != NULL && userPrefix != DefaultW)
2320 LocalFree((HLOCAL) userPrefix);
2321 }
2322error:
2323 TRACE("returning 0x%08x (output path is %s)\n", hr, debugstr_w(pszPath));
2324 return hr;
2325}
INT WINAPI StringFromGUID2(REFGUID id, LPOLESTR str, INT cmax)
Definition: compobj.c:2434
static LPWSTR _GetUserSidStringFromToken(HANDLE Token)
Definition: shellpath.c:2202
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:1069
#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 1898 of file shellpath.c.

1903{
1904 HRESULT hr;
1905 WCHAR shellFolderPath[MAX_PATH], userShellFolderPath[MAX_PATH];
1906 LPCWSTR pShellFolderPath, pUserShellFolderPath;
1907 HKEY userShellFolderKey, shellFolderKey;
1908 DWORD dwType, dwPathLen;
1909
1910 TRACE("%p,%s,%s,%p\n",rootKey, debugstr_w(userPrefix), debugstr_w(value),
1911 path);
1912
1913 if (userPrefix)
1914 {
1915 strcpyW(shellFolderPath, userPrefix);
1916 PathAddBackslashW(shellFolderPath);
1917 strcatW(shellFolderPath, szSHFolders);
1918 pShellFolderPath = shellFolderPath;
1919 strcpyW(userShellFolderPath, userPrefix);
1920 PathAddBackslashW(userShellFolderPath);
1921 strcatW(userShellFolderPath, szSHUserFolders);
1922 pUserShellFolderPath = userShellFolderPath;
1923 }
1924 else
1925 {
1926 pUserShellFolderPath = szSHUserFolders;
1927 pShellFolderPath = szSHFolders;
1928 }
1929
1930 if (RegCreateKeyW(rootKey, pShellFolderPath, &shellFolderKey))
1931 {
1932 TRACE("Failed to create %s\n", debugstr_w(pShellFolderPath));
1933 return E_FAIL;
1934 }
1935 if (RegCreateKeyW(rootKey, pUserShellFolderPath, &userShellFolderKey))
1936 {
1937 TRACE("Failed to create %s\n",
1938 debugstr_w(pUserShellFolderPath));
1939 RegCloseKey(shellFolderKey);
1940 return E_FAIL;
1941 }
1942
1943 dwPathLen = MAX_PATH * sizeof(WCHAR);
1944 if (!RegQueryValueExW(userShellFolderKey, value, NULL, &dwType,
1945 (LPBYTE)path, &dwPathLen) && (dwType == REG_EXPAND_SZ || dwType == REG_SZ))
1946 {
1947 LONG ret;
1948
1949 path[dwPathLen / sizeof(WCHAR)] = '\0';
1950 if (dwType == REG_EXPAND_SZ && path[0] == '%')
1951 {
1952 WCHAR szTemp[MAX_PATH];
1953
1954#ifndef __REACTOS__
1956#else
1957 hr = _SHExpandEnvironmentStrings(hToken, path, szTemp, _countof(szTemp));
1958 if (FAILED(hr))
1959 goto end;
1960#endif
1961 lstrcpynW(path, szTemp, MAX_PATH);
1962 }
1963 ret = RegSetValueExW(shellFolderKey, value, 0, REG_SZ, (LPBYTE)path,
1964 (strlenW(path) + 1) * sizeof(WCHAR));
1965 if (ret != ERROR_SUCCESS)
1967 else
1968 hr = S_OK;
1969 }
1970 else
1971 hr = E_FAIL;
1972#ifdef __REACTOS__
1973end:
1974#endif
1975 RegCloseKey(shellFolderKey);
1976 RegCloseKey(userShellFolderKey);
1977 TRACE("returning 0x%08x\n", hr);
1978 return hr;
1979}
#define ERROR_SUCCESS
Definition: deptool.c:10
static const WCHAR szSHUserFolders[]
Definition: shellpath.c:1035
static HRESULT _SHExpandEnvironmentStrings(LPCWSTR szSrc, LPWSTR szDest)
Definition: shellpath.c:2437
static const WCHAR szSHFolders[]
Definition: shellpath.c:1034
#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:94

Referenced by _SHGetAllUsersProfilePath(), and _SHGetUserProfilePath().

◆ _SHOpenProfilesKey()

static HRESULT _SHOpenProfilesKey ( PHKEY  pKey)
static

Definition at line 2372 of file shellpath.c.

2373{
2374 LONG lRet;
2375 DWORD disp;
2376
2377 lRet = RegCreateKeyExW(HKEY_LOCAL_MACHINE, L"Software\\Microsoft\\Windows NT\\CurrentVersion\\ProfileList", 0, NULL, 0,
2378 KEY_ALL_ACCESS, NULL, pKey, &disp);
2379 return HRESULT_FROM_WIN32(lRet);
2380}
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 3036 of file shellpath.c.

3037{
3038 static const UINT folders[] = {
3051 };
3052 HRESULT hr;
3053
3054 TRACE("\n");
3056 szSHFolders, folders, ARRAY_SIZE(folders));
3057 TRACE("returning 0x%08x\n", hr);
3058 return hr;
3059}
static HRESULT _SHRegisterFolders(HKEY hRootKey, HANDLE hToken, LPCWSTR szUserShellFolderPath, LPCWSTR szShellFolderPath, const UINT folders[], UINT foldersLen)
Definition: shellpath.c:2866
unsigned int UINT
Definition: ndis.h:50
#define CSIDL_COMMON_TEMPLATES
Definition: shlobj.h:2217
#define CSIDL_COMMON_DESKTOPDIRECTORY
Definition: shlobj.h:2197
#define CSIDL_COMMON_STARTMENU
Definition: shlobj.h:2194
#define CSIDL_COMMON_APPDATA
Definition: shlobj.h:2207
#define CSIDL_COMMON_PROGRAMS
Definition: shlobj.h:2195
#define CSIDL_COMMON_FAVORITES
Definition: shlobj.h:2203
#define CSIDL_COMMON_MUSIC
Definition: shlobj.h:2222
#define CSIDL_COMMON_VIDEO
Definition: shlobj.h:2224
#define CSIDL_COMMON_PICTURES
Definition: shlobj.h:2223
#define CSIDL_COMMON_STARTUP
Definition: shlobj.h:2196
#define CSIDL_COMMON_DOCUMENTS
Definition: shlobj.h:2218
#define CSIDL_COMMON_ADMINTOOLS
Definition: shlobj.h:2219

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

2869{
2870 const WCHAR *szValueName;
2871 WCHAR buffer[40];
2872 UINT i;
2874 HRESULT hr = S_OK;
2875 HKEY hUserKey = NULL, hKey = NULL;
2876 DWORD dwType, dwPathLen;
2877 LONG ret;
2878
2879 TRACE("%p,%p,%s,%p,%u\n", hRootKey, hToken,
2880 debugstr_w(szUserShellFolderPath), folders, foldersLen);
2881
2882 ret = RegCreateKeyW(hRootKey, szUserShellFolderPath, &hUserKey);
2883 if (ret)
2885 else
2886 {
2887 ret = RegCreateKeyW(hRootKey, szShellFolderPath, &hKey);
2888 if (ret)
2890 }
2891 for (i = 0; SUCCEEDED(hr) && i < foldersLen; i++)
2892 {
2893 dwPathLen = MAX_PATH * sizeof(WCHAR);
2894
2895 /* For CSIDL_Type_User we also use the GUID if no szValueName is provided */
2896 szValueName = CSIDL_Data[folders[i]].szValueName;
2897#ifdef __REACTOS__
2898 if (!szValueName &&
2899 (CSIDL_Data[folders[i]].type == CSIDL_Type_User ||
2900 CSIDL_Data[folders[i]].type == CSIDL_Type_InMyDocuments))
2901#else
2902 if (!szValueName && CSIDL_Data[folders[i]].type == CSIDL_Type_User)
2903#endif
2904 {
2905 StringFromGUID2( CSIDL_Data[folders[i]].id, buffer, 39 );
2906 szValueName = &buffer[0];
2907 }
2908
2909 if (!RegQueryValueExW(hUserKey, szValueName, NULL,
2910 &dwType, (LPBYTE)path, &dwPathLen) &&
2911 (dwType == REG_SZ || dwType == REG_EXPAND_SZ))
2912 {
2914 hToken, SHGFP_TYPE_CURRENT, path);
2915 }
2916 else
2917 {
2918 *path = '\0';
2919#ifdef __REACTOS__
2920 if (CSIDL_Data[folders[i]].type == CSIDL_Type_User ||
2921 CSIDL_Data[folders[i]].type == CSIDL_Type_InMyDocuments)
2922#else
2923 if (CSIDL_Data[folders[i]].type == CSIDL_Type_User)
2924#endif
2925 _SHGetUserProfilePath(hToken, SHGFP_TYPE_CURRENT, folders[i],
2926 path);
2927 else if (CSIDL_Data[folders[i]].type == CSIDL_Type_AllUsers)
2929 else if (CSIDL_Data[folders[i]].type == CSIDL_Type_WindowsPath)
2930 {
2932 if (CSIDL_Data[folders[i]].szDefaultPath &&
2933 !IS_INTRESOURCE(CSIDL_Data[folders[i]].szDefaultPath))
2934 {
2936 strcatW(path, CSIDL_Data[folders[i]].szDefaultPath);
2937 }
2938 }
2939 else
2940 hr = E_FAIL;
2941 if (*path)
2942 {
2943 ret = RegSetValueExW(hUserKey, szValueName, 0, REG_EXPAND_SZ,
2944 (LPBYTE)path, (strlenW(path) + 1) * sizeof(WCHAR));
2945 if (ret)
2947 else
2948 {
2950 hToken, SHGFP_TYPE_CURRENT, path);
2951 ret = RegSetValueExW(hKey, szValueName, 0, REG_SZ,
2952 (LPBYTE)path, (strlenW(path) + 1) * sizeof(WCHAR));
2953 if (ret)
2955 }
2956 }
2957 }
2958 }
2959 if (hUserKey)
2960 RegCloseKey(hUserKey);
2961 if (hKey)
2963
2964 TRACE("returning 0x%08x\n", hr);
2965 return hr;
2966}
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:2589
static HRESULT _SHGetAllUsersProfilePath(DWORD dwFlags, BYTE folder, LPWSTR pszPath)
Definition: shellpath.c:2332
static HRESULT _SHGetUserProfilePath(HANDLE hToken, DWORD dwFlags, BYTE folder, LPWSTR pszPath)
Definition: shellpath.c:2243
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:2149

Referenced by _SHRegisterCommonShellFolders(), and _SHRegisterUserShellFolders().

◆ _SHRegisterUserShellFolders()

static HRESULT _SHRegisterUserShellFolders ( BOOL  bDefault)
static

Definition at line 2968 of file shellpath.c.

2969{
2970 static const UINT folders[] = {
2992/* Cannot use #if _WIN32_WINNT >= 0x0600 because _WIN32_WINNT == 0x0600 here. */
2993#ifndef __REACTOS__
3000#endif
3001 };
3002 WCHAR userShellFolderPath[MAX_PATH], shellFolderPath[MAX_PATH];
3003 LPCWSTR pUserShellFolderPath, pShellFolderPath;
3004 HRESULT hr = S_OK;
3005 HKEY hRootKey;
3006 HANDLE hToken;
3007
3008 TRACE("%s\n", bDefault ? "TRUE" : "FALSE");
3009 if (bDefault)
3010 {
3011 hToken = (HANDLE)-1;
3012 hRootKey = HKEY_USERS;
3013 strcpyW(userShellFolderPath, L".Default");
3014 PathAddBackslashW(userShellFolderPath);
3015 strcatW(userShellFolderPath, szSHUserFolders);
3016 pUserShellFolderPath = userShellFolderPath;
3017 strcpyW(shellFolderPath, L".Default");
3018 PathAddBackslashW(shellFolderPath);
3019 strcatW(shellFolderPath, szSHFolders);
3020 pShellFolderPath = shellFolderPath;
3021 }
3022 else
3023 {
3024 hToken = NULL;
3025 hRootKey = HKEY_CURRENT_USER;
3026 pUserShellFolderPath = szSHUserFolders;
3027 pShellFolderPath = szSHFolders;
3028 }
3029
3030 hr = _SHRegisterFolders(hRootKey, hToken, pUserShellFolderPath,
3031 pShellFolderPath, folders, ARRAY_SIZE(folders));
3032 TRACE("returning 0x%08x\n", hr);
3033 return hr;
3034}
#define CSIDL_LINKS
Definition: shellpath.c:1059
#define CSIDL_APPDATA_LOCALLOW
Definition: shellpath.c:1060
#define CSIDL_DOWNLOADS
Definition: shellpath.c:1058
#define CSIDL_SEARCHES
Definition: shellpath.c:1062
#define CSIDL_SAVED_GAMES
Definition: shellpath.c:1061
#define CSIDL_CONTACTS
Definition: shellpath.c:1057
#define CSIDL_TEMPLATES
Definition: shlobj.h:2193
#define CSIDL_INTERNET_CACHE
Definition: shlobj.h:2204
#define CSIDL_DESKTOPDIRECTORY
Definition: shlobj.h:2188
#define CSIDL_SENDTO
Definition: shlobj.h:2182
#define CSIDL_RECENT
Definition: shlobj.h:2181
#define CSIDL_ADMINTOOLS
Definition: shlobj.h:2220
#define CSIDL_FONTS
Definition: shlobj.h:2192
#define CSIDL_PERSONAL
Definition: shlobj.h:2178
#define CSIDL_FAVORITES
Definition: shlobj.h:2179
#define CSIDL_MYPICTURES
Definition: shlobj.h:2211
#define CSIDL_COOKIES
Definition: shlobj.h:2205
#define CSIDL_HISTORY
Definition: shlobj.h:2206
#define CSIDL_LOCAL_APPDATA
Definition: shlobj.h:2200
#define CSIDL_STARTMENU
Definition: shlobj.h:2184
#define CSIDL_PROGRAMS
Definition: shlobj.h:2175
#define CSIDL_APPDATA
Definition: shlobj.h:2198
#define CSIDL_PRINTHOOD
Definition: shlobj.h:2199
#define CSIDL_STARTUP
Definition: shlobj.h:2180
#define CSIDL_MYMUSIC
Definition: shlobj.h:2186
#define CSIDL_NETHOOD
Definition: shlobj.h:2191
#define CSIDL_MYVIDEO
Definition: shlobj.h:2187
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:145

◆ 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:2266
#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 736 of file shellpath.c.

737{
738 int i = 0;
739 DWORD rc = 0;
740 int length = 0;
741
742 if (SHELL_OsIsUnicode())
743 {
744 LPWSTR p = lpszFileW;
745
746 TRACE("Cleanup %s\n",debugstr_w(lpszFileW));
747
748 if (lpszPathW)
749 length = strlenW(lpszPathW);
750
751 while (*p)
752 {
753 int gct = PathGetCharTypeW(*p);
754 if (gct == GCT_INVALID || gct == GCT_WILD || gct == GCT_SEPARATOR)
755 {
756 lpszFileW[i]='-';
757 rc |= PCS_REPLACEDCHAR;
758 }
759 else
760 lpszFileW[i]=*p;
761 i++;
762 p++;
763 if (length + i == MAX_PATH)
764 {
766 break;
767 }
768 }
769 lpszFileW[i]=0;
770 }
771 else
772 {
773 LPSTR lpszFileA = (LPSTR)lpszFileW;
774 LPCSTR lpszPathA = (LPCSTR)lpszPathW;
775 LPSTR p = lpszFileA;
776
777 TRACE("Cleanup %s\n",debugstr_a(lpszFileA));
778
779 if (lpszPathA)
780 length = strlen(lpszPathA);
781
782 while (*p)
783 {
784 int gct = PathGetCharTypeA(*p);
785 if (gct == GCT_INVALID || gct == GCT_WILD || gct == GCT_SEPARATOR)
786 {
787 lpszFileA[i]='-';
788 rc |= PCS_REPLACEDCHAR;
789 }
790 else
791 lpszFileA[i]=*p;
792 i++;
793 p++;
794 if (length + i == MAX_PATH)
795 {
797 break;
798 }
799 }
800 lpszFileA[i]=0;
801 }
802 return rc;
803}
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
UINT WINAPI PathGetCharTypeA(UCHAR ch)
Definition: path.c:3026
UINT WINAPI PathGetCharTypeW(WCHAR ch)
Definition: path.c:3036
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:805
#define GCT_INVALID
Definition: shlwapi.h:801
#define GCT_WILD
Definition: shlwapi.h:804
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:1755
BOOL WINAPI PathFileExistsW(LPCWSTR lpszPath)
Definition: path.c:1777

◆ 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:1642
BOOL WINAPI PathIsRootA(LPCSTR lpszPath)
Definition: path.c:1602

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

690{
691 if (SHELL_OsIsUnicode())
692 return PathMakeUniqueNameW(lpszBuffer,dwBuffSize, lpszShortName,lpszLongName,lpszPathName);
693 return PathMakeUniqueNameA(lpszBuffer,dwBuffSize, lpszShortName,lpszLongName,lpszPathName);
694}
static BOOL PathMakeUniqueNameW(LPWSTR lpszBuffer, DWORD dwBuffSize, LPCWSTR lpszShortName, LPCWSTR lpszLongName, LPCWSTR lpszPathName)
Definition: shellpath.c:668
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 668 of file shellpath.c.

674{
675 FIXME("%p %u %s %s %s stub\n",
676 lpszBuffer, dwBuffSize, debugstr_w(lpszShortName),
677 debugstr_w(lpszLongName), debugstr_w(lpszPathName));
678 return TRUE;
679}

Referenced by PathMakeUniqueNameAW().

◆ PathProcessCommandA()

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

Definition at line 971 of file shellpath.c.

976{
977 FIXME("%s %p 0x%04x 0x%04x stub\n",
978 lpszPath, lpszBuff, dwBuffSize, dwFlags);
979 if(!lpszPath) return -1;
980 if(lpszBuff) strcpy(lpszBuff, lpszPath);
981 return strlen(lpszPath);
982}
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388

Referenced by PathProcessCommandAW().

◆ PathProcessCommandAW()

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

Definition at line 1003 of file shellpath.c.

1008{
1009 if (SHELL_OsIsUnicode())
1010 return PathProcessCommandW(lpszPath, lpszBuff, dwBuffSize, dwFlags);
1011 return PathProcessCommandA(lpszPath, lpszBuff, dwBuffSize, dwFlags);
1012}
static LONG PathProcessCommandW(LPCWSTR lpszPath, LPWSTR lpszBuff, DWORD dwBuffSize, DWORD dwFlags)
Definition: shellpath.c:987
static LONG PathProcessCommandA(LPCSTR lpszPath, LPSTR lpszBuff, DWORD dwBuffSize, DWORD dwFlags)
Definition: shellpath.c:971

◆ PathProcessCommandW()

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

Definition at line 987 of file shellpath.c.

992{
993 FIXME("(%s, %p, 0x%04x, 0x%04x) stub\n",
994 debugstr_w(lpszPath), lpszBuff, dwBuffSize, dwFlags);
995 if(!lpszPath) return -1;
996 if(lpszBuff) strcpyW(lpszBuff, lpszPath);
997 return strlenW(lpszPath);
998}

Referenced by PathProcessCommandAW().

◆ PathQualifyA()

VOID WINAPI PathQualifyA ( LPSTR  pszPath)

Definition at line 808 of file shellpath.c.

809{
811 TRACE("%s\n",pszPath);
815}
VOID WINAPI PathQualifyW(LPWSTR pszPath)
Definition: shellpath.c:820
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 829 of file shellpath.c.

830{
831 if (SHELL_OsIsUnicode())
832 PathQualifyW(pszPath);
833 else
834 PathQualifyA(pszPath);
835}
VOID WINAPI PathQualifyA(LPSTR pszPath)
Definition: shellpath.c:808

◆ 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:4530
BOOL WINAPI PathRemoveFileSpecW(LPWSTR lpszPath)
Definition: path.c:629
BOOL WINAPI PathIsValidCharW(WCHAR c, DWORD class)
Definition: path.c:4419
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:1737
LPWSTR WINAPI CharPrevW(_In_ LPCWSTR, _In_ LPCWSTR)

Referenced by PathQualifyW(), and PathResolveW().

◆ PathQualifyW()

VOID WINAPI PathQualifyW ( LPWSTR  pszPath)

Definition at line 820 of file shellpath.c.

821{
822 TRACE("%s\n",debugstr_w(pszPath));
823 PathQualifyExW(pszPath, NULL, 0);
824}
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 837 of file shellpath.c.

838{
839 BOOL ret = FALSE;
840 LPWSTR *dirsW = NULL;
841 DWORD iDir, cDirs, cbDirs;
842 WCHAR pathW[MAX_PATH];
843
844 TRACE("(%s,%p,0x%08x)\n", debugstr_a(path), dirs, flags);
845
846 if (dirs)
847 {
848 for (cDirs = 0; dirs[cDirs]; ++cDirs)
849 ;
850
851 cbDirs = (cDirs + 1) * sizeof(LPWSTR);
852 dirsW = SHAlloc(cbDirs);
853 if (!dirsW)
854 goto Cleanup;
855
856 ZeroMemory(dirsW, cbDirs);
857 for (iDir = 0; iDir < cDirs; ++iDir)
858 {
859 __SHCloneStrAtoW(&dirsW[iDir], dirs[iDir]);
860 if (dirsW[iDir] == NULL)
861 goto Cleanup;
862 }
863 }
864
865 SHAnsiToUnicode(path, pathW, _countof(pathW));
866
867 ret = PathResolveW(pathW, (LPCWSTR*)dirsW, flags);
868 if (ret)
870
871Cleanup:
872 if (dirsW)
873 {
874 for (iDir = 0; iDir < cDirs; ++iDir)
875 {
876 SHFree(dirsW[iDir]);
877 }
878 SHFree(dirsW);
879 }
880 return ret;
881}
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:883
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:175

Referenced by PathResolveAW().

◆ PathResolveAW()

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

Definition at line 960 of file shellpath.c.

961{
962 if (SHELL_OsIsUnicode())
963 return PathResolveW(path, (LPCWSTR*)paths, flags);
964 else
965 return PathResolveA(path, (LPCSTR*)paths, flags);
966}
BOOL WINAPI PathResolveA(LPSTR path, LPCSTR *dirs, DWORD flags)
Definition: shellpath.c:837
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 883 of file shellpath.c.

884{
885 DWORD dwWhich = WHICH_DEFAULT; /* The extensions to be searched */
886
887 TRACE("(%s,%p,0x%08x)\n", debugstr_w(path), dirs, flags);
888
890 dwWhich &= ~WHICH_LNK; /* Don't search '.LNK' (shortcut) */
891
893 SetLastError(ERROR_FILE_NOT_FOUND); /* We set this error code at first in verification */
894
896
897 if (PathIsRootW(path)) /* Root path */
898 {
899 if (path[0] == L'\\' && path[1] == UNICODE_NULL) /* '\' only? */
900 PathQualifyExW(path, ((flags & PRF_FIRSTDIRDEF) ? *dirs : NULL), 0); /* Qualify */
901
903 return PathFileExistsAndAttributesW(path, NULL); /* Check the existence */
904
905 return TRUE;
906 }
907
908 if (PathIsFileSpecW(path)) /* Filename only */
909 {
910 /* Try to find the path with program extensions applied? */
912 PathSearchOnExtensionsW(path, dirs, TRUE, dwWhich))
913 {
914 return TRUE; /* Found */
915 }
916
917 /* Try to find the filename in the directories */
918 if (PathFindOnPathW(path, dirs))
919 goto CheckAbsoluteAndFinish;
920
921 return FALSE; /* Not found */
922 }
923
924 if (PathIsURLW(path)) /* URL? */
925 return FALSE;
926
927 /* Qualify the path */
928 PathQualifyExW(path, ((flags & PRF_FIRSTDIRDEF) ? *dirs : NULL), 1);
929
930 TRACE("(%s)\n", debugstr_w(path));
931
932 if (!(flags & PRF_VERIFYEXISTS)) /* Don't verify the existence? */
933 return TRUE;
934
935 /* Try to find the path with program extensions applied? */
937 !PathSearchOnExtensionsW(path, dirs, FALSE, dwWhich))
938 {
940 return FALSE; /* Not found */
941 }
942
943CheckAbsoluteAndFinish:
944#if (_WIN32_WINNT >= _WIN32_WINNT_WS03)
946 return TRUE;
947
949 return FALSE;
950
952#else
953 return TRUE; /* Found */
954#endif
955}
#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:1403
VOID WINAPI PathUnquoteSpacesW(LPWSTR lpszPath)
Definition: path.c:1034
BOOL WINAPI PathIsFileSpecW(LPCWSTR lpszPath)
Definition: path.c:2133
BOOL WINAPI PathFileExistsAndAttributesW(LPCWSTR lpszPath, DWORD *dwAttr)
Definition: path.c:1832
BOOL WINAPI PathIsURLW(LPCWSTR lpstrPath)
Definition: url.c:2432
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
#define WHICH_DEFAULT

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

◆ 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:1351
BOOL WINAPI PathFileExistsDefExtW(LPWSTR lpszPath, DWORD dwWhich)
Definition: path.c:1117

Referenced by PathResolveW().

◆ PathYetAnotherMakeUniqueName()

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

Definition at line 699 of file shellpath.c.

700{
701 WCHAR pathW[MAX_PATH], retW[MAX_PATH];
702 const WCHAR *file, *ext;
703 int i = 2;
704
705 TRACE("(%p, %s, %s, %s)\n", buffer, debugstr_w(path), debugstr_w(shortname), debugstr_w(longname));
706
707 file = longname ? longname : shortname;
708 PathCombineW(pathW, path, file);
709 strcpyW(retW, pathW);
711
713
714 /* now try to make it unique */
715 while (PathFileExistsW(retW))
716 {
717 sprintfW(retW, L"%s (%d)%s", pathW, i, ext);
718 i++;
719 }
720
721 strcpyW(buffer, retW);
722 TRACE("ret - %s\n", debugstr_w(buffer));
723
724 return TRUE;
725}
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 1859 of file shellpath.c.

1860{
1861 LPCWSTR pszPath, pchBackslash;
1863
1864 pchBackslash = StrChrW(pszStart, L'\\');
1865 if (pchBackslash)
1866 {
1867 *ppch = (LPWSTR)(pchBackslash + 1);
1868 *pcch = (pchBackslash - pszStart) + 1;
1869 StrCpyNW(szPath, pszStart, min(*pcch, _countof(szPath)));
1870 pszPath = szPath;
1871 }
1872 else
1873 {
1874 *ppch = NULL;
1875 *pcch = lstrlenW(pszStart);
1876 pszPath = pszStart;
1877 }
1878
1879 return SHGetSpecialFolderID(pszPath);
1880}
INT SHGetSpecialFolderID(_In_ LPCWSTR pszName)
Definition: shellpath.c:1845
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 3064 of file shellpath.c.

3065{
3066 HRESULT hr;
3067
3069 if (SUCCEEDED(hr))
3071 if (SUCCEEDED(hr))
3073 return hr;
3074}
static HRESULT _SHRegisterUserShellFolders(BOOL bDefault)
Definition: shellpath.c:2968
static HRESULT _SHRegisterCommonShellFolders(void)
Definition: shellpath.c:3036

Referenced by DllRegisterServer().

◆ SHGetFolderLocation()

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

Definition at line 3150 of file shellpath.c.

3156{
3158#ifdef __REACTOS__
3160#endif
3161
3162 TRACE("%p 0x%08x %p 0x%08x %p\n",
3163 hwndOwner, nFolder, hToken, dwReserved, ppidl);
3164
3165 if (!ppidl)
3166 return E_INVALIDARG;
3167 if (dwReserved)
3168 return E_INVALIDARG;
3169
3170#ifdef __REACTOS__
3171 if ((nFolder & CSIDL_FLAG_NO_ALIAS) &&
3173 {
3174 *ppidl = ILCreateFromPathW(szPath);
3175 if (*ppidl)
3176 return S_OK;
3177 }
3178#endif
3179 /* The virtual folders' locations are not user-dependent */
3180 *ppidl = NULL;
3181 switch (nFolder & CSIDL_FOLDER_MASK)
3182 {
3183 case CSIDL_DESKTOP:
3184 *ppidl = _ILCreateDesktop();
3185 break;
3186
3187 case CSIDL_PERSONAL:
3188 *ppidl = _ILCreateMyDocuments();
3189 break;
3190
3191 case CSIDL_INTERNET:
3192 *ppidl = _ILCreateIExplore();
3193 break;
3194
3195 case CSIDL_CONTROLS:
3196 *ppidl = _ILCreateControlPanel();
3197 break;
3198
3199 case CSIDL_PRINTERS:
3200 *ppidl = _ILCreatePrinters();
3201 break;
3202
3203 case CSIDL_BITBUCKET:
3204 *ppidl = _ILCreateBitBucket();
3205 break;
3206
3207 case CSIDL_DRIVES:
3208 *ppidl = _ILCreateMyComputer();
3209 break;
3210
3211 case CSIDL_NETWORK:
3212 *ppidl = _ILCreateNetwork();
3213 break;
3214
3215#ifdef __REACTOS__
3216 case CSIDL_CONNECTIONS:
3217 hr = SHGetFolderLocationHelper(hwndOwner, CSIDL_CONTROLS, &CLSID_NetworkConnections, ppidl);
3218 break;
3219#endif
3220
3221 default:
3222 {
3224
3225 hr = SHGetFolderPathW(hwndOwner, nFolder, hToken,
3227 if (SUCCEEDED(hr))
3228 {
3229 DWORD attributes=0;
3230
3231 TRACE("Value=%s\n", debugstr_w(szPath));
3232 hr = SHILCreateFromPathW(szPath, ppidl, &attributes);
3233 }
3235 {
3236 /* unlike SHGetFolderPath, SHGetFolderLocation in shell32
3237 * version 6.0 returns E_FAIL for nonexistent paths
3238 */
3239 hr = E_FAIL;
3240 }
3241 }
3242 }
3243 if(*ppidl)
3244 hr = S_OK;
3245
3246 TRACE("-- (new pidl %p)\n",*ppidl);
3247 return hr;
3248}
BOOL WINAPI SHGetSpecialFolderPathW(HWND hwndOwner, LPWSTR szPath, int nFolder, BOOL bCreate)
Definition: shellpath.c:3092
_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:1758
LPITEMIDLIST _ILCreateIExplore(void)
Definition: pidl.c:1770
HRESULT WINAPI SHILCreateFromPathW(LPCWSTR path, LPITEMIDLIST *ppidl, DWORD *attributes)
Definition: pidl.c:403
LPITEMIDLIST _ILCreateDesktop(void)
Definition: pidl.c:1747
LPITEMIDLIST _ILCreateNetwork(void)
Definition: pidl.c:1822
LPITEMIDLIST _ILCreatePrinters(void)
Definition: pidl.c:1795
LPITEMIDLIST _ILCreateControlPanel(void)
Definition: pidl.c:1776
LPITEMIDLIST WINAPI ILCreateFromPathW(LPCWSTR path)
Definition: pidl.c:1101
LPITEMIDLIST _ILCreateMyDocuments(void)
Definition: pidl.c:1764
LPITEMIDLIST _ILCreateBitBucket(void)
Definition: pidl.c:1828
#define CSIDL_FLAG_NO_ALIAS
Definition: shlobj.h:2233
#define CSIDL_CONNECTIONS
Definition: shlobj.h:2221
#define CSIDL_PRINTERS
Definition: shlobj.h:2177
#define CSIDL_FOLDER_MASK
Definition: shlobj.h:2231
#define CSIDL_DESKTOP
Definition: shlobj.h:2173
#define CSIDL_NETWORK
Definition: shlobj.h:2190
#define CSIDL_DRIVES
Definition: shlobj.h:2189
#define CSIDL_INTERNET
Definition: shlobj.h:2174
#define CSIDL_CONTROLS
Definition: shlobj.h:2176
#define CSIDL_BITBUCKET
Definition: shlobj.h:2183
_In_ int nFolder
Definition: shlobj.h:1519

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

2842{
2843 WCHAR szTemp[MAX_PATH];
2844 HRESULT hr;
2845
2846 TRACE("%p,%d,%p,%#x,%p\n", hwndOwner, nFolder, hToken, dwFlags, pszPath);
2847
2848 if (pszPath)
2849 *pszPath = '\0';
2850 hr = SHGetFolderPathW(hwndOwner, nFolder, hToken, dwFlags, szTemp);
2851 if (SUCCEEDED(hr) && pszPath)
2852 WideCharToMultiByte(CP_ACP, 0, szTemp, -1, pszPath, MAX_PATH, NULL,
2853 NULL);
2854
2855 return hr;
2856}
#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 2602 of file shellpath.c.

2609{
2610 int length;
2611 HRESULT hr = S_OK;
2612 LPWSTR pszSubPathW = NULL;
2613 LPWSTR pszPathW = NULL;
2614
2615 TRACE("%p,%#x,%p,%#x,%s,%p\n", hwndOwner, nFolder, hToken, dwFlags, debugstr_a(pszSubPath), pszPath);
2616
2617 if(pszPath) {
2618 pszPathW = HeapAlloc(GetProcessHeap(), 0, MAX_PATH * sizeof(WCHAR));
2619 if(!pszPathW) {
2621 goto cleanup;
2622 }
2623 }
2624 TRACE("%08x,%08x,%s\n",nFolder, dwFlags, debugstr_w(pszSubPathW));
2625
2626 /* SHGetFolderPathAndSubDirW does not distinguish if pszSubPath isn't
2627 * set (null), or an empty string.therefore call it without the parameter set
2628 * if pszSubPath is an empty string
2629 */
2630 if (pszSubPath && pszSubPath[0]) {
2631 length = MultiByteToWideChar(CP_ACP, 0, pszSubPath, -1, NULL, 0);
2632 pszSubPathW = HeapAlloc(GetProcessHeap(), 0, length * sizeof(WCHAR));
2633 if(!pszSubPathW) {
2635 goto cleanup;
2636 }
2637 MultiByteToWideChar(CP_ACP, 0, pszSubPath, -1, pszSubPathW, length);
2638 }
2639
2640 hr = SHGetFolderPathAndSubDirW(hwndOwner, nFolder, hToken, dwFlags, pszSubPathW, pszPathW);
2641
2642 if (SUCCEEDED(hr) && pszPath)
2643 WideCharToMultiByte(CP_ACP, 0, pszPathW, -1, pszPath, MAX_PATH, NULL, NULL);
2644
2645cleanup:
2646 HeapFree(GetProcessHeap(), 0, pszPathW);
2647 HeapFree(GetProcessHeap(), 0, pszSubPathW);
2648 return hr;
2649}
#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:2654

Referenced by test_SHGetFolderPathAndSubDirA().

◆ SHGetFolderPathAndSubDirW()

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

Definition at line 2654 of file shellpath.c.

2661{
2662 HRESULT hr;
2663 WCHAR szBuildPath[MAX_PATH], szTemp[MAX_PATH];
2666 int ret;
2667
2668 TRACE("%p,%#x,%p,%#x,%s,%p\n", hwndOwner, nFolder, hToken, dwFlags, debugstr_w(pszSubPath), pszPath);
2669
2670 /* Windows always NULL-terminates the resulting path regardless of success
2671 * or failure, so do so first
2672 */
2673 if (pszPath)
2674 *pszPath = '\0';
2675
2677 return E_INVALIDARG;
2679 return E_INVALIDARG;
2680 szTemp[0] = 0;
2682 switch (type)
2683 {
2685 hr = E_INVALIDARG;
2686 break;
2688 hr = S_FALSE;
2689 break;
2692 if (CSIDL_Data[folder].szDefaultPath &&
2693 !IS_INTRESOURCE(CSIDL_Data[folder].szDefaultPath) &&
2694 *CSIDL_Data[folder].szDefaultPath)
2695 {
2696 PathAddBackslashW(szTemp);
2697 strcatW(szTemp, CSIDL_Data[folder].szDefaultPath);
2698 }
2699 hr = S_OK;
2700 break;
2703 if (CSIDL_Data[folder].szDefaultPath &&
2704 !IS_INTRESOURCE(CSIDL_Data[folder].szDefaultPath) &&
2705 *CSIDL_Data[folder].szDefaultPath)
2706 {
2707 PathAddBackslashW(szTemp);
2708 strcatW(szTemp, CSIDL_Data[folder].szDefaultPath);
2709 }
2710 hr = S_OK;
2711 break;
2714 if (CSIDL_Data[folder].szDefaultPath &&
2715 !IS_INTRESOURCE(CSIDL_Data[folder].szDefaultPath) &&
2716 *CSIDL_Data[folder].szDefaultPath)
2717 {
2718 PathAddBackslashW(szTemp);
2719 strcatW(szTemp, CSIDL_Data[folder].szDefaultPath);
2720 }
2721 hr = S_OK;
2722 break;
2723 case CSIDL_Type_CurrVer:
2725 break;
2726 case CSIDL_Type_User:
2727#ifdef __REACTOS__
2728 case CSIDL_Type_InMyDocuments:
2729#endif
2730 hr = _SHGetUserProfilePath(hToken, dwFlags, folder, szTemp);
2731 break;
2734 break;
2735 default:
2736 FIXME("bogus type %d, please fix\n", type);
2737 hr = E_INVALIDARG;
2738 break;
2739 }
2740
2741 /* Expand environment strings if necessary */
2742 if (*szTemp == '%')
2743#ifndef __REACTOS__
2744 hr = _SHExpandEnvironmentStrings(szTemp, szBuildPath);
2745#else
2746 hr = _SHExpandEnvironmentStrings(hToken, szTemp, szBuildPath, _countof(szBuildPath));
2747#endif
2748 else
2749 strcpyW(szBuildPath, szTemp);
2750
2751 if (FAILED(hr)) goto end;
2752
2753 if(pszSubPath) {
2754 /* make sure the new path does not exceed the buffer length
2755 * and remember to backslash and terminate it */
2756 if(MAX_PATH < (lstrlenW(szBuildPath) + lstrlenW(pszSubPath) + 2)) {
2758 goto end;
2759 }
2760 PathAppendW(szBuildPath, pszSubPath);
2761 PathRemoveBackslashW(szBuildPath);
2762 }
2763 /* Copy the path if it's available before we might return */
2764 if (SUCCEEDED(hr) && pszPath)
2765 strcpyW(pszPath, szBuildPath);
2766
2767 /* if we don't care about existing directories we are ready */
2769
2770 if (PathFileExistsW(szBuildPath)) goto end;
2771
2772 /* not existing but we are not allowed to create it. The return value
2773 * is verified against shell32 version 6.0.
2774 */
2775 if (!(nFolder & CSIDL_FLAG_CREATE))
2776 {
2778 goto end;
2779 }
2780
2781 /* create directory/directories */
2782 ret = SHCreateDirectoryExW(hwndOwner, szBuildPath, NULL);
2783 if (ret && ret != ERROR_ALREADY_EXISTS)
2784 {
2785 ERR("Failed to create directory %s.\n", debugstr_w(szBuildPath));
2786 hr = E_FAIL;
2787 goto end;
2788 }
2789
2790 TRACE("Created missing system directory %s\n", debugstr_w(szBuildPath));
2791
2792end:
2793#ifdef __REACTOS__
2794 /* create desktop.ini for custom icon */
2795 if ((nFolder & CSIDL_FLAG_CREATE) &&
2796 CSIDL_Data[folder].nShell32IconIndex)
2797 {
2798 WCHAR szIconLocation[MAX_PATH];
2800
2801 /* make the directory a read-only folder */
2802 dwAttributes = GetFileAttributesW(szBuildPath);
2804 SetFileAttributesW(szBuildPath, dwAttributes);
2805
2806 /* build the desktop.ini file path */
2807 PathAppendW(szBuildPath, L"desktop.ini");
2808
2809 /* build the icon location */
2810 StringCchPrintfW(szIconLocation, _countof(szIconLocation),
2811 L"%%SystemRoot%%\\system32\\shell32.dll,%d",
2812 CSIDL_Data[folder].nShell32IconIndex);
2813
2814 /* write desktop.ini */
2815 WritePrivateProfileStringW(L".ShellClassInfo", L"IconResource", szIconLocation, szBuildPath);
2816
2817 /* flush! */
2818 WritePrivateProfileStringW(NULL, NULL, NULL, szBuildPath);
2819
2820 /* make the desktop.ini a system and hidden file */
2821 dwAttributes = GetFileAttributesW(szBuildPath);
2823 SetFileAttributesW(szBuildPath, dwAttributes);
2824 }
2825#endif
2826
2827 TRACE("returning 0x%08x (final path is %s)\n", hr, debugstr_w(szBuildPath));
2828 return hr;
2829}
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:2133
#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:906
#define CSIDL_FLAG_DONT_VERIFY
Definition: shlobj.h:2234
STRSAFEAPI StringCchPrintfW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszFormat,...)
Definition: strsafe.h:530
CSIDL_Type type
Definition: shellpath.c:1068
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 1845 of file shellpath.c.

1846{
1847 UINT csidl;
1848
1849 for (csidl = 0; csidl < _countof(CSIDL_Data); ++csidl)
1850 {
1851 const CSIDL_DATA *pData = &CSIDL_Data[csidl];
1852 if (pData->szValueName && lstrcmpiW(pszName, pData->szValueName) == 0)
1853 return csidl;
1854 }
1855
1856 return -1;
1857}
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 3257 of file shellpath.c.

3261{
3263
3264 TRACE("(%p,0x%x,%p)\n", hwndOwner,nFolder,ppidl);
3265
3266 if (!ppidl)
3267 return E_INVALIDARG;
3268
3269 hr = SHGetFolderLocation(hwndOwner, nFolder, NULL, 0, ppidl);
3270 return hr;
3271}
HRESULT WINAPI SHGetFolderLocation(HWND hwndOwner, int nFolder, HANDLE hToken, DWORD dwReserved, LPITEMIDLIST *ppidl)
Definition: shellpath.c:3150

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(), IShellBrowserImpl_Construct(), loadShell32(), MRUList_PidlList_0(), CACListISF::NextLocation(), CShellMenuCallback::OnGetContextMenu(), PidlBrowse(), CAddressEditBox::PopulateComboBox(), RSHELL_CStartMenu_CreateInstance(), SHAddToRecentDocs(), SHCloneSpecialIDList(), Shell_ParsePrinterName(), SHELL_ShowItemIDListProperties(), SHExplorerParseCmdLine(), 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 3079 of file shellpath.c.

3084{
3085 return SHGetFolderPathA(hwndOwner, nFolder + (bCreate ? CSIDL_FLAG_CREATE : 0), NULL, 0,
3086 szPath) == S_OK;
3087}
HRESULT WINAPI SHGetFolderPathA(HWND hwndOwner, int nFolder, HANDLE hToken, DWORD dwFlags, LPSTR pszPath)
Definition: shellpath.c:2836
_In_ int _In_ BOOL bCreate
Definition: shlobj.h:1520

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

◆ Local_Settings_HistoryW

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

Definition at line 1022 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 1023 of file shellpath.c.

◆ MusicW

const WCHAR MusicW[] = L"Music"
static

Definition at line 1024 of file shellpath.c.

◆ PicturesW

const WCHAR PicturesW[] = L"Pictures"
static

Definition at line 1025 of file shellpath.c.

◆ Program_Files_Common_FilesW

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

Definition at line 1027 of file shellpath.c.

◆ Program_FilesW

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

Definition at line 1026 of file shellpath.c.

◆ Start_Menu_Admin_ToolsW

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

Definition at line 1029 of file shellpath.c.

◆ Start_Menu_ProgramsW

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

Definition at line 1028 of file shellpath.c.

◆ Start_Menu_StartupW

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

Definition at line 1030 of file shellpath.c.

◆ szKnownFolderDescriptions

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

Definition at line 1037 of file shellpath.c.

◆ szKnownFolderRedirections

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

Definition at line 1038 of file shellpath.c.

◆ szSHFolders

◆ szSHUserFolders

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