SHRegGetPath function
Retrieves a file path from the registry, expanding environment variables as needed.
Syntax
LSTATUS SHRegGetPath( _In_ HKEY hkey, _In_ LPCTSTR pszSubkey, _In_ LPCTSTR pszValue, _Out_ LPTSTR pszPath, DWORD dwFlags );
Parameters
- hkey [in]
-
Type: HKEY
A handle to a key that is currently open, or a registry root key.
- pszSubkey [in]
-
Type: LPCTSTR
A pointer to a null-terminated string that contains the name of the subkey.
- pszValue [in]
-
Type: LPCTSTR
A pointer to a null-terminated string that contains the name of the value that holds the unexpanded path string.
- pszPath [out]
-
Type: LPTSTR
A buffer to hold the expanded path. You should set the size of this buffer to MAX_PATH to ensure that it is large enough to hold the returned string.
- dwFlags
-
Type: DWORD
Reserved.
Return value
Type: LSTATUS
Returns ERROR_SUCCESS if successful, or a Windows error code otherwise.
Remarks
The data type of the specified registry value must be either REG_EXPAND_SZ or REG_SZ. If it has the REG_EXPAND_SZ type, any environment variables in the registry string will be expanded with ExpandEnvironmentStrings. If it has the REG_SZ data type, environment variables will not be expanded and the string pointed to by pszPath will be identical to the string in the registry.
The following environment strings will be replaced by their equivalent path.
| Environment string | Folder |
|---|---|
| %USERPROFILE% | The current user's profile folder |
| %ALLUSERSPROFILE% | The All Users profile folder |
| %ProgramFiles% | The Program Files folder |
| %SystemRoot% | The system root folder |
| %SystemDrive% | The system drive letter |
Requirements
|
Minimum supported client |
Windows 2000 Professional, Windows XP [desktop apps only] |
|---|---|
|
Minimum supported server |
Windows 2000 Server [desktop apps only] |
|
Header |
|
|
Library |
|
|
DLL |
|
|
Unicode and ANSI names |
SHRegGetPathW (Unicode) and SHRegGetPathA (ANSI) |