SHRegGetPath function
Applies to: desktop apps only
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 |
Note %USERPROFILE% is relative to the user making the call. This function does not work if the user is being impersonated from a service.
Requirements
|
Minimum supported client | Windows 2000 Professional, Windows XP |
|---|---|
|
Minimum supported server | Windows 2000 Server |
|
Header |
|
|
Library |
|
|
DLL |
|
|
Unicode and ANSI names | SHRegGetPathW (Unicode) and SHRegGetPathA (ANSI) |
Send comments about this topic to Microsoft
Build date: 3/7/2012