Example #1
0
        public static void Create(string filePath, string linkPath, string args, string descr, bool dir)
        {
            ShellLink.IShellLinkW shlLink = ShellLink.CreateShellLink();

            Marshal.ThrowExceptionForHR(shlLink.SetDescription(descr));
            Marshal.ThrowExceptionForHR(shlLink.SetPath(filePath));
            Marshal.ThrowExceptionForHR(shlLink.SetArguments(args));
            Marshal.ThrowExceptionForHR(shlLink.SetIconLocation("%SystemRoot%\\System32\\SHELL32.dll", dir ? 4 : 0));

            ((System.Runtime.InteropServices.ComTypes.IPersistFile)shlLink).Save(linkPath, false);
        }
Example #2
0
        public static void Create(string PathToFile, string PathToLink, string Arguments, string Description, bool floder)
        {
            ShellLink.IShellLinkW shlLink = ShellLink.CreateShellLink();

            Marshal.ThrowExceptionForHR(shlLink.SetDescription(Description));
            Marshal.ThrowExceptionForHR(shlLink.SetPath(PathToFile));
            Marshal.ThrowExceptionForHR(shlLink.SetArguments(Arguments));
            Marshal.ThrowExceptionForHR(shlLink.SetIconLocation("%SystemRoot%\\System32\\SHELL32.dll", floder ? 4 : 0));

            ((System.Runtime.InteropServices.ComTypes.IPersistFile)shlLink).Save(PathToLink, false);
        }