ReactOS  0.4.15-dev-2979-gfd8baca
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 <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 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 _CSIDL_Type CSIDL_Type
 

Enumerations

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 WINAPI PathSearchOnExtensionsW (LPWSTR pszPath, LPCWSTR *ppszDirs, BOOL bDoSearch, DWORD dwWhich)
 
static BOOL WINAPI PathIsAbsoluteW (LPCWSTR path)
 
static BOOL WINAPI PathMakeAbsoluteW (LPWSTR path)
 
static DWORD GetShortPathNameAbsentW (LPCWSTR pszLong, LPWSTR pszShort, DWORD cchShort)
 
BOOL WINAPI IsLFNDriveW (LPCWSTR lpszPath)
 
static VOID WINAPI PathQualifyExW (LPWSTR pszPath, LPCWSTR pszDir, 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 (LPWSTR path, LPCWSTR *dirs, 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)
 
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 szCurrentVersion [] = {'S','o','f','t','w','a','r','e','\\','M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s','\\','C','u','r','r','e','n','t','V','e','r','s','i','o','n','\0'}
 
static const WCHAR Administrative_ToolsW [] = {'A','d','m','i','n','i','s','t','r','a','t','i','v','e',' ','T','o','o','l','s','\0'}
 
static const WCHAR AppDataW [] = {'A','p','p','D','a','t','a','\0'}
 
static const WCHAR AppData_LocalLowW [] = {'A','p','p','D','a','t','a','\\','L','o','c','a','l','L','o','w','\0'}
 
static const WCHAR Application_DataW [] = {'A','p','p','l','i','c','a','t','i','o','n',' ','D','a','t','a','\0'}
 
static const WCHAR CacheW [] = {'C','a','c','h','e','\0'}
 
static const WCHAR CD_BurningW [] = {'C','D',' ','B','u','r','n','i','n','g','\0'}
 
static const WCHAR Common_Administrative_ToolsW [] = {'C','o','m','m','o','n',' ','A','d','m','i','n','i','s','t','r','a','t','i','v','e',' ','T','o','o','l','s','\0'}
 
static const WCHAR Common_AppDataW [] = {'C','o','m','m','o','n',' ','A','p','p','D','a','t','a','\0'}
 
static const WCHAR Common_DesktopW [] = {'C','o','m','m','o','n',' ','D','e','s','k','t','o','p','\0'}
 
static const WCHAR Common_DocumentsW [] = {'C','o','m','m','o','n',' ','D','o','c','u','m','e','n','t','s','\0'}
 
static const WCHAR Common_FavoritesW [] = {'C','o','m','m','o','n',' ','F','a','v','o','r','i','t','e','s','\0'}
 
static const WCHAR CommonFilesDirW [] = {'C','o','m','m','o','n','F','i','l','e','s','D','i','r','\0'}
 
static const WCHAR CommonFilesDirX86W [] = {'C','o','m','m','o','n','F','i','l','e','s','D','i','r',' ','(','x','8','6',')','\0'}
 
static const WCHAR CommonMusicW [] = {'C','o','m','m','o','n','M','u','s','i','c','\0'}
 
static const WCHAR CommonPicturesW [] = {'C','o','m','m','o','n','P','i','c','t','u','r','e','s','\0'}
 
static const WCHAR Common_ProgramsW [] = {'C','o','m','m','o','n',' ','P','r','o','g','r','a','m','s','\0'}
 
static const WCHAR Common_StartUpW [] = {'C','o','m','m','o','n',' ','S','t','a','r','t','U','p','\0'}
 
static const WCHAR Common_Start_MenuW [] = {'C','o','m','m','o','n',' ','S','t','a','r','t',' ','M','e','n','u','\0'}
 
static const WCHAR Common_TemplatesW [] = {'C','o','m','m','o','n',' ','T','e','m','p','l','a','t','e','s','\0'}
 
static const WCHAR CommonVideoW [] = {'C','o','m','m','o','n','V','i','d','e','o','\0'}
 
static const WCHAR ContactsW [] = {'C','o','n','t','a','c','t','s','\0'}
 
static const WCHAR CookiesW [] = {'C','o','o','k','i','e','s','\0'}
 
static const WCHAR DesktopW [] = {'D','e','s','k','t','o','p','\0'}
 
static const WCHAR DocumentsW [] = {'D','o','c','u','m','e','n','t','s','\0'}
 
static const WCHAR DownloadsW [] = {'D','o','w','n','l','o','a','d','s','\0'}
 
static const WCHAR FavoritesW [] = {'F','a','v','o','r','i','t','e','s','\0'}
 
static const WCHAR FontsW [] = {'F','o','n','t','s','\0'}
 
static const WCHAR HistoryW [] = {'H','i','s','t','o','r','y','\0'}
 
static const WCHAR LinksW [] = {'L','i','n','k','s','\0'}
 
static const WCHAR Local_AppDataW [] = {'L','o','c','a','l',' ','A','p','p','D','a','t','a','\0'}
 
static const WCHAR Local_Settings_Application_DataW [] = {'L','o','c','a','l',' ','S','e','t','t','i','n','g','s','\\','A','p','p','l','i','c','a','t','i','o','n',' ','D','a','t','a','\0'}
 
static const WCHAR Local_Settings_CD_BurningW [] = {'L','o','c','a','l',' ','S','e','t','t','i','n','g','s','\\','A','p','p','l','i','c','a','t','i','o','n',' ','D','a','t','a','\\','M','i','c','r','o','s','o','f','t','\\','C','D',' ','B','u','r','n','i','n','g','\0'}
 
static const WCHAR Local_Settings_HistoryW [] = {'L','o','c','a','l',' ','S','e','t','t','i','n','g','s','\\','H','i','s','t','o','r','y','\0'}
 
static const WCHAR Local_Settings_Temporary_Internet_FilesW [] = {'L','o','c','a','l',' ','S','e','t','t','i','n','g','s','\\','T','e','m','p','o','r','a','r','y',' ','I','n','t','e','r','n','e','t',' ','F','i','l','e','s','\0'}
 
static const WCHAR Microsoft_Windows_GameExplorerW [] = {'M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s','\\','G','a','m','e','E','x','p','l','o','r','e','r','\0'}
 
static const WCHAR Microsoft_Windows_LibrariesW [] = {'M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s','\\','L','i','b','r','a','r','i','e','s','\0'}
 
static const WCHAR Microsoft_Windows_RingtonesW [] = {'M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s','\\','R','i','n','g','t','o','n','e','s','\0'}
 
static const WCHAR MusicW [] = {'M','u','s','i','c','\0'}
 
static const WCHAR Music_PlaylistsW [] = {'M','u','s','i','c','\\','P','l','a','y','l','i','s','t','s','\0'}
 
static const WCHAR Music_Sample_MusicW [] = {'M','u','s','i','c','\\','S','a','m','p','l','e',' ','M','u','s','i','c','\0'}
 
static const WCHAR Music_Sample_PlaylistsW [] = {'M','u','s','i','c','\\','S','a','m','p','l','e',' ','P','l','a','y','l','i','s','t','s','\0'}
 
static const WCHAR My_MusicW [] = {'M','y',' ','M','u','s','i','c','\0'}
 
static const WCHAR My_PicturesW [] = {'M','y',' ','P','i','c','t','u','r','e','s','\0'}
 
static const WCHAR My_VideoW [] = {'M','y',' ','V','i','d','e','o','\0'}
 
static const WCHAR NetHoodW [] = {'N','e','t','H','o','o','d','\0'}
 
static const WCHAR OEM_LinksW [] = {'O','E','M',' ','L','i','n','k','s','\0'}
 
static const WCHAR PersonalW [] = {'P','e','r','s','o','n','a','l','\0'}
 
static const WCHAR PicturesW [] = {'P','i','c','t','u','r','e','s','\0'}
 
static const WCHAR Pictures_Sample_PicturesW [] = {'P','i','c','t','u','r','e','s','\\','S','a','m','p','l','e',' ','P','i','c','t','u','r','e','s','\0'}
 
static const WCHAR Pictures_Slide_ShowsW [] = {'P','i','c','t','u','r','e','s','\\','S','l','i','d','e',' ','S','h','o','w','s','\0'}
 
static const WCHAR PrintHoodW [] = {'P','r','i','n','t','H','o','o','d','\0'}
 
static const WCHAR Program_FilesW [] = {'P','r','o','g','r','a','m',' ','F','i','l','e','s','\0'}
 
static const WCHAR Program_Files_Common_FilesW [] = {'P','r','o','g','r','a','m',' ','F','i','l','e','s','\\','C','o','m','m','o','n',' ','F','i','l','e','s','\0'}
 
static const WCHAR Program_Files_x86W [] = {'P','r','o','g','r','a','m',' ','F','i','l','e','s',' ','(','x','8','6',')','\0'}
 
static const WCHAR Program_Files_x86_Common_FilesW [] = {'P','r','o','g','r','a','m',' ','F','i','l','e','s',' ','(','x','8','6',')','\\','C','o','m','m','o','n',' ','F','i','l','e','s','\0'}
 
static const WCHAR ProgramFilesDirW [] = {'P','r','o','g','r','a','m','F','i','l','e','s','D','i','r','\0'}
 
static const WCHAR ProgramFilesDirX86W [] = {'P','r','o','g','r','a','m','F','i','l','e','s','D','i','r',' ','(','x','8','6',')','\0'}
 
static const WCHAR ProgramsW [] = {'P','r','o','g','r','a','m','s','\0'}
 
static const WCHAR PublicW [] = {'P','u','b','l','i','c',0}
 
static const WCHAR RecentW [] = {'R','e','c','e','n','t','\0'}
 
static const WCHAR ResourcesW [] = {'R','e','s','o','u','r','c','e','s','\0'}
 
static const WCHAR Saved_GamesW [] = {'S','a','v','e','d',' ','G','a','m','e','s','\0'}
 
static const WCHAR SearchesW [] = {'S','e','a','r','c','h','e','s','\0'}
 
static const WCHAR SendToW [] = {'S','e','n','d','T','o','\0'}
 
static const WCHAR StartUpW [] = {'S','t','a','r','t','U','p','\0'}
 
static const WCHAR Start_MenuW [] = {'S','t','a','r','t',' ','M','e','n','u','\0'}
 
static const WCHAR Start_Menu_ProgramsW [] = {'S','t','a','r','t',' ','M','e','n','u','\\','P','r','o','g','r','a','m','s','\0'}
 
static const WCHAR Start_Menu_Admin_ToolsW [] = {'S','t','a','r','t',' ','M','e','n','u','\\','P','r','o','g','r','a','m','s','\\','A','d','m','i','n','i','s','t','r','a','t','i','v','e',' ','T','o','o','l','s','\0'}
 
static const WCHAR Start_Menu_StartupW [] = {'S','t','a','r','t',' ','M','e','n','u','\\','P','r','o','g','r','a','m','s','\\','S','t','a','r','t','U','p','\0'}
 
static const WCHAR TemplatesW [] = {'T','e','m','p','l','a','t','e','s','\0'}
 
static const WCHAR UsersW [] = {'U','s','e','r','s','\0'}
 
static const WCHAR UsersPublicW [] = {'U','s','e','r','s','\\','P','u','b','l','i','c','\0'}
 
static const WCHAR VideosW [] = {'V','i','d','e','o','s','\0'}
 
static const WCHAR Videos_Sample_VideosW [] = {'V','i','d','e','o','s','\\','S','a','m','p','l','e',' ','V','i','d','e','o','s','\0'}
 
static const WCHAR DefaultW [] = {'.','D','e','f','a','u','l','t','\0'}
 
static const WCHAR AllUsersProfileW [] = {'%','A','L','L','U','S','E','R','S','P','R','O','F','I','L','E','%','\0'}
 
static const WCHAR PublicProfileW [] = {'%','P','U','B','L','I','C','%',0}
 
static const WCHAR UserProfileW [] = {'%','U','S','E','R','P','R','O','F','I','L','E','%','\0'}
 
static const WCHAR SystemDriveW [] = {'%','S','y','s','t','e','m','D','r','i','v','e','%','\0'}
 
static const WCHAR ProfileListW [] = {'S','o','f','t','w','a','r','e','\\','M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s',' ','N','T','\\','C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\','P','r','o','f','i','l','e','L','i','s','t',0}
 
static const WCHAR ProfilesDirectoryW [] = {'P','r','o','f','i','l','e','s','D','i','r','e','c','t','o','r','y',0}
 
static const WCHAR AllUsersProfileValueW [] = {'A','l','l','U','s','e','r','s','P','r','o','f','i','l','e','\0'}
 
static const WCHAR szSHFolders [] = {'S','o','f','t','w','a','r','e','\\','M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s','\\','C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\','E','x','p','l','o','r','e','r','\\','S','h','e','l','l',' ','F','o','l','d','e','r','s','\0'}
 
static const WCHAR szSHUserFolders [] = {'S','o','f','t','w','a','r','e','\\','M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s','\\','C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\','E','x','p','l','o','r','e','r','\\','U','s','e','r',' ','S','h','e','l','l',' ','F','o','l','d','e','r','s','\0'}
 
static const WCHAR szDefaultProfileDirW [] = {'u','s','e','r','s',0}
 
static const WCHAR szKnownFolderDescriptions [] = {'S','o','f','t','w','a','r','e','\\','M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s','\\','C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\','E','x','p','l','o','r','e','r','\\','F','o','l','d','e','r','D','e','s','c','r','i','p','t','i','o','n','s','\0'}
 
static const WCHAR szKnownFolderRedirections [] = {'S','o','f','t','w','a','r','e','\\','M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s','\\','C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\','E','x','p','l','o','r','e','r','\\','U','s','e','r',' ','S','h','e','l','l',' ','F','o','l','d','e','r','s',0}
 
static const WCHAR AllUsersW [] = {'P','u','b','l','i','c',0}
 
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 54 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 955 of file shellpath.c.

◆ CSIDL_CONTACTS

#define CSIDL_CONTACTS   0x0043

Definition at line 952 of file shellpath.c.

◆ CSIDL_DOWNLOADS

#define CSIDL_DOWNLOADS   0x0047

Definition at line 953 of file shellpath.c.

◆ CSIDL_LINKS

#define CSIDL_LINKS   0x004d

Definition at line 954 of file shellpath.c.

◆ CSIDL_SAVED_GAMES

#define CSIDL_SAVED_GAMES   0x0062

Definition at line 956 of file shellpath.c.

◆ CSIDL_SEARCHES

#define CSIDL_SEARCHES   0x0063

Definition at line 957 of file shellpath.c.

◆ WIN32_NO_STATUS

#define WIN32_NO_STATUS

Definition at line 28 of file shellpath.c.

Typedef Documentation

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

Function Documentation

◆ _GetUserSidStringFromToken()

static LPWSTR _GetUserSidStringFromToken ( HANDLE  Token)
static

Definition at line 2060 of file shellpath.c.

2061 {
2062  char InfoBuffer[64];
2063  PTOKEN_USER UserInfo;
2064  DWORD InfoSize;
2065  LPWSTR SidStr;
2066 
2067  UserInfo = (PTOKEN_USER) InfoBuffer;
2068  if (! GetTokenInformation(Token, TokenUser, InfoBuffer, sizeof(InfoBuffer),
2069  &InfoSize))
2070  {
2072  return NULL;
2073  UserInfo = HeapAlloc(GetProcessHeap(), 0, InfoSize);
2074  if (UserInfo == NULL)
2075  return NULL;
2076  if (! GetTokenInformation(Token, TokenUser, UserInfo, InfoSize,
2077  &InfoSize))
2078  {
2079  HeapFree(GetProcessHeap(), 0, UserInfo);
2080  return NULL;
2081  }
2082  }
2083 
2084  if (! ConvertSidToStringSidW(UserInfo->User.Sid, &SidStr))
2085  SidStr = NULL;
2086 
2087  if (UserInfo != (PTOKEN_USER) InfoBuffer)
2088  HeapFree(GetProcessHeap(), 0, UserInfo);
2089 
2090  return SidStr;
2091 }
_IRQL_requires_same_ _In_ PLSA_STRING _In_ SECURITY_LOGON_TYPE _In_ ULONG _In_ ULONG _In_opt_ PTOKEN_GROUPS _In_ PTOKEN_SOURCE _Out_ PVOID _Out_ PULONG _Inout_ PLUID _Out_ PHANDLE Token
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1040
BOOL WINAPI ConvertSidToStringSidW(PSID Sid, LPWSTR *StringSid)
Definition: security.c:3259
#define GetProcessHeap()
Definition: compat.h:595
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
unsigned long DWORD
Definition: ntddk_ex.h:95
#define NULL
Definition: types.h:112
BOOL WINAPI GetTokenInformation(HANDLE TokenHandle, TOKEN_INFORMATION_CLASS TokenInformationClass, LPVOID TokenInformation, DWORD TokenInformationLength, PDWORD ReturnLength)
Definition: security.c:413
struct _TOKEN_USER * PTOKEN_USER
SID_AND_ATTRIBUTES User
Definition: setypes.h:960
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define HeapFree(x, y, z)
Definition: compat.h:594
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10

Referenced by _SHGetUserProfilePath().

◆ _SHExpandEnvironmentStrings()

static HRESULT _SHExpandEnvironmentStrings ( LPCWSTR  szSrc,
LPWSTR  szDest 
)
static

Definition at line 2294 of file shellpath.c.

2298 {
2299  HRESULT hr;
2300 #ifndef __REACTOS__
2301  WCHAR szTemp[MAX_PATH], szProfilesPrefix[MAX_PATH] = { 0 };
2302  HKEY key = NULL;
2303 #else
2304  WCHAR szTemp[MAX_PATH];
2305 #endif
2306 
2307  TRACE("%s, %p\n", debugstr_w(szSrc), szDest);
2308 
2309  if (!szSrc || !szDest) return E_INVALIDARG;
2310 
2311  /* short-circuit if there's nothing to expand */
2312  if (szSrc[0] != '%')
2313  {
2314  strcpyW(szDest, szSrc);
2315  hr = S_OK;
2316  goto end;
2317  }
2318 #ifndef __REACTOS__
2319  /* Get the profile prefix, we'll probably be needing it */
2321  if (SUCCEEDED(hr))
2322  {
2323  WCHAR def_val[MAX_PATH];
2324 
2325  /* get the system drive */
2326  GetSystemDirectoryW(def_val, MAX_PATH);
2327  strcpyW( def_val + 3, szDefaultProfileDirW );
2328 
2329  hr = _SHGetProfilesValue(key, ProfilesDirectoryW, szProfilesPrefix, def_val );
2330  }
2331 #else
2332  hr = S_OK;
2333 #endif
2334 
2335  *szDest = 0;
2336  strcpyW(szTemp, szSrc);
2337  while (SUCCEEDED(hr) && szTemp[0] == '%')
2338  {
2340  {
2341 #ifndef __REACTOS__
2343 
2344  strcpyW(szDest, szProfilesPrefix);
2347  PathAppendW(szDest, szAllUsers);
2348 #else
2349  DWORD cchSize = cchDest;
2350  if (!GetAllUsersProfileDirectoryW(szDest, &cchSize))
2351  goto fallback_expand;
2352 #endif
2353  PathAppendW(szDest, szTemp + strlenW(AllUsersProfileW));
2354  }
2355 #ifndef __REACTOS__
2356  else if (!strncmpiW(szTemp, PublicProfileW, strlenW(PublicProfileW)))
2357  {
2358  WCHAR szAllUsers[MAX_PATH], def_val[MAX_PATH];
2359 
2360  GetSystemDirectoryW(def_val, MAX_PATH);
2361  strcpyW( def_val + 3, UsersPublicW );
2362 
2364  PathAppendW(szDest, szAllUsers);
2365  PathAppendW(szDest, szTemp + strlenW(PublicProfileW));
2366  }
2367 #endif
2368  else if (!strncmpiW(szTemp, UserProfileW, strlenW(UserProfileW)))
2369  {
2370 #ifndef __REACTOS__
2372  DWORD userLen = MAX_PATH;
2373 
2374  strcpyW(szDest, szProfilesPrefix);
2375  GetUserNameW(userName, &userLen);
2376  PathAppendW(szDest, userName);
2377 #else
2378  DWORD cchSize = cchDest;
2379  if (!_SHGetUserProfileDirectoryW(hToken, szDest, &cchSize))
2380  goto fallback_expand;
2381 #endif
2382  PathAppendW(szDest, szTemp + strlenW(UserProfileW));
2383  }
2384  else if (!strncmpiW(szTemp, SystemDriveW, strlenW(SystemDriveW)))
2385  {
2386 #ifndef __REACTOS__
2387  GetSystemDirectoryW(szDest, MAX_PATH);
2388 #else
2389  if (!GetSystemDirectoryW(szDest, cchDest))
2390  goto fallback_expand;
2391 #endif
2392  strcpyW(szDest + 3, szTemp + strlenW(SystemDriveW) + 1);
2393  }
2394  else
2395 #ifdef __REACTOS__
2396 fallback_expand:
2397 #endif
2398  {
2399 #ifndef __REACTOS__
2400  DWORD ret = ExpandEnvironmentStringsW(szTemp, szDest, MAX_PATH);
2401 #else
2402  DWORD ret = SHExpandEnvironmentStringsForUserW(hToken, szTemp, szDest, cchDest);
2403 #endif
2404 
2405 #ifndef __REACTOS__
2406  if (ret > MAX_PATH)
2407 #else
2408  if (ret > cchDest)
2409 #endif
2411  else if (ret == 0)
2413  else if (!strcmpW( szTemp, szDest )) break; /* nothing expanded */
2414  }
2415  if (SUCCEEDED(hr)) strcpyW(szTemp, szDest);
2416  }
2417 end:
2418 #ifndef __REACTOS__
2419  if (key)
2420  RegCloseKey(key);
2421 #endif
2422  TRACE("returning 0x%08x (input was %s, output is %s)\n", hr,
2423  debugstr_w(szSrc), debugstr_w(szDest));
2424  return hr;
2425 }
static const WCHAR PublicProfileW[]
Definition: shellpath.c:918
#define HRESULT_FROM_WIN32(x)
Definition: winerror.h:92
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
static const WCHAR UserProfileW[]
Definition: shellpath.c:920
HRESULT hr
Definition: shlfolder.c:183
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1040
static const WCHAR ProfilesDirectoryW[]
Definition: shellpath.c:924
#define strncmpiW(s1, s2, n)
Definition: unicode.h:40
BOOL WINAPI PathAppendW(LPWSTR lpszPath, LPCWSTR lpszAppend)
Definition: path.c:126
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
static const WCHAR PublicW[]
Definition: shellpath.c:892
BOOL _SHGetUserProfileDirectoryW(HANDLE hToken, LPWSTR szPath, LPDWORD lpcchPath)
Definition: shellpath.c:1839
if SUCCEEDED(hr)
#define debugstr_w
Definition: kernel32.h:32
static const WCHAR AllUsersProfileW[]
Definition: shellpath.c:916
#define E_INVALIDARG
Definition: ddrawi.h:101
static const WCHAR UsersPublicW[]
Definition: shellpath.c:911
static HRESULT _SHOpenProfilesKey(PHKEY pKey)
Definition: shellpath.c:2229
BOOL WINAPI GetUserNameW(LPWSTR lpszName, LPDWORD lpSize)
Definition: misc.c:291
#define TRACE(s)
Definition: solgame.cpp:4
static const WCHAR szAllUsers[]
Definition: msipriv.h:1138
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:79
static const WCHAR SystemDriveW[]
Definition: shellpath.c:921
#define MAX_PATH
Definition: compat.h:34
unsigned long DWORD
Definition: ntddk_ex.h:95
GLuint GLuint end
Definition: gl.h:1545
int ret
#define E_NOT_SUFFICIENT_BUFFER
Definition: winerror.h:2345
#define S_OK
Definition: intsafe.h:52
static const WCHAR szDefaultProfileDirW[]
Definition: shellpath.c:929
WINE_UNICODE_INLINE WCHAR * strcpyW(WCHAR *dst, const WCHAR *src)
Definition: unicode.h:219
BOOL WINAPI GetAllUsersProfileDirectoryW(_Out_opt_ LPWSTR lpProfileDir, _Inout_ LPDWORD lpcchSize)
Definition: profile.c:1310
static const WCHAR AllUsersW[]
Definition: shellpath.c:934
UINT WINAPI GetSystemDirectoryW(OUT LPWSTR lpBuffer, IN UINT uSize)
Definition: path.c:2312
static HRESULT _SHGetProfilesValue(HKEY profilesKey, LPCWSTR szValueName, LPWSTR szValue, LPCWSTR szDefault)
Definition: shellpath.c:2244
#define NULL
Definition: types.h:112
DWORD WINAPI ExpandEnvironmentStringsW(IN LPCWSTR lpSrc, IN LPWSTR lpDst, IN DWORD nSize)
Definition: environ.c:519
static const WCHAR userName[]
Definition: wnet.c:2154
static const WCHAR AllUsersProfileValueW[]
Definition: shellpath.c:925
WINE_UNICODE_INLINE int strcmpW(const WCHAR *str1, const WCHAR *str2)
Definition: unicode.h:229
Definition: path.c:41

Referenced by _SHGetUserShellFolderPath(), and SHGetFolderPathAndSubDirW().

◆ _SHGetAllUsersProfilePath()

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

Definition at line 2189 of file shellpath.c.

2191 {
2192  HRESULT hr;
2193 
2194  TRACE("0x%08x,0x%02x,%p\n", dwFlags, folder, pszPath);
2195 
2196  if (folder >= ARRAY_SIZE(CSIDL_Data))
2197  return E_INVALIDARG;
2199  return E_INVALIDARG;
2200  if (!pszPath)
2201  return E_INVALIDARG;
2202 
2204 #ifndef __REACTOS__
2205  hr = _SHGetDefaultValue(folder, pszPath);
2206 #else
2207  hr = _SHGetDefaultValue(NULL, folder, pszPath);
2208 #endif
2209  else
2210  {
2211 #ifndef __REACTOS__
2213 #else
2215 #endif
2216  CSIDL_Data[folder].szValueName, pszPath);
2217  if (FAILED(hr))
2218 #ifndef __REACTOS__
2219  hr = _SHGetDefaultValue(folder, pszPath);
2220 #else
2221  hr = _SHGetDefaultValue(NULL, folder, pszPath);
2222 #endif
2223  }
2224  TRACE("returning 0x%08x (output path is %s)\n", hr, debugstr_w(pszPath));
2225  return hr;
2226 }
Definition: fci.c:115
HRESULT hr
Definition: shlfolder.c:183
static const CSIDL_DATA CSIDL_Data[]
Definition: shellpath.c:969
#define debugstr_w
Definition: kernel32.h:32
#define E_INVALIDARG
Definition: ddrawi.h:101
#define TRACE(s)
Definition: solgame.cpp:4
LONG HRESULT
Definition: typedefs.h:79
static HRESULT _SHGetDefaultValue(BYTE folder, LPWSTR pszPath)
Definition: shellpath.c:1875
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
#define ARRAY_SIZE(a)
Definition: main.h:24
#define NULL
Definition: types.h:112
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
static HRESULT _SHGetUserShellFolderPath(HKEY rootKey, LPCWSTR userPrefix, LPCWSTR value, LPWSTR path)
Definition: shellpath.c:1756
#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 1991 of file shellpath.c.

1993 {
1994  HRESULT hr;
1995 
1996  TRACE("0x%08x,0x%02x,%p\n", dwFlags, folder, pszPath);
1997 
1998  if (folder >= ARRAY_SIZE(CSIDL_Data))
1999  return E_INVALIDARG;
2001  return E_INVALIDARG;
2002  if (!pszPath)
2003  return E_INVALIDARG;
2004 
2006 #ifndef __REACTOS__
2007  hr = _SHGetDefaultValue(folder, pszPath);
2008 #else
2009  hr = _SHGetDefaultValue(NULL, folder, pszPath);
2010 #endif
2011  else
2012  {
2013  HKEY hKey;
2014 
2016  hr = E_FAIL;
2017  else
2018  {
2019  DWORD dwType, dwPathLen = MAX_PATH * sizeof(WCHAR);
2020 
2021  if (RegQueryValueExW(hKey, CSIDL_Data[folder].szValueName, NULL,
2022  &dwType, (LPBYTE)pszPath, &dwPathLen) ||
2023  (dwType != REG_SZ && dwType != REG_EXPAND_SZ))
2024  {
2025 #ifndef __REACTOS__
2026  hr = _SHGetDefaultValue(folder, pszPath);
2027 #else
2028  hr = _SHGetDefaultValue(NULL, folder, pszPath);
2029 #endif
2030  dwType = REG_EXPAND_SZ;
2031  switch (folder)
2032  {
2035  /* these two should never be set on 32-bit setups */
2036  if (!is_win64)
2037  {
2038  BOOL is_wow64;
2040  if (!is_wow64) break;
2041  }
2042  /* fall through */
2043  default:
2044  RegSetValueExW(hKey, CSIDL_Data[folder].szValueName, 0, dwType,
2045  (LPBYTE)pszPath, (strlenW(pszPath)+1)*sizeof(WCHAR));
2046  }
2047  }
2048  else
2049  {
2050  pszPath[dwPathLen / sizeof(WCHAR)] = '\0';
2051  hr = S_OK;
2052  }
2053  RegCloseKey(hKey);
2054  }
2055  }
2056  TRACE("returning 0x%08x (output path is %s)\n", hr, debugstr_w(pszPath));
2057  return hr;
2058 }
Definition: fci.c:115
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
HRESULT hr
Definition: shlfolder.c:183
static const CSIDL_DATA CSIDL_Data[]
Definition: shellpath.c:969
static const WCHAR szCurrentVersion[]
Definition: shellpath.c:816
#define E_FAIL
Definition: ddrawi.h:102
#define CSIDL_PROGRAM_FILESX86
Definition: shlobj.h:2053
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:53
unsigned int BOOL
Definition: ntddk_ex.h:94
#define debugstr_w
Definition: kernel32.h:32
#define E_INVALIDARG
Definition: ddrawi.h:101
static const BOOL is_win64
Definition: shellpath.c:58
BOOL WINAPI IsWow64Process(IN HANDLE hProcess, OUT PBOOL Wow64Process)
Definition: proc.c:1975
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:4895
#define TRACE(s)
Definition: solgame.cpp:4
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4116
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:79
static BOOL is_wow64
Definition: loader.c:55
#define MAX_PATH
Definition: compat.h:34
unsigned long DWORD
Definition: ntddk_ex.h:95
static HRESULT _SHGetDefaultValue(BYTE folder, LPWSTR pszPath)
Definition: shellpath.c:1875
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
LONG WINAPI RegCreateKeyW(HKEY hKey, LPCWSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:1199
#define GetCurrentProcess()
Definition: compat.h:618
#define CSIDL_PROGRAM_FILES_COMMONX86
Definition: shlobj.h:2055
#define S_OK
Definition: intsafe.h:52
FxAutoRegKey hKey
#define ARRAY_SIZE(a)
Definition: main.h:24
#define REG_EXPAND_SZ
Definition: nt_native.h:1494
#define NULL
Definition: types.h:112
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
#define REG_SZ
Definition: layer.c:22

Referenced by SHGetFolderPathAndSubDirW().

◆ _SHGetDefaultValue()

static HRESULT _SHGetDefaultValue ( BYTE  folder,
LPWSTR  pszPath 
)
static

Definition at line 1875 of file shellpath.c.

1879 {
1880  HRESULT hr;
1881  WCHAR resourcePath[MAX_PATH];
1882 #ifdef __REACTOS__
1883  NT_PRODUCT_TYPE ProductType;
1884 #endif
1885 
1886  TRACE("0x%02x,%p\n", folder, pszPath);
1887 
1888  if (folder >= ARRAY_SIZE(CSIDL_Data))
1889  return E_INVALIDARG;
1890 
1891  if (!pszPath)
1892  return E_INVALIDARG;
1893 
1894 #ifdef __REACTOS__
1895  if (hToken != NULL && hToken != (HANDLE)-1)
1896  {
1897  FIXME("unsupported for user other than current or default\n");
1898  }
1899 #endif
1900 
1901  if (!is_win64)
1902  {
1903  BOOL is_wow64;
1904 
1905  switch (folder)
1906  {
1907  case CSIDL_PROGRAM_FILES:
1911  break;
1916  break;
1917  }
1918  }
1919 
1920  switch (CSIDL_Data[folder].type)
1921  {
1922  case CSIDL_Type_User:
1923  strcpyW(pszPath, UserProfileW);
1924  break;
1925 #ifdef __REACTOS__
1926  case CSIDL_Type_InMyDocuments:
1927  strcpyW(pszPath, UserProfileW);
1928  if (DoGetProductType(&ProductType) && ProductType == NtProductWinNt)
1929  {
1930  if (IS_INTRESOURCE(CSIDL_Data[CSIDL_MYDOCUMENTS].szDefaultPath))
1931  {
1932  WCHAR szItem[MAX_PATH];
1934  LOWORD(CSIDL_Data[CSIDL_MYDOCUMENTS].szDefaultPath),
1935  szItem, ARRAY_SIZE(szItem));
1936  PathAppendW(pszPath, szItem);
1937  }
1938  else
1939  {
1940  PathAppendW(pszPath, CSIDL_Data[CSIDL_MYDOCUMENTS].szDefaultPath);
1941  }
1942  }
1943  break;
1944 #endif
1945  case CSIDL_Type_AllUsers:
1946 #ifndef __REACTOS__
1947  strcpyW(pszPath, PublicProfileW);
1948 #else
1949  strcpyW(pszPath, AllUsersProfileW);
1950 #endif
1951  break;
1952  case CSIDL_Type_CurrVer:
1953  strcpyW(pszPath, SystemDriveW);
1954  break;
1955  default:
1956  ; /* no corresponding env. var, do nothing */
1957  }
1958 
1959  hr = S_OK;
1960  if (CSIDL_Data[folder].szDefaultPath)
1961  {
1962  if (IS_INTRESOURCE(CSIDL_Data[folder].szDefaultPath))
1963  {
1965  LOWORD(CSIDL_Data[folder].szDefaultPath), resourcePath, MAX_PATH))
1966  {
1967  PathAppendW(pszPath, resourcePath);
1968  }
1969  else
1970  {
1971  ERR("(%d,%s), LoadString failed, missing translation?\n", folder,
1972  debugstr_w(pszPath));
1973  hr = E_FAIL;
1974  }
1975  }
1976  else
1977  {
1978  PathAppendW(pszPath, CSIDL_Data[folder].szDefaultPath);
1979  }
1980  }
1981  TRACE("returning 0x%08x\n", hr);
1982  return hr;
1983 }
static const WCHAR PublicProfileW[]
Definition: shellpath.c:918
Definition: fci.c:115
static const WCHAR UserProfileW[]
Definition: shellpath.c:920
HRESULT hr
Definition: shlfolder.c:183
static const CSIDL_DATA CSIDL_Data[]
Definition: shellpath.c:969
#define CSIDL_PROGRAM_FILES
Definition: shlobj.h:2049
#define E_FAIL
Definition: ddrawi.h:102
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
BOOL WINAPI PathAppendW(LPWSTR lpszPath, LPCWSTR lpszAppend)
Definition: path.c:126
#define CSIDL_PROGRAM_FILESX86
Definition: shlobj.h:2053
#define CSIDL_MYDOCUMENTS
Definition: shlobj.h:2024
unsigned int BOOL
Definition: ntddk_ex.h:94
#define debugstr_w
Definition: kernel32.h:32
#define FIXME(fmt,...)
Definition: debug.h:111
static const WCHAR AllUsersProfileW[]
Definition: shellpath.c:916
#define E_INVALIDARG
Definition: ddrawi.h:101
static const BOOL is_win64
Definition: shellpath.c:58
BOOL WINAPI IsWow64Process(IN HANDLE hProcess, OUT PBOOL Wow64Process)
Definition: proc.c:1975
#define TRACE(s)
Definition: solgame.cpp:4
#define IS_INTRESOURCE(i)
Definition: winuser.h:580
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:79
static const WCHAR SystemDriveW[]
Definition: shellpath.c:921
static BOOL is_wow64
Definition: loader.c:55
#define MAX_PATH
Definition: compat.h:34
#define GetCurrentProcess()
Definition: compat.h:618
#define CSIDL_PROGRAM_FILES_COMMONX86
Definition: shlobj.h:2055
#define CSIDL_PROGRAM_FILES_COMMON
Definition: shlobj.h:2054
#define ERR(fmt,...)
Definition: debug.h:110
#define S_OK
Definition: intsafe.h:52
WINE_UNICODE_INLINE WCHAR * strcpyW(WCHAR *dst, const WCHAR *src)
Definition: unicode.h:219
#define shell32_hInstance
#define ARRAY_SIZE(a)
Definition: main.h:24
#define NULL
Definition: types.h:112
enum _NT_PRODUCT_TYPE NT_PRODUCT_TYPE
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
#define LOWORD(l)
Definition: pedump.c:82

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

◆ _SHGetProfilesValue()

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

Definition at line 2244 of file shellpath.c.

2246 {
2247  HRESULT hr;
2248  DWORD type, dwPathLen = MAX_PATH * sizeof(WCHAR);
2249  LONG lRet;
2250 
2251  TRACE("%p,%s,%p,%s\n", profilesKey, debugstr_w(szValueName), szValue,
2252  debugstr_w(szDefault));
2253  lRet = RegQueryValueExW(profilesKey, szValueName, NULL, &type,
2254  (LPBYTE)szValue, &dwPathLen);
2255  if (!lRet && (type == REG_SZ || type == REG_EXPAND_SZ) && dwPathLen
2256  && *szValue)
2257  {
2258  dwPathLen /= sizeof(WCHAR);
2259  szValue[dwPathLen] = '\0';
2260  hr = S_OK;
2261  }
2262  else
2263  {
2264  /* Missing or invalid value, set a default */
2265  lstrcpynW(szValue, szDefault, MAX_PATH);
2266  TRACE("Setting missing value %s to %s\n", debugstr_w(szValueName),
2267  debugstr_w(szValue));
2268  lRet = RegSetValueExW(profilesKey, szValueName, 0, REG_EXPAND_SZ,
2269  (LPBYTE)szValue,
2270  (strlenW(szValue) + 1) * sizeof(WCHAR));
2271  if (lRet)
2272  hr = HRESULT_FROM_WIN32(lRet);
2273  else
2274  hr = S_OK;
2275  }
2276  TRACE("returning 0x%08x (output value is %s)\n", hr, debugstr_w(szValue));
2277  return hr;
2278 }
#define HRESULT_FROM_WIN32(x)
Definition: winerror.h:92
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
HRESULT hr
Definition: shlfolder.c:183
#define lstrcpynW
Definition: compat.h:597
unsigned char * LPBYTE
Definition: typedefs.h:53
long LONG
Definition: pedump.c:60
#define debugstr_w
Definition: kernel32.h:32
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:4895
#define TRACE(s)
Definition: solgame.cpp:4
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4116
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:79
#define MAX_PATH
Definition: compat.h:34
unsigned long DWORD
Definition: ntddk_ex.h:95
#define S_OK
Definition: intsafe.h:52
#define REG_EXPAND_SZ
Definition: nt_native.h:1494
#define NULL
Definition: types.h:112
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
#define REG_SZ
Definition: layer.c:22

Referenced by _SHExpandEnvironmentStrings().

◆ _SHGetUserProfileDirectoryW()

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

Definition at line 1839 of file shellpath.c.

1840 {
1841  BOOL result;
1842  if (!hToken)
1843  {
1845  result = GetUserProfileDirectoryW(hToken, szPath, lpcchPath);
1846  CloseHandle(hToken);
1847  }
1848  else if ((INT) hToken == -1)
1849  {
1851  }
1852  else
1853  {
1854  result = GetUserProfileDirectoryW(hToken, szPath, lpcchPath);
1855  }
1856  TRACE("_SHGetUserProfileDirectoryW returning %S\n", szPath);
1857  return result;
1858 }
BOOL WINAPI GetDefaultUserProfileDirectoryW(_Out_opt_ LPWSTR lpProfileDir, _Inout_ LPDWORD lpcchSize)
Definition: profile.c:1443
#define CloseHandle
Definition: compat.h:598
GLuint64EXT * result
Definition: glext.h:11304
BOOL WINAPI GetUserProfileDirectoryW(_In_ HANDLE hToken, _Out_opt_ LPWSTR lpProfileDir, _Inout_ LPDWORD lpcchSize)
Definition: profile.c:1792
int32_t INT
Definition: typedefs.h:58
unsigned int BOOL
Definition: ntddk_ex.h:94
#define TRACE(s)
Definition: solgame.cpp:4
#define TOKEN_QUERY
Definition: setypes.h:878
#define GetCurrentProcess()
Definition: compat.h:618
LPCWSTR szPath
Definition: env.c:37
BOOL WINAPI OpenProcessToken(HANDLE ProcessHandle, DWORD DesiredAccess, PHANDLE TokenHandle)
Definition: security.c:296

Referenced by _SHExpandEnvironmentStrings().

◆ _SHGetUserProfilePath()

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

Definition at line 2101 of file shellpath.c.

2103 {
2104  const WCHAR *szValueName;
2105  WCHAR buffer[40];
2106  HRESULT hr;
2107 
2108  TRACE("%p,0x%08x,0x%02x,%p\n", hToken, dwFlags, folder, pszPath);
2109 
2110  if (folder >= ARRAY_SIZE(CSIDL_Data))
2111  return E_INVALIDARG;
2112 #ifdef __REACTOS__
2114  CSIDL_Data[folder].type != CSIDL_Type_InMyDocuments)
2115 #else
2117 #endif
2118  {
2119  return E_INVALIDARG;
2120  }
2121  if (!pszPath)
2122  return E_INVALIDARG;
2123 
2125  {
2126 #ifndef __REACTOS__
2127  hr = _SHGetDefaultValue(folder, pszPath);
2128 #else
2129  hr = _SHGetDefaultValue(hToken, folder, pszPath);
2130 #endif
2131  }
2132  else
2133  {
2134  LPCWSTR userPrefix = NULL;
2135  HKEY hRootKey;
2136 
2137  if (hToken == (HANDLE)-1)
2138  {
2139  hRootKey = HKEY_USERS;
2140  userPrefix = DefaultW;
2141  }
2142  else if (hToken == NULL)
2143  hRootKey = HKEY_CURRENT_USER;
2144  else
2145  {
2146  hRootKey = HKEY_USERS;
2147  userPrefix = _GetUserSidStringFromToken(hToken);
2148  if (userPrefix == NULL)
2149  {
2150  hr = E_FAIL;
2151  goto error;
2152  }
2153  }
2154 
2155  /* For CSIDL_Type_User we also use the GUID if no szValueName is provided */
2156  szValueName = CSIDL_Data[folder].szValueName;
2157  if (!szValueName)
2158  {
2160  szValueName = &buffer[0];
2161  }
2162 
2163 #ifndef __REACTOS__
2164  hr = _SHGetUserShellFolderPath(hRootKey, userPrefix, szValueName, pszPath);
2165  if (FAILED(hr) && hRootKey != HKEY_LOCAL_MACHINE)
2166  hr = _SHGetUserShellFolderPath(HKEY_LOCAL_MACHINE, NULL, szValueName, pszPath);
2167  if (FAILED(hr))
2168  hr = _SHGetDefaultValue(folder, pszPath);
2169 #else
2170  hr = _SHGetUserShellFolderPath(hRootKey, hToken, userPrefix, szValueName, pszPath);
2171  if (FAILED(hr) && hRootKey != HKEY_LOCAL_MACHINE)
2172  hr = _SHGetUserShellFolderPath(HKEY_LOCAL_MACHINE, hToken, NULL, szValueName, pszPath);
2173  if (FAILED(hr))
2174  hr = _SHGetDefaultValue(hToken, folder, pszPath);
2175 #endif
2176  if (userPrefix != NULL && userPrefix != DefaultW)
2177  LocalFree((HLOCAL) userPrefix);
2178  }
2179 error:
2180  TRACE("returning 0x%08x (output path is %s)\n", hr, debugstr_w(pszPath));
2181  return hr;
2182 }
#define HKEY_USERS
Definition: winreg.h:13
Definition: fci.c:115
HRESULT hr
Definition: shlfolder.c:183
#define error(str)
Definition: mkdosfs.c:1605
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
#define HKEY_CURRENT_USER
Definition: winreg.h:11
static const CSIDL_DATA CSIDL_Data[]
Definition: shellpath.c:969
GLuint buffer
Definition: glext.h:5915
#define E_FAIL
Definition: ddrawi.h:102
#define debugstr_w
Definition: kernel32.h:32
#define E_INVALIDARG
Definition: ddrawi.h:101
struct CFFOLDER folder
Definition: fdi.c:102
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:79
INT WINAPI StringFromGUID2(REFGUID id, LPOLESTR str, INT cmax)
Definition: compobj.c:2434
static HRESULT _SHGetDefaultValue(BYTE folder, LPWSTR pszPath)
Definition: shellpath.c:1875
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
#define ARRAY_SIZE(a)
Definition: main.h:24
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1577
static LPWSTR _GetUserSidStringFromToken(HANDLE Token)
Definition: shellpath.c:2060
#define NULL
Definition: types.h:112
LPCWSTR szValueName
Definition: shellpath.c:964
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
static HRESULT _SHGetUserShellFolderPath(HKEY rootKey, LPCWSTR userPrefix, LPCWSTR value, LPWSTR path)
Definition: shellpath.c:1756
static const WCHAR DefaultW[]
Definition: shellpath.c:915
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12

Referenced by _SHRegisterFolders(), and SHGetFolderPathAndSubDirW().

◆ _SHGetUserShellFolderPath()

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

Definition at line 1756 of file shellpath.c.

1761 {
1762  HRESULT hr;
1763  WCHAR shellFolderPath[MAX_PATH], userShellFolderPath[MAX_PATH];
1764  LPCWSTR pShellFolderPath, pUserShellFolderPath;
1765  HKEY userShellFolderKey, shellFolderKey;
1766  DWORD dwType, dwPathLen;
1767 
1768  TRACE("%p,%s,%s,%p\n",rootKey, debugstr_w(userPrefix), debugstr_w(value),
1769  path);
1770 
1771  if (userPrefix)
1772  {
1773  strcpyW(shellFolderPath, userPrefix);
1774  PathAddBackslashW(shellFolderPath);
1775  strcatW(shellFolderPath, szSHFolders);
1776  pShellFolderPath = shellFolderPath;
1777  strcpyW(userShellFolderPath, userPrefix);
1778  PathAddBackslashW(userShellFolderPath);
1779  strcatW(userShellFolderPath, szSHUserFolders);
1780  pUserShellFolderPath = userShellFolderPath;
1781  }
1782  else
1783  {
1784  pUserShellFolderPath = szSHUserFolders;
1785  pShellFolderPath = szSHFolders;
1786  }
1787 
1788  if (RegCreateKeyW(rootKey, pShellFolderPath, &shellFolderKey))
1789  {
1790  TRACE("Failed to create %s\n", debugstr_w(pShellFolderPath));
1791  return E_FAIL;
1792  }
1793  if (RegCreateKeyW(rootKey, pUserShellFolderPath, &userShellFolderKey))
1794  {
1795  TRACE("Failed to create %s\n",
1796  debugstr_w(pUserShellFolderPath));
1797  RegCloseKey(shellFolderKey);
1798  return E_FAIL;
1799  }
1800 
1801  dwPathLen = MAX_PATH * sizeof(WCHAR);
1802  if (!RegQueryValueExW(userShellFolderKey, value, NULL, &dwType,
1803  (LPBYTE)path, &dwPathLen) && (dwType == REG_EXPAND_SZ || dwType == REG_SZ))
1804  {
1805  LONG ret;
1806 
1807  path[dwPathLen / sizeof(WCHAR)] = '\0';
1808  if (dwType == REG_EXPAND_SZ && path[0] == '%')
1809  {
1810  WCHAR szTemp[MAX_PATH];
1811 
1812 #ifndef __REACTOS__
1814 #else
1815  hr = _SHExpandEnvironmentStrings(hToken, path, szTemp, _countof(szTemp));
1816  if (FAILED(hr))
1817  goto end;
1818 #endif
1819  lstrcpynW(path, szTemp, MAX_PATH);
1820  }
1821  ret = RegSetValueExW(shellFolderKey, value, 0, REG_SZ, (LPBYTE)path,
1822  (strlenW(path) + 1) * sizeof(WCHAR));
1823  if (ret != ERROR_SUCCESS)
1825  else
1826  hr = S_OK;
1827  }
1828  else
1829  hr = E_FAIL;
1830 #ifdef __REACTOS__
1831 end:
1832 #endif
1833  RegCloseKey(shellFolderKey);
1834  RegCloseKey(userShellFolderKey);
1835  TRACE("returning 0x%08x\n", hr);
1836  return hr;
1837 }
Definition: pdh_main.c:93
#define HRESULT_FROM_WIN32(x)
Definition: winerror.h:92
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
#define ERROR_SUCCESS
Definition: deptool.c:10
HRESULT hr
Definition: shlfolder.c:183
static HRESULT _SHExpandEnvironmentStrings(LPCWSTR szSrc, LPWSTR szDest)
Definition: shellpath.c:2294
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
#define E_FAIL
Definition: ddrawi.h:102
#define lstrcpynW
Definition: compat.h:597
static const WCHAR szSHUserFolders[]
Definition: shellpath.c:928
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:53
LPWSTR WINAPI PathAddBackslashW(LPWSTR lpszPath)
Definition: path.c:294
long LONG
Definition: pedump.c:60
#define debugstr_w
Definition: kernel32.h:32
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:4895
#define TRACE(s)
Definition: solgame.cpp:4
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4116
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:79
#define _countof(array)
Definition: sndvol32.h:68
#define MAX_PATH
Definition: compat.h:34
unsigned long DWORD
Definition: ntddk_ex.h:95
GLuint GLuint end
Definition: gl.h:1545
int ret
LONG WINAPI RegCreateKeyW(HKEY hKey, LPCWSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:1199
#define S_OK
Definition: intsafe.h:52
WINE_UNICODE_INLINE WCHAR * strcpyW(WCHAR *dst, const WCHAR *src)
Definition: unicode.h:219
#define REG_EXPAND_SZ
Definition: nt_native.h:1494
WINE_UNICODE_INLINE WCHAR * strcatW(WCHAR *dst, const WCHAR *src)
Definition: unicode.h:242
#define NULL
Definition: types.h:112
static const WCHAR szSHFolders[]
Definition: shellpath.c:927
#define REG_SZ
Definition: layer.c:22

Referenced by _SHGetAllUsersProfilePath(), and _SHGetUserProfilePath().

◆ _SHOpenProfilesKey()

static HRESULT _SHOpenProfilesKey ( PHKEY  pKey)
static

Definition at line 2229 of file shellpath.c.

2230 {
2231  LONG lRet;
2232  DWORD disp;
2233 
2235  KEY_ALL_ACCESS, NULL, pKey, &disp);
2236  return HRESULT_FROM_WIN32(lRet);
2237 }
#define HRESULT_FROM_WIN32(x)
Definition: winerror.h:92
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:1091
long LONG
Definition: pedump.c:60
unsigned long DWORD
Definition: ntddk_ex.h:95
FxRegKey * pKey
#define KEY_ALL_ACCESS
Definition: nt_native.h:1041
static const WCHAR ProfileListW[]
Definition: shellpath.c:923
#define NULL
Definition: types.h:112
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12

Referenced by _SHExpandEnvironmentStrings().

◆ _SHRegisterCommonShellFolders()

static HRESULT _SHRegisterCommonShellFolders ( void  )
static

Definition at line 2892 of file shellpath.c.

2893 {
2894  static const UINT folders[] = {
2907  };
2908  HRESULT hr;
2909 
2910  TRACE("\n");
2912  szSHFolders, folders, ARRAY_SIZE(folders));
2913  TRACE("returning 0x%08x\n", hr);
2914  return hr;
2915 }
HRESULT hr
Definition: shlfolder.c:183
#define CSIDL_COMMON_DESKTOPDIRECTORY
Definition: shlobj.h:2036
#define CSIDL_COMMON_FAVORITES
Definition: shlobj.h:2042
static HRESULT _SHRegisterFolders(HKEY hRootKey, HANDLE hToken, LPCWSTR szUserShellFolderPath, LPCWSTR szShellFolderPath, const UINT folders[], UINT foldersLen)
Definition: shellpath.c:2722
#define CSIDL_COMMON_STARTUP
Definition: shlobj.h:2035
#define CSIDL_COMMON_PICTURES
Definition: shlobj.h:2062
#define CSIDL_COMMON_TEMPLATES
Definition: shlobj.h:2056
static const WCHAR szSHUserFolders[]
Definition: shellpath.c:928
#define CSIDL_COMMON_PROGRAMS
Definition: shlobj.h:2034
#define CSIDL_COMMON_STARTMENU
Definition: shlobj.h:2033
#define CSIDL_COMMON_ADMINTOOLS
Definition: shlobj.h:2058
#define TRACE(s)
Definition: solgame.cpp:4
LONG HRESULT
Definition: typedefs.h:79
#define CSIDL_COMMON_VIDEO
Definition: shlobj.h:2063
#define CSIDL_COMMON_APPDATA
Definition: shlobj.h:2046
#define CSIDL_COMMON_MUSIC
Definition: shlobj.h:2061
#define ARRAY_SIZE(a)
Definition: main.h:24
#define CSIDL_COMMON_DOCUMENTS
Definition: shlobj.h:2057
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
static const WCHAR szSHFolders[]
Definition: shellpath.c:927
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12

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

2725 {
2726  const WCHAR *szValueName;
2727  WCHAR buffer[40];
2728  UINT i;
2729  WCHAR path[MAX_PATH];
2730  HRESULT hr = S_OK;
2731  HKEY hUserKey = NULL, hKey = NULL;
2732  DWORD dwType, dwPathLen;
2733  LONG ret;
2734 
2735  TRACE("%p,%p,%s,%p,%u\n", hRootKey, hToken,
2736  debugstr_w(szUserShellFolderPath), folders, foldersLen);
2737 
2738  ret = RegCreateKeyW(hRootKey, szUserShellFolderPath, &hUserKey);
2739  if (ret)
2741  else
2742  {
2743  ret = RegCreateKeyW(hRootKey, szShellFolderPath, &hKey);
2744  if (ret)
2746  }
2747  for (i = 0; SUCCEEDED(hr) && i < foldersLen; i++)
2748  {
2749  dwPathLen = MAX_PATH * sizeof(WCHAR);
2750 
2751  /* For CSIDL_Type_User we also use the GUID if no szValueName is provided */
2752  szValueName = CSIDL_Data[folders[i]].szValueName;
2753 #ifdef __REACTOS__
2754  if (!szValueName &&
2755  (CSIDL_Data[folders[i]].type == CSIDL_Type_User ||
2756  CSIDL_Data[folders[i]].type == CSIDL_Type_InMyDocuments))
2757 #else
2758  if (!szValueName && CSIDL_Data[folders[i]].type == CSIDL_Type_User)
2759 #endif
2760  {
2761  StringFromGUID2( CSIDL_Data[folders[i]].id, buffer, 39 );
2762  szValueName = &buffer[0];
2763  }
2764 
2765  if (!RegQueryValueExW(hUserKey, szValueName, NULL,
2766  &dwType, (LPBYTE)path, &dwPathLen) &&
2767  (dwType == REG_SZ || dwType == REG_EXPAND_SZ))
2768  {
2769  hr = SHGetFolderPathW(NULL, folders[i] | CSIDL_FLAG_CREATE,
2770  hToken, SHGFP_TYPE_CURRENT, path);
2771  }
2772  else
2773  {
2774  *path = '\0';
2775 #ifdef __REACTOS__
2776  if (CSIDL_Data[folders[i]].type == CSIDL_Type_User ||
2777  CSIDL_Data[folders[i]].type == CSIDL_Type_InMyDocuments)
2778 #else
2779  if (CSIDL_Data[folders[i]].type == CSIDL_Type_User)
2780 #endif
2781  _SHGetUserProfilePath(hToken, SHGFP_TYPE_CURRENT, folders[i],
2782  path);
2783  else if (CSIDL_Data[folders[i]].type == CSIDL_Type_AllUsers)
2785  else if (CSIDL_Data[folders[i]].type == CSIDL_Type_WindowsPath)
2786  {
2788  if (CSIDL_Data[folders[i]].szDefaultPath &&
2789  !IS_INTRESOURCE(CSIDL_Data[folders[i]].szDefaultPath))
2790  {
2792  strcatW(path, CSIDL_Data[folders[i]].szDefaultPath);
2793  }
2794  }
2795  else
2796  hr = E_FAIL;
2797  if (*path)
2798  {
2799  ret = RegSetValueExW(hUserKey, szValueName, 0, REG_EXPAND_SZ,
2800  (LPBYTE)path, (strlenW(path) + 1) * sizeof(WCHAR));
2801  if (ret)
2803  else
2804  {
2805  hr = SHGetFolderPathW(NULL, folders[i] | CSIDL_FLAG_CREATE,
2806  hToken, SHGFP_TYPE_CURRENT, path);
2807  ret = RegSetValueExW(hKey, szValueName, 0, REG_SZ,
2808  (LPBYTE)path, (strlenW(path) + 1) * sizeof(WCHAR));
2809  if (ret)
2811  }
2812  }
2813  }
2814  }
2815  if (hUserKey)
2816  RegCloseKey(hUserKey);
2817  if (hKey)
2818  RegCloseKey(hKey);
2819 
2820  TRACE("returning 0x%08x\n", hr);
2821  return hr;
2822 }
#define HRESULT_FROM_WIN32(x)
Definition: winerror.h:92
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
HRESULT hr
Definition: shlfolder.c:183
static const CSIDL_DATA CSIDL_Data[]
Definition: shellpath.c:969
GLuint buffer
Definition: glext.h:5915
#define E_FAIL
Definition: ddrawi.h:102
UINT WINAPI GetWindowsDirectoryW(OUT LPWSTR lpBuffer, IN UINT uSize)
Definition: path.c:2351
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:53
LPWSTR WINAPI PathAddBackslashW(LPWSTR lpszPath)
Definition: path.c:294
long LONG
Definition: pedump.c:60
if SUCCEEDED(hr)
#define debugstr_w
Definition: kernel32.h:32
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:4895
#define TRACE(s)
Definition: solgame.cpp:4
#define IS_INTRESOURCE(i)
Definition: winuser.h:580
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4116
__wchar_t WCHAR
Definition: xmlstorage.h:180
static HRESULT _SHGetUserProfilePath(HANDLE hToken, DWORD dwFlags, BYTE folder, LPWSTR pszPath)
Definition: shellpath.c:2101
LONG HRESULT
Definition: typedefs.h:79
#define MAX_PATH
Definition: compat.h:34
INT WINAPI StringFromGUID2(REFGUID id, LPOLESTR str, INT cmax)
Definition: compobj.c:2434
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
static HRESULT _SHGetAllUsersProfilePath(DWORD dwFlags, BYTE folder, LPWSTR pszPath)
Definition: shellpath.c:2189
LONG WINAPI RegCreateKeyW(HKEY hKey, LPCWSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:1199
#define S_OK
Definition: intsafe.h:52
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
FxAutoRegKey hKey
#define REG_EXPAND_SZ
Definition: nt_native.h:1494
WINE_UNICODE_INLINE WCHAR * strcatW(WCHAR *dst, const WCHAR *src)
Definition: unicode.h:242
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
#define CSIDL_FLAG_CREATE
HRESULT WINAPI SHGetFolderPathW(HWND hwndOwner, int nFolder, HANDLE hToken, DWORD dwFlags, LPWSTR pszPath)
Definition: shellpath.c:2447
LPCWSTR szValueName
Definition: shellpath.c:964
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
#define REG_SZ
Definition: layer.c:22

Referenced by _SHRegisterCommonShellFolders(), and _SHRegisterUserShellFolders().

◆ _SHRegisterUserShellFolders()

static HRESULT _SHRegisterUserShellFolders ( BOOL  bDefault)
static

Definition at line 2824 of file shellpath.c.

2825 {
2826  static const UINT folders[] = {
2830  CSIDL_APPDATA,
2831  CSIDL_STARTUP,
2832  CSIDL_RECENT,
2833  CSIDL_SENDTO,
2835  CSIDL_MYMUSIC,
2836  CSIDL_MYVIDEO,
2838  CSIDL_NETHOOD,
2843  CSIDL_COOKIES,
2844  CSIDL_HISTORY,
2846  CSIDL_FONTS,
2848 /* Cannot use #if _WIN32_WINNT >= 0x0600 because _WIN32_WINNT == 0x0600 here. */
2849 #ifndef __REACTOS__
2852  CSIDL_LINKS,
2856 #endif
2857  };
2858  WCHAR userShellFolderPath[MAX_PATH], shellFolderPath[MAX_PATH];
2859  LPCWSTR pUserShellFolderPath, pShellFolderPath;
2860  HRESULT hr = S_OK;
2861  HKEY hRootKey;
2862  HANDLE hToken;
2863 
2864  TRACE("%s\n", bDefault ? "TRUE" : "FALSE");
2865  if (bDefault)
2866  {
2867  hToken = (HANDLE)-1;
2868  hRootKey = HKEY_USERS;
2869  strcpyW(userShellFolderPath, DefaultW);
2870  PathAddBackslashW(userShellFolderPath);
2871  strcatW(userShellFolderPath, szSHUserFolders);
2872  pUserShellFolderPath = userShellFolderPath;
2873  strcpyW(shellFolderPath, DefaultW);
2874  PathAddBackslashW(shellFolderPath);
2875  strcatW(shellFolderPath, szSHFolders);
2876  pShellFolderPath = shellFolderPath;
2877  }
2878  else
2879  {
2880  hToken = NULL;
2881  hRootKey = HKEY_CURRENT_USER;
2882  pUserShellFolderPath = szSHUserFolders;
2883  pShellFolderPath = szSHFolders;
2884  }
2885 
2886  hr = _SHRegisterFolders(hRootKey, hToken, pUserShellFolderPath,
2887  pShellFolderPath, folders, ARRAY_SIZE(folders));
2888  TRACE("returning 0x%08x\n", hr);
2889  return hr;
2890 }
#define HKEY_USERS
Definition: winreg.h:13
#define CSIDL_COOKIES
Definition: shlobj.h:2044
#define CSIDL_MYVIDEO
Definition: shlobj.h:2026
HRESULT hr
Definition: shlfolder.c:183
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
#define CSIDL_MYPICTURES
Definition: shlobj.h:2050
#define CSIDL_CONTACTS
Definition: shellpath.c:952
#define HKEY_CURRENT_USER
Definition: winreg.h:11
static HRESULT _SHRegisterFolders(HKEY hRootKey, HANDLE hToken, LPCWSTR szUserShellFolderPath, LPCWSTR szShellFolderPath, const UINT folders[], UINT foldersLen)
Definition: shellpath.c:2722
#define CSIDL_HISTORY
Definition: shlobj.h:2045
#define CSIDL_FONTS
Definition: shlobj.h:2031
#define CSIDL_INTERNET_CACHE
Definition: shlobj.h:2043
static const WCHAR szSHUserFolders[]
Definition: shellpath.c:928
#define CSIDL_RECENT
Definition: shlobj.h:2020
#define CSIDL_FAVORITES
Definition: shlobj.h:2018
LPWSTR WINAPI PathAddBackslashW(LPWSTR lpszPath)
Definition: path.c:294
#define CSIDL_SEARCHES
Definition: shellpath.c:957
#define TRACE(s)
Definition: solgame.cpp:4
#define CSIDL_ADMINTOOLS
Definition: shlobj.h:2059
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:79
#define CSIDL_LOCAL_APPDATA
Definition: shlobj.h:2039
#define CSIDL_SENDTO
Definition: shlobj.h:2021
#define CSIDL_APPDATA
Definition: shlobj.h:2037
#define MAX_PATH
Definition: compat.h:34
static HANDLE
Definition: shellpath.c:88
#define CSIDL_STARTUP
Definition: shlobj.h:2019
#define CSIDL_LINKS
Definition: shellpath.c:954
#define CSIDL_APPDATA_LOCALLOW
Definition: shellpath.c:955
#define S_OK
Definition: intsafe.h:52
WINE_UNICODE_INLINE WCHAR * strcpyW(WCHAR *dst, const WCHAR *src)
Definition: unicode.h:219
#define CSIDL_DOWNLOADS
Definition: shellpath.c:953
#define ARRAY_SIZE(a)
Definition: main.h:24
#define CSIDL_PRINTHOOD
Definition: shlobj.h:2038
WINE_UNICODE_INLINE WCHAR * strcatW(WCHAR *dst, const WCHAR *src)
Definition: unicode.h:242
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
#define CSIDL_SAVED_GAMES
Definition: shellpath.c:956
#define CSIDL_NETHOOD
Definition: shlobj.h:2030
static const WCHAR szSHFolders[]
Definition: shellpath.c:927
#define CSIDL_PERSONAL
Definition: shlobj.h:2017
#define CSIDL_STARTMENU
Definition: shlobj.h:2023
#define CSIDL_DESKTOPDIRECTORY
Definition: shlobj.h:2027
#define CSIDL_PROGRAMS
Definition: shlobj.h:2014
#define CSIDL_TEMPLATES
Definition: shlobj.h:2032
static const WCHAR DefaultW[]
Definition: shellpath.c:915
#define CSIDL_MYMUSIC
Definition: shlobj.h:2025

Referenced by SHELL_RegisterShellFolders().

◆ GetShortPathNameAbsentW()

static DWORD GetShortPathNameAbsentW ( LPCWSTR  pszLong,
LPWSTR  pszShort,
DWORD  cchShort 
)
static

Definition at line 149 of file shellpath.c.

150 {
151  FIXME("GetShortPathNameAbsentW(%ls, %p, %ld): stub\n", pszLong, pszShort, cchShort);
152  StringCchCopyW(pszShort, cchShort, pszLong);
153  return lstrlenW(pszShort);
154 }
#define lstrlenW
Definition: compat.h:609
STRSAFEAPI StringCchCopyW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:149
#define FIXME(fmt,...)
Definition: debug.h:111

Referenced by PathQualifyExW().

◆ IsLFNDriveA()

BOOL WINAPI IsLFNDriveA ( LPCSTR  lpszPath)

Definition at line 408 of file shellpath.c.

409 {
410  DWORD fnlen;
411 
412  if (!GetVolumeInformationA(lpszPath, NULL, 0, NULL, &fnlen, NULL, NULL, 0))
413  return FALSE;
414  return fnlen > 12;
415 }
BOOL WINAPI GetVolumeInformationA(IN LPCSTR lpRootPathName, IN LPSTR lpVolumeNameBuffer, IN DWORD nVolumeNameSize, OUT LPDWORD lpVolumeSerialNumber OPTIONAL, OUT LPDWORD lpMaximumComponentLength OPTIONAL, OUT LPDWORD lpFileSystemFlags OPTIONAL, OUT LPSTR lpFileSystemNameBuffer OPTIONAL, IN DWORD nFileSystemNameSize)
Definition: volume.c:32
#define FALSE
Definition: types.h:117
unsigned long DWORD
Definition: ntddk_ex.h:95
#define NULL
Definition: types.h:112

Referenced by IsLFNDriveAW().

◆ IsLFNDriveAW()

BOOL WINAPI IsLFNDriveAW ( LPCVOID  lpszPath)

Definition at line 432 of file shellpath.c.

433 {
434  if (SHELL_OsIsUnicode())
435  return IsLFNDriveW(lpszPath);
436  return IsLFNDriveA(lpszPath);
437 }
static __inline BOOL SHELL_OsIsUnicode(void)
Definition: shell32_main.h:130
BOOL WINAPI IsLFNDriveW(LPCWSTR lpszPath)
Definition: shellpath.c:420
BOOL WINAPI IsLFNDriveA(LPCSTR lpszPath)
Definition: shellpath.c:408

◆ IsLFNDriveW()

BOOL WINAPI IsLFNDriveW ( LPCWSTR  lpszPath)

Definition at line 420 of file shellpath.c.

421 {
422  DWORD fnlen;
423 
424  if (!GetVolumeInformationW(lpszPath, NULL, 0, NULL, &fnlen, NULL, NULL, 0))
425  return FALSE;
426  return fnlen > 12;
427 }
#define FALSE
Definition: types.h:117
unsigned long DWORD
Definition: ntddk_ex.h:95
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
#define NULL
Definition: types.h:112

Referenced by IsLFNDriveAW(), and PathQualifyExW().

◆ PathAppendAW()

BOOL WINAPI PathAppendAW ( LPVOID  lpszPath1,
LPCVOID  lpszPath2 
)

Definition at line 236 of file shellpath.c.

239 {
240  if (SHELL_OsIsUnicode())
241  return PathAppendW(lpszPath1, lpszPath2);
242  return PathAppendA(lpszPath1, lpszPath2);
243 }
BOOL WINAPI PathAppendA(LPSTR lpszPath, LPCSTR lpszAppend)
Definition: path.c:106
static __inline BOOL SHELL_OsIsUnicode(void)
Definition: shell32_main.h:130
BOOL WINAPI PathAppendW(LPWSTR lpszPath, LPCWSTR lpszAppend)
Definition: path.c:126

◆ PathCleanupSpec()

int WINAPI PathCleanupSpec ( LPCWSTR  lpszPathW,
LPWSTR  lpszFileW 
)

Definition at line 531 of file shellpath.c.

532 {
533  int i = 0;
534  DWORD rc = 0;
535  int length = 0;
536 
537  if (SHELL_OsIsUnicode())
538  {
539  LPWSTR p = lpszFileW;
540 
541  TRACE("Cleanup %s\n",debugstr_w(lpszFileW));
542 
543  if (lpszPathW)
544  length = strlenW(lpszPathW);
545 
546  while (*p)
547  {
548  int gct = PathGetCharTypeW(*p);
549  if (gct == GCT_INVALID || gct == GCT_WILD || gct == GCT_SEPARATOR)
550  {
551  lpszFileW[i]='-';
552  rc |= PCS_REPLACEDCHAR;
553  }
554  else
555  lpszFileW[i]=*p;
556  i++;
557  p++;
558  if (length + i == MAX_PATH)
559  {
560  rc |= PCS_FATAL | PCS_PATHTOOLONG;
561  break;
562  }
563  }
564  lpszFileW[i]=0;
565  }
566  else
567  {
568  LPSTR lpszFileA = (LPSTR)lpszFileW;
569  LPCSTR lpszPathA = (LPCSTR)lpszPathW;
570  LPSTR p = lpszFileA;
571 
572  TRACE("Cleanup %s\n",debugstr_a(lpszFileA));
573 
574  if (lpszPathA)
575  length = strlen(lpszPathA);
576 
577  while (*p)
578  {
579  int gct = PathGetCharTypeA(*p);
580  if (gct == GCT_INVALID || gct == GCT_WILD || gct == GCT_SEPARATOR)
581  {
582  lpszFileA[i]='-';
583  rc |= PCS_REPLACEDCHAR;
584  }
585  else
586  lpszFileA[i]=*p;
587  i++;
588  p++;
589  if (length + i == MAX_PATH)
590  {
591  rc |= PCS_FATAL | PCS_PATHTOOLONG;
592  break;
593  }
594  }
595  lpszFileA[i]=0;
596  }
597  return rc;
598 }
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
UINT WINAPI PathGetCharTypeW(WCHAR ch)
Definition: path.c:3035
static __inline BOOL SHELL_OsIsUnicode(void)
Definition: shell32_main.h:130
static LPSTR
Definition: shellpath.c:88
char * LPSTR
Definition: xmlstorage.h:182
#define PCS_FATAL
Definition: shlobj.h:331
#define PCS_PATHTOOLONG
Definition: shlobj.h:335
#define GCT_WILD
Definition: shlwapi.h:778
#define GCT_INVALID
Definition: shlwapi.h:775
#define debugstr_w
Definition: kernel32.h:32
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
const char * LPCSTR
Definition: xmlstorage.h:183
UINT WINAPI PathGetCharTypeA(UCHAR ch)
Definition: path.c:3025
#define TRACE(s)
Definition: solgame.cpp:4
#define debugstr_a
Definition: kernel32.h:31
#define MAX_PATH
Definition: compat.h:34
#define GCT_SEPARATOR
Definition: shlwapi.h:779
unsigned long DWORD
Definition: ntddk_ex.h:95
#define PCS_REPLACEDCHAR
Definition: shlobj.h:332
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
GLfloat GLfloat p
Definition: glext.h:8902
WCHAR * LPWSTR
Definition: xmlstorage.h:184

◆ PathFileExistsAW()

BOOL WINAPI PathFileExistsAW ( LPCVOID  lpszPath)

Definition at line 398 of file shellpath.c.

399 {
400  if (SHELL_OsIsUnicode())
401  return PathFileExistsW (lpszPath);
402  return PathFileExistsA (lpszPath);
403 }
BOOL WINAPI PathFileExistsA(LPCSTR lpszPath)
Definition: path.c:1754
static __inline BOOL SHELL_OsIsUnicode(void)
Definition: shell32_main.h:130
BOOL WINAPI PathFileExistsW(LPCWSTR lpszPath)
Definition: path.c:1776

◆ PathGetExtensionA()

static LPSTR PathGetExtensionA ( LPCSTR  lpszPath)
static

Definition at line 252 of file shellpath.c.

253 {
254  TRACE("(%s)\n",lpszPath);
255 
256  lpszPath = PathFindExtensionA(lpszPath);
257  return (LPSTR)(*lpszPath?(lpszPath+1):lpszPath);
258 }
char * LPSTR
Definition: xmlstorage.h:182
#define TRACE(s)
Definition: solgame.cpp:4
LPSTR WINAPI PathFindExtensionA(LPCSTR lpszPath)
Definition: path.c:422

Referenced by PathIsExeA().

◆ PathGetExtensionW()

static LPWSTR PathGetExtensionW ( LPCWSTR  lpszPath)
static

Definition at line 263 of file shellpath.c.

264 {
265  TRACE("(%s)\n",debugstr_w(lpszPath));
266 
267  lpszPath = PathFindExtensionW(lpszPath);
268  return (LPWSTR)(*lpszPath?(lpszPath+1):lpszPath);
269 }
#define debugstr_w
Definition: kernel32.h:32
LPWSTR WINAPI PathFindExtensionW(LPCWSTR lpszPath)
Definition: path.c:447
#define TRACE(s)
Definition: solgame.cpp:4
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by PathIsExeW(), and SHPathGetExtensionW().

◆ PathGetShortPathA()

static void PathGetShortPathA ( LPSTR  pszPath)
static

Definition at line 296 of file shellpath.c.

297 {
298  CHAR path[MAX_PATH];
299 
300  TRACE("%s\n", pszPath);
301 
302  if (GetShortPathNameA(pszPath, path, MAX_PATH))
303  {
304  lstrcpyA(pszPath, path);
305  }
306 }
char CHAR
Definition: xmlstorage.h:175
#define TRACE(s)
Definition: solgame.cpp:4
DWORD WINAPI GetShortPathNameA(IN LPCSTR lpszLongPath, OUT LPSTR lpszShortPath, IN DWORD cchBuffer)
Definition: path.c:1751
#define MAX_PATH
Definition: compat.h:34
LPSTR WINAPI lstrcpyA(LPSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:100

Referenced by PathGetShortPathAW().

◆ PathGetShortPathAW()

VOID WINAPI PathGetShortPathAW ( LPVOID  pszPath)

Definition at line 326 of file shellpath.c.

327 {
328  if(SHELL_OsIsUnicode())
329  PathGetShortPathW(pszPath);
330  PathGetShortPathA(pszPath);
331 }
static __inline BOOL SHELL_OsIsUnicode(void)
Definition: shell32_main.h:130
static void PathGetShortPathW(LPWSTR pszPath)
Definition: shellpath.c:311
static void PathGetShortPathA(LPSTR pszPath)
Definition: shellpath.c:296

◆ PathGetShortPathW()

static void PathGetShortPathW ( LPWSTR  pszPath)
static

Definition at line 311 of file shellpath.c.

312 {
314 
315  TRACE("%s\n", debugstr_w(pszPath));
316 
317  if (GetShortPathNameW(pszPath, path, MAX_PATH))
318  {
319  lstrcpyW(pszPath, path);
320  }
321 }
#define debugstr_w
Definition: kernel32.h:32
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
DWORD WINAPI GetShortPathNameW(IN LPCWSTR lpszLongPath, OUT LPWSTR lpszShortPath, IN DWORD cchBuffer)
Definition: path.c:1832
#define MAX_PATH
Definition: compat.h:34
#define lstrcpyW
Definition: compat.h:608

Referenced by PathGetShortPathAW().

◆ PathIsAbsoluteW()

static BOOL WINAPI PathIsAbsoluteW ( LPCWSTR  path)
static

Definition at line 127 of file shellpath.c.

128 {
129  return PathIsUNCW(path) || (PathGetDriveNumberW(path) != -1 && path[2] == L'\\');
130 }
static const WCHAR L[]
Definition: oid.c:1250
int WINAPI PathGetDriveNumberW(const WCHAR *path)
Definition: path.c:553
BOOL WINAPI PathIsUNCW(LPCWSTR lpszPath)
Definition: path.c:2265

Referenced by PathResolveW().

◆ PathIsExeA()

static BOOL PathIsExeA ( LPCSTR  lpszPath)
static

Definition at line 350 of file shellpath.c.

351 {
352  LPCSTR lpszExtension = PathGetExtensionA(lpszPath);
353  int i;
354  static const char * const lpszExtensions[] =
355  {"exe", "com", "pif", "cmd", "bat", "scf", "scr", NULL };
356 
357  TRACE("path=%s\n",lpszPath);
358 
359  for(i=0; lpszExtensions[i]; i++)
360  if (!lstrcmpiA(lpszExtension,lpszExtensions[i])) return TRUE;
361 
362  return FALSE;
363 }
int WINAPI lstrcmpiA(LPCSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:42
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
const char * LPCSTR
Definition: xmlstorage.h:183
#define TRACE(s)
Definition: solgame.cpp:4
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 NULL
Definition: types.h:112
static LPSTR PathGetExtensionA(LPCSTR lpszPath)
Definition: shellpath.c:252

Referenced by PathIsExeAW().

◆ PathIsExeAW()

BOOL WINAPI PathIsExeAW ( LPCVOID  path)

Definition at line 388 of file shellpath.c.

389 {
390  if (SHELL_OsIsUnicode())
391  return PathIsExeW (path);
392  return PathIsExeA(path);
393 }
static __inline BOOL SHELL_OsIsUnicode(void)
Definition: shell32_main.h:130
BOOL PathIsExeW(LPCWSTR lpszPath)
Definition: shellpath.c:368
static BOOL PathIsExeA(LPCSTR lpszPath)
Definition: shellpath.c:350

◆ PathIsExeW()

BOOL PathIsExeW ( LPCWSTR  lpszPath)

Definition at line 368 of file shellpath.c.

369 {
370  LPCWSTR lpszExtension = PathGetExtensionW(lpszPath);
371  int i;
372  static const WCHAR lpszExtensions[][4] =
373  {{'e','x','e','\0'}, {'c','o','m','\0'}, {'p','i','f','\0'},
374  {'c','m','d','\0'}, {'b','a','t','\0'}, {'s','c','f','\0'},
375  {'s','c','r','\0'}, {'\0'} };
376 
377  TRACE("path=%s\n",debugstr_w(lpszPath));
378 
379  for(i=0; lpszExtensions[i][0]; i++)
380  if (!strcmpiW(lpszExtension,lpszExtensions[i])) return TRUE;
381 
382  return FALSE;
383 }
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define debugstr_w
Definition: kernel32.h:32
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define strcmpiW(s1, s2)
Definition: unicode.h:39
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
static LPWSTR PathGetExtensionW(LPCWSTR lpszPath)
Definition: shellpath.c:263

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

◆ PathIsRootAW()

BOOL WINAPI PathIsRootAW ( LPCVOID  lpszPath)

Definition at line 340 of file shellpath.c.

341 {
342  if (SHELL_OsIsUnicode())
343  return PathIsRootW(lpszPath);
344  return PathIsRootA(lpszPath);
345 }
static __inline BOOL SHELL_OsIsUnicode(void)
Definition: shell32_main.h:130
BOOL WINAPI PathIsRootW(LPCWSTR lpszPath)
Definition: path.c:1641
BOOL WINAPI PathIsRootA(LPCSTR lpszPath)
Definition: path.c:1601

◆ PathMakeAbsoluteW()

static BOOL WINAPI PathMakeAbsoluteW ( LPWSTR  path)
static

Definition at line 133 of file shellpath.c.

134 {
136  DWORD cch;
137 
138  if (path == NULL)
139  return FALSE;
141  if (!cch || cch > _countof(path1))
142  return FALSE;
143  return (PathCombineW(path, path1, path) != NULL);
144 }
#define GetCurrentDirectoryW(x, y)
Definition: compat.h:615
#define FALSE
Definition: types.h:117
static const WCHAR path1[]
Definition: path.c:28
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define _countof(array)
Definition: sndvol32.h:68
#define MAX_PATH
Definition: compat.h:34
unsigned long DWORD
Definition: ntddk_ex.h:95
#define NULL
Definition: types.h:112
IN PCTCH IN DWORD cch
Definition: pager.h:36
LPWSTR WINAPI PathCombineW(LPWSTR lpszDest, LPCWSTR lpszDir, LPCWSTR lpszFile)
Definition: path.c:194

Referenced by PathResolveW().

◆ PathMakeUniqueNameA()

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

Definition at line 445 of file shellpath.c.

451 {
452  FIXME("%p %u %s %s %s stub\n",
453  lpszBuffer, dwBuffSize, debugstr_a(lpszShortName),
454  debugstr_a(lpszLongName), debugstr_a(lpszPathName));
455  return TRUE;
456 }
#define TRUE
Definition: types.h:120
#define FIXME(fmt,...)
Definition: debug.h:111
#define debugstr_a
Definition: kernel32.h:31

Referenced by PathMakeUniqueNameAW().

◆ PathMakeUniqueNameAW()

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

Definition at line 477 of file shellpath.c.

483 {
484  if (SHELL_OsIsUnicode())
485  return PathMakeUniqueNameW(lpszBuffer,dwBuffSize, lpszShortName,lpszLongName,lpszPathName);
486  return PathMakeUniqueNameA(lpszBuffer,dwBuffSize, lpszShortName,lpszLongName,lpszPathName);
487 }
static BOOL PathMakeUniqueNameW(LPWSTR lpszBuffer, DWORD dwBuffSize, LPCWSTR lpszShortName, LPCWSTR lpszLongName, LPCWSTR lpszPathName)
Definition: shellpath.c:461
static __inline BOOL SHELL_OsIsUnicode(void)
Definition: shell32_main.h:130
static BOOL PathMakeUniqueNameA(LPSTR lpszBuffer, DWORD dwBuffSize, LPCSTR lpszShortName, LPCSTR lpszLongName, LPCSTR lpszPathName)
Definition: shellpath.c:445

◆ PathMakeUniqueNameW()

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

Definition at line 461 of file shellpath.c.

467 {
468  FIXME("%p %u %s %s %s stub\n",
469  lpszBuffer, dwBuffSize, debugstr_w(lpszShortName),
470  debugstr_w(lpszLongName), debugstr_w(lpszPathName));
471  return TRUE;
472 }
#define TRUE
Definition: types.h:120
#define debugstr_w
Definition: kernel32.h:32
#define FIXME(fmt,...)
Definition: debug.h:111

Referenced by PathMakeUniqueNameAW().

◆ PathProcessCommandA()

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

Definition at line 769 of file shellpath.c.

774 {
775  FIXME("%s %p 0x%04x 0x%04x stub\n",
776  lpszPath, lpszBuff, dwBuffSize, dwFlags);
777  if(!lpszPath) return -1;
778  if(lpszBuff) strcpy(lpszBuff, lpszPath);
779  return strlen(lpszPath);
780 }
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define FIXME(fmt,...)
Definition: debug.h:111
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
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 801 of file shellpath.c.

806 {
807  if (SHELL_OsIsUnicode())
808  return PathProcessCommandW(lpszPath, lpszBuff, dwBuffSize, dwFlags);
809  return PathProcessCommandA(lpszPath, lpszBuff, dwBuffSize, dwFlags);
810 }
static LONG PathProcessCommandA(LPCSTR lpszPath, LPSTR lpszBuff, DWORD dwBuffSize, DWORD dwFlags)
Definition: shellpath.c:769
static LONG PathProcessCommandW(LPCWSTR lpszPath, LPWSTR lpszBuff, DWORD dwBuffSize, DWORD dwFlags)
Definition: shellpath.c:785
static __inline BOOL SHELL_OsIsUnicode(void)
Definition: shell32_main.h:130
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175

◆ PathProcessCommandW()

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

Definition at line 785 of file shellpath.c.

790 {
791  FIXME("(%s, %p, 0x%04x, 0x%04x) stub\n",
792  debugstr_w(lpszPath), lpszBuff, dwBuffSize, dwFlags);
793  if(!lpszPath) return -1;
794  if(lpszBuff) strcpyW(lpszBuff, lpszPath);
795  return strlenW(lpszPath);
796 }
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
#define debugstr_w
Definition: kernel32.h:32
#define FIXME(fmt,...)
Definition: debug.h:111
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
WINE_UNICODE_INLINE WCHAR * strcpyW(WCHAR *dst, const WCHAR *src)
Definition: unicode.h:219

Referenced by PathProcessCommandAW().

◆ PathQualifyA()

VOID WINAPI PathQualifyA ( LPSTR  pszPath)

Definition at line 603 of file shellpath.c.

604 {
606  TRACE("%s\n",pszPath);
609  SHUnicodeToAnsi(szPath, pszPath, MAX_PATH);
610 }
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define _countof(array)
Definition: sndvol32.h:68
#define MAX_PATH
Definition: compat.h:34
DWORD WINAPI SHAnsiToUnicode(LPCSTR lpSrcStr, LPWSTR lpDstStr, int iLen)
Definition: string.c:2659
VOID WINAPI PathQualifyW(LPWSTR pszPath)
Definition: shellpath.c:615
INT WINAPI SHUnicodeToAnsi(LPCWSTR lpSrcStr, LPSTR lpDstStr, INT iLen)
Definition: string.c:2783
LPCWSTR szPath
Definition: env.c:37

Referenced by PathQualifyAW().

◆ PathQualifyAW()

VOID WINAPI PathQualifyAW ( LPVOID  pszPath)

Definition at line 624 of file shellpath.c.

625 {
626  if (SHELL_OsIsUnicode())
627  PathQualifyW(pszPath);
628  else
629  PathQualifyA(pszPath);
630 }
static __inline BOOL SHELL_OsIsUnicode(void)
Definition: shell32_main.h:130
VOID WINAPI PathQualifyW(LPWSTR pszPath)
Definition: shellpath.c:615
VOID WINAPI PathQualifyA(LPSTR pszPath)
Definition: shellpath.c:603

◆ PathQualifyExW()

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

Definition at line 159 of file shellpath.c.

160 {
161  WCHAR szRoot[MAX_PATH], szCopy[MAX_PATH], szCurDir[MAX_PATH];
162  LPWSTR pch;
163  LONG cch;
164  BOOL bCheckLFN;
165 
166  if (FAILED(StringCchCopyW(szCopy, _countof(szCopy), pszPath)))
167  return;
168 
169  FixSlashesAndColonW(szCopy);
170 
171  if (pszDir)
172  {
173  cch = GetCurrentDirectoryW(_countof(szCurDir), szCurDir);
175  pszDir = NULL;
176  }
177 
178  if (!GetFullPathNameW(szCopy, _countof(szRoot), szRoot, NULL))
179  goto Quit;
180 
181  if (PathIsUNCW(szRoot)) /* it begins with double backslash */
182  {
183  pch = StrChrW(&szRoot[2], L'\\');
184  if (pch)
185  {
186  pch = StrChrW(&pch[1], L'\\');
187  if (pch)
188  *pch = 0;
189  if (!PathAddBackslashW(szRoot))
190  goto Quit;
191  /* szRoot is like \\MyServer\MyShare\ */
192  bCheckLFN = TRUE;
193  }
194  else
195  {
196  bCheckLFN = FALSE;
197  }
198  }
199  else
200  {
201  if (!PathStripToRootW(szRoot) || !PathAddBackslashW(szRoot))
202  goto Quit;
203  /* szRoot is like X:\ */
204  bCheckLFN = TRUE;
205  }
206 
207  if (bCheckLFN && !IsLFNDriveW(szRoot)) /* not a long filename drive */
208  {
209  if (!GetFullPathNameW(szCopy, _countof(szRoot), szRoot, NULL))
210  goto Quit;
211  if (!GetShortPathNameW(szRoot, szCopy, _countof(szCopy)) &&
212  !GetShortPathNameAbsentW(szRoot, szCopy, _countof(szCopy)))
213  {
214  goto Quit;
215  }
216  }
217 
218  PathRemoveBackslashW(szCopy);
219  StringCchCopyW(pszPath, MAX_PATH, szCopy);
220 
221  if ((dwFlags & 1) == 0)
222  {
223  cch = lstrlenW(pszPath);
224  if (cch > 0 && pszPath[cch - 1] == L'.')
225  pszPath[cch - 1] = 0;
226  }
227 
228 Quit:
229  if (pszDir)
230  SetCurrentDirectoryW(szCurDir);
231 }
#define TRUE
Definition: types.h:120
#define GetCurrentDirectoryW(x, y)
Definition: compat.h:615
DWORD WINAPI GetFullPathNameW(IN LPCWSTR lpFileName, IN DWORD nBufferLength, OUT LPWSTR lpBuffer, OUT LPWSTR *lpFilePart)
Definition: path.c:1105
#define lstrlenW
Definition: compat.h:609
#define pch(ap)
Definition: match.c:418
VOID WINAPI FixSlashesAndColonW(LPWSTR lpwstr)
Definition: ordinal.c:4401
#define FALSE
Definition: types.h:117
BOOL WINAPI PathStripToRootW(LPWSTR lpszPath)
Definition: path.c:733
LPWSTR WINAPI PathAddBackslashW(LPWSTR lpszPath)
Definition: path.c:294
unsigned int BOOL
Definition: ntddk_ex.h:94
long LONG
Definition: pedump.c:60
STRSAFEAPI StringCchCopyW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:149
BOOL WINAPI IsLFNDriveW(LPCWSTR lpszPath)
Definition: shellpath.c:420
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define _countof(array)
Definition: sndvol32.h:68
DWORD WINAPI GetShortPathNameW(IN LPCWSTR lpszLongPath, OUT LPWSTR lpszShortPath, IN DWORD cchBuffer)
Definition: path.c:1832
_In_ LPCSTR pszDir
Definition: shellapi.h:582
#define MAX_PATH
Definition: compat.h:34
static const WCHAR L[]
Definition: oid.c:1250
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
LPWSTR WINAPI PathRemoveBackslashW(LPWSTR lpszPath)
Definition: path.c:867
BOOL WINAPI SetCurrentDirectoryW(IN LPCWSTR lpPathName)
Definition: path.c:2248
LPWSTR WINAPI StrChrW(LPCWSTR lpszStr, WCHAR ch)
Definition: string.c:468
#define NULL
Definition: types.h:112
static DWORD GetShortPathNameAbsentW(LPCWSTR pszLong, LPWSTR pszShort, DWORD cchShort)
Definition: shellpath.c:149
BOOL WINAPI PathIsUNCW(LPCWSTR lpszPath)
Definition: path.c:2265
WCHAR * LPWSTR
Definition: xmlstorage.h:184
IN PCTCH IN DWORD cch
Definition: pager.h:36

Referenced by PathQualifyW(), and PathResolveW().

◆ PathQualifyW()

VOID WINAPI PathQualifyW ( LPWSTR  pszPath)

Definition at line 615 of file shellpath.c.

616 {
617  TRACE("%s\n",debugstr_w(pszPath));
618  PathQualifyExW(pszPath, NULL, 0);
619 }
#define debugstr_w
Definition: kernel32.h:32
#define TRACE(s)
Definition: solgame.cpp:4
static VOID WINAPI PathQualifyExW(LPWSTR pszPath, LPCWSTR pszDir, DWORD dwFlags)
Definition: shellpath.c:159
#define NULL
Definition: types.h:112

Referenced by PathQualifyA(), and PathQualifyAW().

◆ PathRemoveFileSpecAW()

BOOL WINAPI PathRemoveFileSpecAW ( LPVOID  lpszPath)

Definition at line 282 of file shellpath.c.

283 {
284  if (SHELL_OsIsUnicode())
285  return PathRemoveFileSpecW(lpszPath);
286  return PathRemoveFileSpecA(lpszPath);
287 }
BOOL WINAPI PathRemoveFileSpecW(LPWSTR lpszPath)
Definition: path.c:629
static __inline BOOL SHELL_OsIsUnicode(void)
Definition: shell32_main.h:130
BOOL WINAPI PathRemoveFileSpecA(LPSTR lpszPath)
Definition: path.c:586

◆ PathResolveA()

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

Definition at line 632 of file shellpath.c.

633 {
634  BOOL ret = FALSE;
635  LPWSTR *dirsW = NULL;
636  DWORD iDir, cDirs, cbDirs;
637  WCHAR pathW[MAX_PATH];
638 
639  TRACE("PathResolveA(%s,%p,0x%08x)\n", debugstr_a(path), dirs, flags);
640 
641  if (dirs)
642  {
643  for (cDirs = 0; dirs[cDirs]; ++cDirs)
644  ;
645 
646  cbDirs = (cDirs + 1) * sizeof(LPWSTR);
647  dirsW = SHAlloc(cbDirs);
648  if (!dirsW)
649  goto Cleanup;
650 
651  ZeroMemory(dirsW, cbDirs);
652  for (iDir = 0; iDir < cDirs; ++iDir)
653  {
654  __SHCloneStrAtoW(&dirsW[iDir], dirs[iDir]);
655  if (dirsW[iDir] == NULL)
656  goto Cleanup;
657  }
658  }
659 
660  SHAnsiToUnicode(path, pathW, _countof(pathW));
661 
662  ret = PathResolveW(pathW, (LPCWSTR*)dirsW, flags);
663  if (ret)
664  SHUnicodeToAnsi(pathW, path, MAX_PATH);
665 
666 Cleanup:
667  if (dirsW)
668  {
669  for (iDir = 0; iDir < cDirs; ++iDir)
670  {
671  SHFree(dirsW[iDir]);
672  }
673  SHFree(dirsW);
674  }
675  return ret;
676 }
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
#define ZeroMemory
Definition: winbase.h:1664
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
BOOL WINAPI PathResolveW(LPWSTR path, LPCWSTR *dirs, DWORD flags)
Definition: shellpath.c:678
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define debugstr_a
Definition: kernel32.h:31
#define _countof(array)
Definition: sndvol32.h:68
#define MAX_PATH
Definition: compat.h:34
DWORD WINAPI SHAnsiToUnicode(LPCSTR lpSrcStr, LPWSTR lpDstStr, int iLen)
Definition: string.c:2659
unsigned long DWORD
Definition: ntddk_ex.h:95
GLbitfield flags
Definition: glext.h:7161
int ret
INT WINAPI SHUnicodeToAnsi(LPCWSTR lpSrcStr, LPSTR lpDstStr, INT iLen)
Definition: string.c:2783
static const WCHAR Cleanup[]
Definition: register.c:80
static __inline LPWSTR __SHCloneStrAtoW(WCHAR **target, const char *source)
Definition: shell32_main.h:160
#define NULL
Definition: types.h:112
void WINAPI SHFree(LPVOID pv)
Definition: shellole.c:331
WCHAR * LPWSTR
Definition: xmlstorage.h:184
LPVOID WINAPI SHAlloc(SIZE_T len)
Definition: shellole.c:309

Referenced by PathResolveAW().

◆ PathResolveAW()

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

Definition at line 758 of file shellpath.c.

759 {
760  if (SHELL_OsIsUnicode())
761  return PathResolveW(path, (LPCWSTR*)paths, flags);
762  else
763  return PathResolveA(path, (LPCSTR*)paths, flags);
764 }
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
static __inline BOOL SHELL_OsIsUnicode(void)
Definition: shell32_main.h:130
BOOL WINAPI PathResolveW(LPWSTR path, LPCWSTR *dirs, DWORD flags)
Definition: shellpath.c:678
const char * LPCSTR
Definition: xmlstorage.h:183
GLbitfield flags
Definition: glext.h:7161
GLsizei const GLuint * paths
Definition: glext.h:11717
BOOL WINAPI PathResolveA(LPSTR path, LPCSTR *dirs, DWORD flags)
Definition: shellpath.c:632

◆ PathResolveW()

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

Definition at line 678 of file shellpath.c.

679 {
681 
682  TRACE("PathResolveW(%s,%p,0x%08x)\n", debugstr_w(path), dirs, flags);
683 
684  if (flags & PRF_VERIFYEXISTS)
686 
688 
689  if (PathIsRootW(path))
690  {
691  if ((path[0] == L'\\' && path[1] == 0) ||
693  {
694  if (flags & PRF_FIRSTDIRDEF)
695  PathQualifyExW(path, dirs[0], 0);
696  else
697  PathQualifyExW(path, NULL, 0);
698  }
699 
700  if (flags & PRF_VERIFYEXISTS)
702  return TRUE;
703  }
704  else if (PathIsFileSpecW(path))
705  {
706  if ((flags & PRF_TRYPROGRAMEXTENSIONS) && PathSearchOnExtensionsW(path, dirs, TRUE, dwWhich))
707  return TRUE;
708 
709  if (PathFindOnPathW(path, dirs))
710  {
711 #if (_WIN32_WINNT >= _WIN32_WINNT_VISTA)
712  if (!(flags & PRF_REQUIREABSOLUTE))
713  return TRUE;
714 
715  if (!PathIsAbsoluteW(path))
717 #else
718  return TRUE;
719 #endif
720  }
721  }
722  else if (!PathIsURLW(path))
723  {
724  if (flags & PRF_FIRSTDIRDEF)
725  PathQualifyExW(path, *dirs, 1);
726  else
727  PathQualifyExW(path, NULL, 1);
728 
729  if (flags & PRF_VERIFYEXISTS)
730  {
732  PathSearchOnExtensionsW(path, dirs, FALSE, dwWhich))
733  {
734  return TRUE;
735  }
737  {
738  return FALSE;
739  }
740  }
741 
742 #if (_WIN32_WINNT >= _WIN32_WINNT_VISTA)
744  {
745  if (!PathIsAbsoluteW(path))
747  }
748 #endif
749  return TRUE;
750  }
751 
752  return FALSE;
753 }
BOOL WINAPI PathFileExistsAndAttributesW(LPCWSTR lpszPath, DWORD *dwAttr)
Definition: path.c:1831
#define WHICH_DEFAULT
#define TRUE
Definition: types.h:120
#define PRF_FIRSTDIRDEF
Definition: PathResolve.cpp:32
#define PRF_DONTFINDLNK
Definition: PathResolve.cpp:33
#define PRF_VERIFYEXISTS
Definition: PathResolve.cpp:29
#define PRF_TRYPROGRAMEXTENSIONS
Definition: PathResolve.cpp:31
BOOL WINAPI PathIsURLW(LPCWSTR lpstrPath)
Definition: url.c:2432
static BOOL WINAPI PathIsAbsoluteW(LPCWSTR path)
Definition: shellpath.c:127
#define FALSE
Definition: types.h:117
BOOL WINAPI PathIsUNCServerShareW(LPCWSTR lpszPath)
Definition: path.c:2377
#define debugstr_w
Definition: kernel32.h:32
#define PRF_REQUIREABSOLUTE
Definition: PathResolve.cpp:36
BOOL WINAPI PathIsFileSpecW(LPCWSTR lpszPath)
Definition: path.c:2132
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
BOOL WINAPI PathIsRootW(LPCWSTR lpszPath)
Definition: path.c:1641
#define TRACE(s)
Definition: solgame.cpp:4
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:611
GLbitfield flags
Definition: glext.h:7161
static const WCHAR L[]
Definition: oid.c:1250
static BOOL WINAPI PathSearchOnExtensionsW(LPWSTR pszPath, LPCWSTR *ppszDirs, BOOL bDoSearch, DWORD dwWhich)
Definition: shellpath.c:114
static VOID WINAPI PathQualifyExW(LPWSTR pszPath, LPCWSTR pszDir, DWORD dwFlags)
Definition: shellpath.c:159
#define WHICH_LNK
VOID WINAPI PathUnquoteSpacesW(LPWSTR lpszPath)
Definition: path.c:1034
#define NULL
Definition: types.h:112
BOOL WINAPI PathIsUNCServerW(LPCWSTR lpszPath)
Definition: path.c:2322
static BOOL WINAPI PathMakeAbsoluteW(LPWSTR path)
Definition: shellpath.c:133
BOOL WINAPI PathFindOnPathW(LPWSTR lpszFile, LPCWSTR *lppszOtherDirs)
Definition: path.c:1402

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

◆ PathSearchOnExtensionsW()

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

Definition at line 114 of file shellpath.c.

115 {
116  if (*PathFindExtensionW(pszPath) != 0)
117  return FALSE;
118 
119  if (bDoSearch)
120  return PathFindOnPathExW(pszPath, ppszDirs, dwWhich);
121  else
122  return PathFileExistsDefExtW(pszPath, dwWhich);
123 }
#define FALSE
Definition: types.h:117
LPWSTR WINAPI PathFindExtensionW(LPCWSTR lpszPath)
Definition: path.c:447
BOOL WINAPI PathFileExistsDefExtW(LPWSTR lpszPath, DWORD dwWhich)
Definition: path.c:1117
BOOL WINAPI PathFindOnPathExW(LPWSTR lpszFile, LPCWSTR *lppszOtherDirs, DWORD dwWhich)
Definition: path.c:1350

Referenced by PathResolveW().

◆ PathYetAnotherMakeUniqueName()

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

Definition at line 492 of file shellpath.c.

493 {
494  WCHAR pathW[MAX_PATH], retW[MAX_PATH];
495  const WCHAR *file, *ext;
496  int i = 2;
497 
498  TRACE("(%p, %s, %s, %s)\n", buffer, debugstr_w(path), debugstr_w(shortname), debugstr_w(longname));
499 
500  file = longname ? longname : shortname;
501  PathCombineW(pathW, path, file);
502  strcpyW(retW, pathW);
503  PathRemoveExtensionW(pathW);
504 
506 
507  /* now try to make it unique */
508  while (PathFileExistsW(retW))
509  {
510  static const WCHAR fmtW[] = {'%','s',' ','(','%','d',')','%','s',0};
511 
512  sprintfW(retW, fmtW, pathW, i, ext);
513  i++;
514  }
515 
516  strcpyW(buffer, retW);
517  TRACE("ret - %s\n", debugstr_w(buffer));
518 
519  return TRUE;
520 }
#define TRUE
Definition: types.h:120
GLuint buffer
Definition: glext.h:5915
void WINAPI PathRemoveExtensionW(LPWSTR lpszPath)
Definition: path.c:823
#define debugstr_w
Definition: kernel32.h:32
char ext[3]
Definition: mkdosfs.c:358
BOOL WINAPI PathFileExistsW(LPCWSTR lpszPath)
Definition: path.c:1776
LPWSTR WINAPI PathFindExtensionW(LPCWSTR lpszPath)
Definition: path.c:447
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:34
const char file[]
Definition: icontest.c:11
WINE_UNICODE_INLINE WCHAR * strcpyW(WCHAR *dst, const WCHAR *src)
Definition: unicode.h:219
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 sprintfW
Definition: unicode.h:58
LPWSTR WINAPI PathCombineW(LPWSTR lpszDest, LPCWSTR lpszDir, LPCWSTR lpszFile)
Definition: path.c:194
Definition: fci.c:126

Referenced by BrsFolder_NewFolder(), CNewMenu::CreateNewFolder(), CDefaultContextMenu::DoCreateNewFolder(), loadShell32(), and CNewMenu::NewItemByNonCommand().

◆ SHELL_RegisterShellFolders()

HRESULT SHELL_RegisterShellFolders ( void  )

Definition at line 2920 of file shellpath.c.

2921 {
2922  HRESULT hr;
2923 
2925  if (SUCCEEDED(hr))
2927  if (SUCCEEDED(hr))
2929  return hr;
2930 }
static HRESULT _SHRegisterCommonShellFolders(void)
Definition: shellpath.c:2892
HRESULT hr
Definition: shlfolder.c:183
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
if SUCCEEDED(hr)
static HRESULT _SHRegisterUserShellFolders(BOOL bDefault)
Definition: shellpath.c:2824
LONG HRESULT
Definition: typedefs.h:79

Referenced by DllRegisterServer().

◆ SHGetFolderLocation()

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

Definition at line 2980 of file shellpath.c.

2986 {
2988 
2989  TRACE("%p 0x%08x %p 0x%08x %p\n",
2990  hwndOwner, nFolder, hToken, dwReserved, ppidl);
2991 
2992  if (!ppidl)
2993  return E_INVALIDARG;
2994  if (dwReserved)
2995  return E_INVALIDARG;
2996 
2997  /* The virtual folders' locations are not user-dependent */
2998  *ppidl = NULL;
2999  switch (nFolder & CSIDL_FOLDER_MASK)
3000  {
3001  case CSIDL_DESKTOP:
3002  *ppidl = _ILCreateDesktop();
3003  break;
3004 
3005  case CSIDL_PERSONAL:
3006  *ppidl = _ILCreateMyDocuments();
3007  break;
3008 
3009  case CSIDL_INTERNET:
3010  *ppidl = _ILCreateIExplore();
3011  break;
3012 
3013  case CSIDL_CONTROLS:
3014  *ppidl = _ILCreateControlPanel();
3015  break;
3016 
3017  case CSIDL_PRINTERS:
3018  *ppidl = _ILCreatePrinters();
3019  break;
3020 
3021  case CSIDL_BITBUCKET:
3022  *ppidl = _ILCreateBitBucket();
3023  break;
3024 
3025  case CSIDL_DRIVES:
3026  *ppidl = _ILCreateMyComputer();
3027  break;
3028 
3029  case CSIDL_NETWORK:
3030  *ppidl = _ILCreateNetwork();
3031  break;
3032 
3033  default:
3034  {
3036 
3037  hr = SHGetFolderPathW(hwndOwner, nFolder, hToken,
3039  if (SUCCEEDED(hr))
3040  {
3041  DWORD attributes=0;
3042 
3043  TRACE("Value=%s\n", debugstr_w(szPath));
3044  hr = SHILCreateFromPathW(szPath, ppidl, &attributes);
3045  }
3047  {
3048  /* unlike SHGetFolderPath, SHGetFolderLocation in shell32
3049  * version 6.0 returns E_FAIL for nonexistent paths
3050  */
3051  hr = E_FAIL;
3052  }
3053  }
3054  }
3055  if(*ppidl)
3056  hr = S_OK;
3057 
3058  TRACE("-- (new pidl %p)\n",*ppidl);
3059  return hr;
3060 }
LPITEMIDLIST _ILCreateDesktop(void)
Definition: pidl.c:1602
#define HRESULT_FROM_WIN32(x)
Definition: winerror.h:92
HRESULT hr
Definition: shlfolder.c:183
LPITEMIDLIST _ILCreatePrinters(void)
Definition: pidl.c:1650
#define CSIDL_DESKTOP
Definition: shlobj.h:2012
_In_ int nFolder
Definition: shlobj.h:1444
#define CSIDL_BITBUCKET
Definition: shlobj.h:2022
#define E_FAIL
Definition: ddrawi.h:102
#define CSIDL_CONTROLS
Definition: shlobj.h:2015
#define CSIDL_FOLDER_MASK
Definition: shlobj.h:2070
#define CSIDL_PRINTERS
Definition: shlobj.h:2016
#define CSIDL_DRIVES
Definition: shlobj.h:2028
_In_ HANDLE _In_ DWORD _In_ DWORD _Inout_opt_ LPOVERLAPPED _In_opt_ LPTRANSMIT_FILE_BUFFERS _In_ DWORD dwReserved
Definition: mswsock.h:90
if SUCCEEDED(hr)
#define debugstr_w
Definition: kernel32.h:32
#define E_INVALIDARG
Definition: ddrawi.h:101
LPITEMIDLIST _ILCreateMyComputer(void)
Definition: pidl.c:1613
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:79
#define MAX_PATH
Definition: compat.h:34
unsigned long DWORD
Definition: ntddk_ex.h:95
LPITEMIDLIST _ILCreateNetwork(void)
Definition: pidl.c:1669
#define S_OK
Definition: intsafe.h:52
LPCWSTR szPath
Definition: env.c:37
#define NULL
Definition: types.h:112
#define CSIDL_INTERNET
Definition: shlobj.h:2013
HRESULT WINAPI SHILCreateFromPathW(LPCWSTR path, LPITEMIDLIST *ppidl, DWORD *attributes)
Definition: pidl.c:392
#define CSIDL_PERSONAL
Definition: shlobj.h:2017
HRESULT WINAPI SHGetFolderPathW(HWND hwndOwner, int nFolder, HANDLE hToken, DWORD dwFlags, LPWSTR pszPath)
Definition: shellpath.c:2447
LPITEMIDLIST _ILCreateIExplore(void)
Definition: pidl.c:1625
LPITEMIDLIST _ILCreateMyDocuments(void)
Definition: pidl.c:1619
LPITEMIDLIST _ILCreateControlPanel(void)
Definition: pidl.c:1631
#define CSIDL_NETWORK
Definition: shlobj.h:2029
LPITEMIDLIST _ILCreateBitBucket(void)
Definition: pidl.c:1675

Referenced by CBandSiteMenu::_CreateBuiltInISFBand(), BrsFolder_OnCreate(), ILIsParentOrSpecialParent(), CExplorerBand::InitializeExplorerBand(), CExplorerBand::InsertSubitems(), LoadRdpSettingsFromFile(), loadShell32(), CShellMenuCallback::OnGetSubMenu(), SaveRdpSettingsToFile(), SHCreateFromDesktop(), SHEmptyRecycleBinW(), SHGetSpecialFolderLocation(), START_TEST(), TestCommandLine(), and TestCompareIDList().

◆ SHGetFolderPathA()

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

Definition at line 2692 of file shellpath.c.

2698 {
2699  WCHAR szTemp[MAX_PATH];
2700  HRESULT hr;
2701 
2702  TRACE("%p,%d,%p,%#x,%p\n", hwndOwner, nFolder, hToken, dwFlags, pszPath);
2703 
2704  if (pszPath)
2705  *pszPath = '\0';
2706  hr = SHGetFolderPathW(hwndOwner, nFolder, hToken, dwFlags, szTemp);
2707  if (SUCCEEDED(hr) && pszPath)
2708  WideCharToMultiByte(CP_ACP, 0, szTemp, -1, pszPath, MAX_PATH, NULL,
2709  NULL);
2710 
2711  return hr;
2712 }
#define WideCharToMultiByte
Definition: compat.h:111
HRESULT hr
Definition: shlfolder.c:183
#define CP_ACP
Definition: compat.h:109
_In_ int nFolder
Definition: shlobj.h:1444
if SUCCEEDED(hr)
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:79
#define MAX_PATH
Definition: compat.h:34
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
#define NULL
Definition: types.h:112
HRESULT WINAPI SHGetFolderPathW(HWND hwndOwner, int nFolder, HANDLE hToken, DWORD dwFlags, LPWSTR pszPath)
Definition: shellpath.c:2447

Referenced by init_functionpointers(), loadShell32(), 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 2460 of file shellpath.c.

2467 {
2468  int length;
2469  HRESULT hr = S_OK;
2470  LPWSTR pszSubPathW = NULL;
2471  LPWSTR pszPathW = NULL;
2472 
2473  TRACE("%p,%#x,%p,%#x,%s,%p\n", hwndOwner, nFolder, hToken, dwFlags, debugstr_a(pszSubPath), pszPath);
2474 
2475  if(pszPath) {
2476  pszPathW = HeapAlloc(GetProcessHeap(), 0, MAX_PATH * sizeof(WCHAR));
2477  if(!pszPathW) {
2479  goto cleanup;
2480  }
2481  }
2482  TRACE("%08x,%08x,%s\n",nFolder, dwFlags, debugstr_w(pszSubPathW));
2483 
2484  /* SHGetFolderPathAndSubDirW does not distinguish if pszSubPath isn't
2485  * set (null), or an empty string.therefore call it without the parameter set
2486  * if pszSubPath is an empty string
2487  */
2488  if (pszSubPath && pszSubPath[0]) {
2489  length = MultiByteToWideChar(CP_ACP, 0, pszSubPath, -1, NULL, 0);
2490  pszSubPathW = HeapAlloc(GetProcessHeap(), 0, length * sizeof(WCHAR));
2491  if(!pszSubPathW) {
2493  goto cleanup;
2494  }
2495  MultiByteToWideChar(CP_ACP, 0, pszSubPath, -1, pszSubPathW, length);
2496  }
2497 
2498  hr = SHGetFolderPathAndSubDirW(hwndOwner, nFolder, hToken, dwFlags, pszSubPathW, pszPathW);
2499 
2500  if (SUCCEEDED(hr) && pszPath)
2501  WideCharToMultiByte(CP_ACP, 0, pszPathW, -1, pszPath, MAX_PATH, NULL, NULL);
2502 
2503 cleanup:
2504  HeapFree(GetProcessHeap(), 0, pszPathW);
2505  HeapFree(GetProcessHeap(), 0, pszSubPathW);
2506  return hr;
2507 }
#define HRESULT_FROM_WIN32(x)
Definition: winerror.h:92
#define WideCharToMultiByte
Definition: compat.h:111
HRESULT hr
Definition: shlfolder.c:183
#define CP_ACP
Definition: compat.h:109
_In_ int nFolder
Definition: shlobj.h:1444
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
if SUCCEEDED(hr)
#define debugstr_w
Definition: kernel32.h:32
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:595
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define debugstr_a
Definition: kernel32.h:31
LONG HRESULT
Definition: typedefs.h:79
#define MAX_PATH
Definition: compat.h:34
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
#define S_OK
Definition: intsafe.h:52
#define NULL
Definition: types.h:112
#define MultiByteToWideChar
Definition: compat.h:110
char * cleanup(char *str)
Definition: wpickclick.c:99
WCHAR * LPWSTR
Definition: xmlstorage.h:184
HRESULT WINAPI SHGetFolderPathAndSubDirW(HWND hwndOwner, int nFolder, HANDLE hToken, DWORD dwFlags, LPCWSTR pszSubPath, LPWSTR pszPath)
Definition: shellpath.c:2512
#define HeapFree(x, y, z)
Definition: compat.h:594

Referenced by test_SHGetFolderPathAndSubDirA().

◆ SHGetFolderPathAndSubDirW()

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

Definition at line 2512 of file shellpath.c.

2519 {
2520  HRESULT hr;
2521  WCHAR szBuildPath[MAX_PATH], szTemp[MAX_PATH];
2523  CSIDL_Type type;
2524  int ret;
2525 
2526  TRACE("%p,%#x,%p,%#x,%s,%p\n", hwndOwner, nFolder, hToken, dwFlags, debugstr_w(pszSubPath), pszPath);
2527 
2528  /* Windows always NULL-terminates the resulting path regardless of success
2529  * or failure, so do so first
2530  */
2531  if (pszPath)
2532  *pszPath = '\0';
2533 
2534  if (folder >= ARRAY_SIZE(CSIDL_Data))
2535  return E_INVALIDARG;
2537  return E_INVALIDARG;
2538  szTemp[0] = 0;
2540  switch (type)
2541  {
2542  case CSIDL_Type_Disallowed:
2543  hr = E_INVALIDARG;
2544  break;
2546  hr = S_FALSE;
2547  break;
2549  GetWindowsDirectoryW(szTemp, MAX_PATH);
2550  if (CSIDL_Data[folder].szDefaultPath &&
2551  !IS_INTRESOURCE(CSIDL_Data[folder].szDefaultPath) &&
2552  *CSIDL_Data[folder].szDefaultPath)
2553  {
2554  PathAddBackslashW(szTemp);
2555  strcatW(szTemp, CSIDL_Data[folder].szDefaultPath);
2556  }
2557  hr = S_OK;
2558  break;
2559  case CSIDL_Type_SystemPath:
2560  GetSystemDirectoryW(szTemp, MAX_PATH);
2561  if (CSIDL_Data[folder].szDefaultPath &&
2562  !IS_INTRESOURCE(CSIDL_Data[folder].szDefaultPath) &&
2563  *CSIDL_Data[folder].szDefaultPath)
2564  {
2565  PathAddBackslashW(szTemp);
2566  strcatW(szTemp, CSIDL_Data[folder].szDefaultPath);
2567  }
2568  hr = S_OK;
2569  break;
2572  if (CSIDL_Data[folder].szDefaultPath &&
2573  !IS_INTRESOURCE(CSIDL_Data[folder].szDefaultPath) &&
2574  *CSIDL_Data[folder].szDefaultPath)
2575  {
2576  PathAddBackslashW(szTemp);
2577  strcatW(szTemp, CSIDL_Data[folder].szDefaultPath);
2578  }
2579  hr = S_OK;
2580  break;
2581  case CSIDL_Type_CurrVer:
2583  break;
2584  case CSIDL_Type_User:
2585 #ifdef __REACTOS__
2586  case CSIDL_Type_InMyDocuments:
2587 #endif
2588  hr = _SHGetUserProfilePath(hToken, dwFlags, folder, szTemp);
2589  break;
2590  case CSIDL_Type_AllUsers:
2592  break;
2593  default:
2594  FIXME("bogus type %d, please fix\n", type);
2595  hr = E_INVALIDARG;
2596  break;
2597  }
2598 
2599  /* Expand environment strings if necessary */
2600  if (*szTemp == '%')
2601 #ifndef __REACTOS__
2602  hr = _SHExpandEnvironmentStrings(szTemp, szBuildPath);
2603 #else
2604  hr = _SHExpandEnvironmentStrings(hToken, szTemp, szBuildPath, _countof(szBuildPath));
2605 #endif
2606  else
2607  strcpyW(szBuildPath, szTemp);
2608 
2609  if (FAILED(hr)) goto end;
2610 
2611  if(pszSubPath) {
2612  /* make sure the new path does not exceed the buffer length
2613  * and remember to backslash and terminate it */
2614  if(MAX_PATH < (lstrlenW(szBuildPath) + lstrlenW(pszSubPath) + 2)) {
2616  goto end;
2617  }
2618  PathAppendW(szBuildPath, pszSubPath);
2619  PathRemoveBackslashW(szBuildPath);
2620  }
2621  /* Copy the path if it's available before we might return */
2622  if (SUCCEEDED(hr) && pszPath)
2623  strcpyW(pszPath, szBuildPath);
2624 
2625  /* if we don't care about existing directories we are ready */
2626  if(nFolder & CSIDL_FLAG_DONT_VERIFY) goto end;
2627 
2628  if (PathFileExistsW(szBuildPath)) goto end;
2629 
2630  /* not existing but we are not allowed to create it. The return value
2631  * is verified against shell32 version 6.0.
2632  */
2633  if (!(nFolder & CSIDL_FLAG_CREATE))
2634  {
2636  goto end;
2637  }
2638 
2639  /* create directory/directories */
2640  ret = SHCreateDirectoryExW(hwndOwner, szBuildPath, NULL);
2641  if (ret && ret != ERROR_ALREADY_EXISTS)
2642  {
2643  ERR("Failed to create directory %s.\n", debugstr_w(szBuildPath));
2644  hr = E_FAIL;
2645  goto end;
2646  }
2647 
2648  TRACE("Created missing system directory %s\n", debugstr_w(szBuildPath));
2649 
2650 end:
2651  /* create desktop.ini for custom icon */
2652  if ((nFolder & CSIDL_FLAG_CREATE) &&
2653  CSIDL_Data[folder].nShell32IconIndex)
2654  {
2655  static const WCHAR s_szFormat[] = L"%%SystemRoot%%\\system32\\shell32.dll,%d";
2656  WCHAR szIconLocation[MAX_PATH];
2658 
2659  /* make the directory a read-only folder */
2660  dwAttributes = GetFileAttributesW(szBuildPath);
2662  SetFileAttributesW(szBuildPath, dwAttributes);
2663 
2664  /* build the desktop.ini file path */
2665  PathAppendW(szBuildPath, L"desktop.ini");
2666 
2667  /* build the icon location */
2668  StringCchPrintfW(szIconLocation, _countof(szIconLocation), s_szFormat,
2669  CSIDL_Data[folder].nShell32IconIndex);
2670 
2671  /* write desktop.ini */
2672  WritePrivateProfileStringW(L".ShellClassInfo", L"IconResource", szIconLocation, szBuildPath);
2673 
2674  /* flush! */
2675  WritePrivateProfileStringW(NULL, NULL, NULL, szBuildPath);
2676 
2677  /* make the desktop.ini a system and hidden file */
2678  dwAttributes = GetFileAttributesW(szBuildPath);
2680  SetFileAttributesW(szBuildPath, dwAttributes);
2681  }
2682 
2683  TRACE("returning 0x%08x (final path is %s)\n", hr, debugstr_w(szBuildPath));
2684  return hr;
2685 }
BOOL WINAPI SetFileAttributesW(LPCWSTR lpFileName, DWORD dwFileAttributes)
Definition: fileinfo.c:794
#define HRESULT_FROM_WIN32(x)
Definition: winerror.h:92
Definition: fci.c:115
HRESULT hr
Definition: shlfolder.c:183
static HRESULT _SHExpandEnvironmentStrings(LPCWSTR szSrc, LPWSTR szDest)
Definition: shellpath.c:2294
#define CSIDL_FLAG_DONT_VERIFY
Definition: shlobj.h:2073
#define FILE_ATTRIBUTE_SYSTEM
Definition: nt_native.h:704
static HRESULT _SHGetCurrentVersionPath(DWORD dwFlags, BYTE folder, LPWSTR pszPath)
Definition: shellpath.c:1991
static const CSIDL_DATA CSIDL_Data[]
Definition: shellpath.c:969
_In_ int nFolder
Definition: shlobj.h:1444
enum _CSIDL_Type CSIDL_Type
#define lstrlenW
Definition: compat.h:609
#define E_FAIL
Definition: ddrawi.h:102
DWORD dwAttributes
Definition: vdmdbg.h:34
UINT WINAPI GetWindowsDirectoryW(OUT LPWSTR lpBuffer, IN UINT uSize)
Definition: path.c:2351
BOOL WINAPI PathAppendW(LPWSTR lpszPath, LPCWSTR lpszAppend)
Definition: path.c:126
#define CSIDL_FOLDER_MASK
Definition: shlobj.h:2070
LPWSTR WINAPI PathAddBackslashW(LPWSTR lpszPath)
Definition: path.c:294
DWORD WINAPI GetFileAttributesW(LPCWSTR lpFileName)
Definition: fileinfo.c:652
if SUCCEEDED(hr)
#define debugstr_w
Definition: kernel32.h:32
#define FIXME(fmt,...)
Definition: debug.h:111
#define S_FALSE
Definition: winerror.h:2357
#define E_INVALIDARG
Definition: ddrawi.h:101
BOOL WINAPI PathFileExistsW(LPCWSTR lpszPath)
Definition: path.c:1776
struct CFFOLDER folder
Definition: fdi.c:102
#define TRACE(s)
Definition: solgame.cpp:4
#define IS_INTRESOURCE(i)
Definition: winuser.h:580
__wchar_t WCHAR
Definition: xmlstorage.h:180
static HRESULT _SHGetUserProfilePath(HANDLE hToken, DWORD dwFlags, BYTE folder, LPWSTR pszPath)
Definition: shellpath.c:2101
LONG HRESULT
Definition: typedefs.h:79
#define _countof(array)
Definition: sndvol32.h:68
#define MAX_PATH
Definition: compat.h:34
#define FILE_ATTRIBUTE_READONLY
Definition: nt_native.h:702
unsigned long DWORD
Definition: ntddk_ex.h:95
GLuint GLuint end
Definition: gl.h:1545
int ret
static HRESULT _SHGetAllUsersProfilePath(DWORD dwFlags, BYTE folder, LPWSTR pszPath)
Definition: shellpath.c:2189
static const WCHAR L[]
Definition: oid.c:1250
UINT WINAPI GetSystemWow64DirectoryW(OUT LPWSTR lpBuffer, IN UINT uSize)
Definition: path.c:2420
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
LPWSTR WINAPI PathRemoveBackslashW(LPWSTR lpszPath)
Definition: path.c:867
BOOL WINAPI WritePrivateProfileStringW(LPCWSTR section, LPCWSTR entry, LPCWSTR string, LPCWSTR filename)
Definition: profile.c:1453
#define ERR(fmt,...)
Definition: debug.h:110
#define S_OK
Definition: intsafe.h:52
WINE_UNICODE_INLINE WCHAR * strcpyW(WCHAR *dst, const WCHAR *src)
Definition: unicode.h:219
#define ARRAY_SIZE(a)
Definition: main.h:24
int WINAPI SHCreateDirectoryExW(HWND hWnd, LPCWSTR path, LPSECURITY_ATTRIBUTES sec)
Definition: shlfileop.cpp:846
STRSAFEAPI StringCchPrintfW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszFormat,...)
Definition: strsafe.h:530
WINE_UNICODE_INLINE WCHAR * strcatW(WCHAR *dst, const WCHAR *src)
Definition: unicode.h:242