Using SHGetSpecialFolderPath() to get the localized name of the “Program Files” folder



Someone asked this:



What is the proper way to find the localised name of the “Program Files” directory?
The SHGetSpecialFolderPath have no constant for this folder.
I currently use the registry setting:


HKLM/Pmail/Attachments/TopDir value


This works for all platforms from HPC Pro to WindowMoble 2003. I suppose this can be subject to change in the future.


There is a constant that was added in Ozone: CSIDL_PROGRAM_FILES.  You may need a newer version of the SDK.


James Drage
Microsoft Windows Mobile Shell Team


Comments (9)

  1. jevans says:

    Okay, what’s Ozone?

  2. Neil Enns says:

    Windows Mobile 2003.

    Neil

  3. Niclas says:

    I have tried this on pocket pc 2000, pocket pc 2002 and windows mobile 2003.

    The only platform SHGetSpecialFolderPath works is windows mobile 2003.

    I read the API documentation for evc 3.0 without sp. The function of SHGetSpecialFolderPath is determined by the oem manufacturer.

    Could Microsoft please specify the models and makers that implements this API?

    Regards Niclas

  4. Robert Levy says:

    SHGetSpecialFolderPath should be implemented on all devices but, as this post points out, CSIDL_PROGRAM_FILES was not added until 2003

  5. Niclas says:

    Hello Robert, Please send me an email to niclas.l at remotex.se .

    I will send you code that shows an error on symbol 2800 series pocket pc 2002 devices.

    Regards /Niclas

  6. Neil Enns says:

    Niclas,

    As was mentioned above, using CSIDL_PROGRAM_FILES only works on 2003 devices and later. It’s known that it doesn’t work on 2002 devices.

  7. runtime says:

    Note that the "HKLM/Pmail/Attachments/TopDir" registry key does not seem to exist on my Smartphone (2002). The "HKLM/Pmail/" registry key exists, but there is no reference to the localized Program Files directory name. 🙁

  8. Oddmar Dam says:

    Filename = Environment.GetFolderPath(Environment.SpecialFolder.Programs)

  9. cs4 says:

    Environment.GetFolderPath(Environment.SpecialFolder.Programs)

    returns \Windows\Start Menu\Programs

    rather than \Program Files

Skip to main content