SHRegGetPathA function (shlwapi.h)
Retrieves a file path from the registry, expanding environment variables as needed.
Syntax
LSTATUS SHRegGetPathA(
[in] HKEY hKey,
[in] LPCSTR pcszSubKey,
[in] LPCSTR pcszValue,
[out] LPSTR pszPath,
DWORD dwFlags
);
Parameters
[in] hKey
Type: HKEY
A handle to a key that is currently open, or a registry root key.
[in] pcszSubKey
Type: LPCTSTR
A pointer to a null-terminated string that contains the name of the subkey.
[in] pcszValue
Type: LPCTSTR
A pointer to a null-terminated string that contains the name of the value that holds the unexpanded path string.
[out] pszPath
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
The shlwapi.h header defines SHRegGetPath as an alias which automatically selects the ANSI or Unicode version of this function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code that not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see Conventions for Function Prototypes.
Requirements
Requirement | Value |
---|---|
Minimum supported client | Windows 2000 Professional, Windows XP [desktop apps only] |
Minimum supported server | Windows 2000 Server [desktop apps only] |
Target Platform | Windows |
Header | shlwapi.h |
Library | Shlwapi.lib |
DLL | Shlwapi.dll (version 5.0 or later) |