I am trying to write a managed class in C # to port SHGetKnownFolderPath while it is running on Vista, but it crashes on XP because I did not find the proper function in shell32.dll, as expected.
I want it to be configured in such a way that I can refuse (admittedly, a hacker) solution using System.Environment.GetFolderPath if you are using XP. (Or, better yet, if he cannot find funciton in shell32.)
Is there a way to do this other conditional compilation?
My current code is as follows:
public abstract class KnownFolders { [DllImport("shell32.dll")] private static extern int SHGetKnownFolderPath([MarshalAs(UnmanagedType.LPStruct)] Guid rfid, uint dwFlags, IntPtr hToken, out IntPtr pszPath);
source share