Do Not Register Hard-Coded Paths

[This is preliminary documentation and subject to change.]

Best Practice   (Designed for Microsoft® Windows® Logo)

Installers and applications should make use of the registry REG_EXPAND_SZ string type; the %SystemDrive%, %SystemRoot%, %windir%, %ProgramFiles%, %Temp%, and %UserProfile% environment variables; and the ExpandEnvironmentStrings function.

Do not hard-code paths to the Windows system root or to the drive containing Windows in the registry because users can remap their drives under Windows NT.

For example, under Windows NT, do not use a key such as the following:

MyPath : REG_SZ : "C:\Program Files\MyApp"    // BAD PRACTICE!
 

Instead, use a key such as:

MyPath : REG_EXPAND_SZ : "%SystemDrive%\Program Files\MyApp"
 

When the string is retrieved, the ExpandEnvironmentStrings function can be used to get the up-to-date path.