views:

618

answers:

6

I'm troubleshooting a problem with creating Vista shortcuts.

I want to make sure that our Installer is reading the Programs folder from the right Registry entry.

It's reading it fromK HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\Programs

And it's showing this directory for Programs: C:\Users\NonAdmin2 UAC OFF\AppData\Roaming\Microsoft\Windows\Start Menu\Programs

From what I've read, this seems correct, but I wanted to double check.

A: 

Sounds correct to me.

Geoffrey Chetwood
+4  A: 

Don't use the registry to read this. Use SHGetFolderPath with CSIDL_PROGRAMS.

For a reason why, see Raymond Chen's comments on the "Shell Folders" key:

http://blogs.msdn.com/oldnewthing/archive/2003/11/03/55532.aspx

Tadmas
+1  A: 

use windows installer properties. will probably be easier.

http://msdn.microsoft.com/en-us/library/aa370905(VS.85).aspx#system_folder_properties

Darren Kopp
+1  A: 

You should probably use API for this, such as SHGetFolderPath

Factor Mystic
A: 

Example of the SHGetFolderPath in VB http://support.microsoft.com/kb/252652

Clay Nichols
A: 

Helpful code snippet

ode Snippet

public class Utilities

{

public enum FolderPaths

{ CSIDL_DESKTOP = 0x0000, // CSIDL_INTERNET = 0x0001, // Internet Explorer (icon on desktop) CSIDL_PROGRAMS = 0x0002, // Start Menu\Programs CSIDL_CONTROLS = 0x0003, // My Computer\Control Panel CSIDL_PRINTERS = 0x0004, // My Computer\Printers CSIDL_PERSONAL = 0x0005, // My Documents CSIDL_FAVORITES = 0x0006, // \Favorites CSIDL_STARTUP = 0x0007, // Start Menu\Programs\Startup CSIDL_RECENT = 0x0008, // \Recent CSIDL_SENDTO = 0x0009, // \SendTo CSIDL_BITBUCKET = 0x000a, // \Recycle Bin CSIDL_STARTMENU = 0x000b, // \Start Menu CSIDL_MYDOCUMENTS = CSIDL_PERSONAL, // Personal was just a silly name for My Documents CSIDL_MYMUSIC = 0x000d, // "My Music" folder CSIDL_MYVIDEO = 0x000e, // "My Videos" folder CSIDL_DESKTOPDIRECTORY = 0x0010, // \Desktop CSIDL_DRIVES = 0x0011, // My Computer CSIDL_NETWORK = 0x0012, // Network Neighborhood (My Network Places) CSIDL_NETHOOD = 0x0013, // \nethood CSIDL_FONTS = 0x0014, // windows\fonts CSIDL_TEMPLATES = 0x0015, CSIDL_COMMON_STARTMENU = 0x0016, // All Users\Start Menu CSIDL_COMMON_PROGRAMS = 0X0017, // All Users\Start Menu\Programs CSIDL_COMMON_STARTUP = 0x0018, // All Users\Startup CSIDL_COMMON_DESKTOPDIRECTORY = 0x0019, // All Users\Desktop CSIDL_APPDATA = 0x001a, // \Application Data CSIDL_PRINTHOOD = 0x001b, // \PrintHood CSIDL_LOCAL_APPDATA = 0x001c // \Local Settings\Applicaiton Data (non roaming) }

    [DllImport("shfolder.dll", CharSet = CharSet.Unicode)]
public static extern int SHGetFolderPath(IntPtr owner, int folder, IntPtr token, int flags, StringBuilder path);

}

void MyFunction()

{ StringBuilder path = new StringBuilder(260);

String folderPath = ""; if (0 == Utilities.SHGetFolderPath(IntPtr.Zero, (int) Utilities.FolderPaths.CSIDL_MYVIDEO, IntPtr.Zero, 0, path)) { folderPath = path.ToString(); }

}

Clay Nichols