private void RemoteAppMainWindow_Load(object sender, EventArgs e) { new SystemRemoteApps().Init(); try { IconModule.TestIconLib(); } catch (FileNotFoundException) { MessageBox.Show("IconLib.dll is unavailable. Please add it to the RemoteApp Tool folder."); Environment.Exit(0); } Text = $"{System.Reflection.Assembly.GetExecutingAssembly().GetName().Name} {System.Reflection.Assembly.GetExecutingAssembly().GetName().Version} ({System.Net.Dns.GetHostName()})"; if (Control.ModifierKeys != Keys.Shift) { if (UserSettings.Instance.MainWindowWidth >= MinimumSize.Width) { Width = UserSettings.Instance.MainWindowWidth; } if (UserSettings.Instance.MainWindowHeight >= MinimumSize.Height) { Height = UserSettings.Instance.MainWindowHeight; } } HelpSystem.SetupTips(this); AddSysMenuItems(); ReloadApps(); }
private void ExtractFtIcon(string productFileName, RemoteAppLib.New.FileTypeAssociation fta) { // Extract icon for filetype if (!IconModule.ExtractToIco(fta.IconPath, int.Parse(fta.IconIndex), productFileName + "." + fta.Extension + ".ico")) { // If filetype icon fails to extract, then grab the default document icon from Shell32.dll IconModule.ExtractToIco(RemoteAppFunction.GetSysDir() + @"\shell32.dll", 0, productFileName + "." + fta.Extension + ".ico"); // Possibly show an error here?? } }
public static System.Drawing.Bitmap GetAppBitmap(string remoteAppShortName) { // FIX : Potential exception. var appKey = $@"SOFTWARE\Microsoft\Windows NT\CurrentVersion\Terminal Server\TSAppAllowList\Applications\{remoteAppShortName}"; var registryKey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(appKey); var icon = IconModule.ReturnIcon("", 0).ToBitmap(); if (registryKey is null) { return(icon); } var iconPath = registryKey.GetValue("IconPath", ""); var iconIndex = (int)registryKey.GetValue("IconIndex", ""); return(IconModule.ReturnIcon((string)iconPath, iconIndex).ToBitmap()); }
public void LoadValues() { ShortNameText.Text = _remoteApp.Name; CommandLineOptionCombo.SelectedIndex = _remoteApp.CommandLineOption; FullNameText.Text = _remoteApp.FullName; PathText.Text = _remoteApp.Path; CommandLineText.Text = _remoteApp.CommandLine; CommandLineOptionCombo.SelectedIndex = _remoteApp.CommandLineOption; IconPathText.Text = _remoteApp.IconPath; IconIndexText.Text = _remoteApp.IconIndex.ToString(); var tswa = 0; if (_remoteApp.TSWA) { tswa = 1; } TSWAbox.SelectedIndex = tswa; var TheIcon = IconModule.ReturnIcon(IconPathText.Text, (int)Math.Round(double.Parse(IconIndexText.Text)), true); Icon = TheIcon ?? Forms.RemoteAppMainWindow.Icon; }
private void CreateButton_Click(object sender, EventArgs e) { var MSIPath = string.Empty; if (CheckBoxSignRDPEnabled.Checked && string.IsNullOrEmpty(CertificateComboBox.SelectedItem as string)) { MessageBox.Show("You must select a certificate to sign the RDP file.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (DisabledFTACheckBox.Checked && _remoteApp.FileTypeAssociations != null) { _remoteApp.FileTypeAssociations.Clear(); } string RDPPath; if (RDPRadioButton.Checked) { FileSaveRDP.FileName = _remoteApp.Name; if (FileSaveRDP.ShowDialog() != DialogResult.OK) { return; } RDPPath = FileSaveRDP.FileName; } else { FileSaveMSI.FileName = _remoteApp.Name; if (FileSaveMSI.ShowDialog() != DialogResult.OK) { return; } MSIPath = FileSaveMSI.FileName; RDPPath = Environment.GetEnvironmentVariable("TEMP") + @"\" + _remoteApp.Name + ".rdp"; _ = Environment.GetEnvironmentVariable("TEMP") + @"\" + _remoteApp.Name + ".msi"; } if (UseRDGatewayCheckBox.Checked) { _ = GatewayAddress.Text; _ = AttemptDirectCheckBox.Checked; } if (RDPRadioButton.Checked) { CreateRDPFile(RDPPath, _remoteApp); // !!!!!!! If it's an RDP file if (EditAfterSave.Checked) { var CmdLine = RemoteAppFunction.GetSysDir() + @"\notepad.exe"; Process.Start(CmdLine, FileSaveRDP.FileName); } if (CreateRAWebIcon.Checked) { var IconFilePath = RDPPath.Substring(0, RDPPath.Length - 4) + ".ico"; if (!IconModule.ExtractToIco(_remoteApp.IconPath, _remoteApp.IconIndex, IconFilePath)) { MessageBox.Show("Icon could not be created the RemoteApp. RDP file will still be created.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } // Check if there are file type associations before trying to work with the file type association icons if (_remoteApp.FileTypeAssociations != null) { foreach (RemoteAppLib.New.FileTypeAssociation fta in _remoteApp.FileTypeAssociations) { var ProductFileName = RDPPath.Substring(0, RDPPath.Length - 4); ExtractFtIcon(ProductFileName, fta); } } } Close(); } else { // !!!!!!! If it's an MSI var RDP = new RDP2MSIlib.New.RDP(); CreateRDPFile(RDPPath, _remoteApp); RDP.RDPFilePath = RDPPath; RDP.ShortcutOnDesktop = ShortcutDesktopCheckBox.Checked; RDP.ShortcutInStart = ShortcutStartCheckBox.Checked; RDP.ShortcutSubfolderInStart = SubfolderRadioButton.Checked; RDP.ProductRemoteTag = ShortcutTagTextBox.Text; RDP.PerUser = PerUserRadioButton.Checked; var FilesToDelete = new List <string>(); var ProductFileName = RDPPath.Substring(0, RDPPath.Length - 4); var IconFilePath = ProductFileName + ".ico"; FilesToDelete.Add(RDPPath); if (!IconModule.ExtractToIco(_remoteApp.IconPath, _remoteApp.IconIndex, IconFilePath)) { MessageBox.Show("There was an error loading icon:" + Environment.NewLine + _remoteApp.IconPath + "," + _remoteApp.IconIndex + Environment.NewLine + "The MSI will still be created but the main icon will be missing.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else { FilesToDelete.Add(IconFilePath); } if (_remoteApp.FileTypeAssociations != null) { foreach (RemoteAppLib.New.FileTypeAssociation fta in _remoteApp.FileTypeAssociations) { ExtractFtIcon(ProductFileName, fta); FilesToDelete.Add(ProductFileName + "." + fta.Extension + ".ico"); } RDP.FlatFileTypes = _remoteApp.FileTypeAssociations.GetFlatFileTypes(); } RDP.CreateMSI(MSIPath); RemoteAppFunction.DeleteFiles(FilesToDelete); Close(); } }