SHRegSetPathW function (shlwapi.h)
Takes a file path, replaces folder names with environment strings, and places the resulting string in the registry.
Syntax
LSTATUS SHRegSetPathW(
[in] HKEY hKey,
[in] LPCWSTR pcszSubKey,
[in] LPCWSTR pcszValue,
[in] LPCWSTR pcszPath,
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 containing the name of an existing subkey. If the subkey does not exist, SHRegSetPath will fail.
[in] pcszValue
Type: LPCTSTR
A pointer to a null-terminated string with the name of the value to hold the path string.
[in] pcszPath
Type: LPCTSTR
A pointer to a null-terminated string with a fully qualified file path.
dwFlags
Type: DWORD
Reserved.
Return value
Type: LSTATUS
Returns ERROR_SUCCESS if successful, or a Windows error code otherwise.
Remarks
For Windows 2000, SHRegSetPath uses PathUnExpandEnvStrings to convert folder names to their corresponding environment string. If any environment variables were substituted, the registry value will be set with the REG_EXPAND_SZ data type. Otherwise, it will be set with the REG_SZ data type.
The following folder paths will be replaced by their equivalent environment string.
Folder | Environment string |
---|---|
The current user's profile folder | %USERPROFILE% |
The All Users profile folder | %ALLUSERSPROFILE% |
The Program Files folder | %ProgramFiles% |
The system root folder | %SystemRoot% |
The system drive letter | %SystemDrive% |
Note
The shlwapi.h header defines SHRegSetPath as an alias that 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 is 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) |