brady gaster

yadnb

programmatically access favorites

Is there, like, a system folder that would be, say, “this user's favorites” folder? Meaning, all of the URL shortcuts that someone had saved to their favorites? Anyone know this?

Comments

Jeff Gonzalez said:

System.Environment.GetFolderPath(Environment.SpecialFolder.Favorites)... You would need to impersonate this user and associate the executing thread with the impersonated principal.
# May 12, 2004 4:04 PM

brady gaster said:

Dude, that's SO money! Thanks!
# May 12, 2004 4:18 PM

Jeff Gonzalez said:

[DllImportAttribute("Kernel32")]
private static extern long GetPrivateProfileString(string section, string key, string def, StringBuilder value, int size, string filepath);


[STAThread]
static void Main(string[] args)
{
String[] favoriteFiles = Directory.GetFiles(Environment.GetFolderPath(Environment.SpecialFolder.Favorites), "*.url");

for (int i = 0; i < favoriteFiles.Length; i++)
{
Console.WriteLine(RetrieveFavoritesDetails("InternetShortcut", "URL", favoriteFiles[i]));
}


Console.WriteLine();
Console.Read();
}

internal static string RetrieveFavoritesDetails(string sectionName, string propertyName, string path)
{
StringBuilder stringBuilder = new StringBuilder(255);
GetPrivateProfileString(sectionName, propertyName, String.Empty, stringBuilder, 255, path);
return stringBuilder.ToString();
}
# May 12, 2004 5:48 PM

Jeff Gonzalez said:

and... Your Welcome! =)
# May 12, 2004 5:48 PM
Leave a Comment

(required) 

(required) 

(optional)

(required)