public static void Unpin(string _SourceObj, PIN_DESTINATION _PinTo) { // Known bug: Incomplete }
public static bool IsPinned(string _SourceObj, PIN_DESTINATION _PinTo) { // Known bug: Incomplete return(false); }
public static void Pin(string _SourceObj, PIN_DESTINATION _PinTo, string _IconFileName = null) { // // Current version assumes _SourceObj is an RDS RemoteApp shortcut // C:\Users\John\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\misrds.jrfcorp.net (RADC)\Funds Database (misrds.jrfcorp.net).lnk try { if (_IconFileName == null) { _IconFileName = String.Empty; } string appdata_folder = Jrfc.Shell.GetUserAppdataFolder(); string source_file_wo_ext = Path.GetFileNameWithoutExtension(_SourceObj); string source_file_ext = Path.GetExtension(_SourceObj); string stubexe_filepath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "TaskBarStub.exe"); string stubnew_filename = source_file_wo_ext + ".exe"; string stubnew_filepath = Path.Combine(appdata_folder, stubnew_filename); string stubini_filename = Path.Combine(appdata_folder, source_file_wo_ext + ".ini"); string stubico_filename = Path.Combine(appdata_folder, source_file_wo_ext + ".ico"); string PinTo10_exepath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "PinTo10", "PinTo10.exe"); //// Create the source //BitmapImage img = new BitmapImage(); //img.BeginInit(); //img.UriSource = new Uri(_IconFileName); //img.EndInit(); //img. //BitmapSource bs = CreateBitmapSource(Colors.Green); /* Write (renamed) TaskbarStub.ini */ List <string> ini_lines = new List <string>(); ini_lines.Add("LaunchFilename=" + _SourceObj); ini_lines.Add("IconFilename=" + _IconFileName); System.IO.File.WriteAllLines(stubini_filename, ini_lines.ToArray()); /* Create new renamed TaskbarStub.exe, then inkove to replace icon */ File.Copy(stubexe_filepath, stubnew_filepath, true); // true = overwrite if (!string.IsNullOrWhiteSpace(_IconFileName)) { if (File.Exists(_IconFileName)) { IconChanger ic = new IconChanger(); ic.ChangeIcon(stubnew_filepath, _IconFileName); } } /* Pin to Taskbar */ ProcessStartInfo psi2 = new ProcessStartInfo(PinTo10_exepath); if (_PinTo == PIN_DESTINATION.Taskbar) { psi2.Arguments = @"/PTFOL01:'" + appdata_folder + "' /PTFILE01:'" + stubnew_filename + "'"; } else if (_PinTo == PIN_DESTINATION.Start) { psi2.Arguments = @"/PSFOL01:'" + appdata_folder + "' /PSFILE01:'" + stubnew_filename + "'"; } psi2.WindowStyle = ProcessWindowStyle.Hidden; psi2.CreateNoWindow = true; Process.Start(psi2); } catch (System.Exception x) { throw x; } }