private void SearchSubKey(String process, RegistryKey key) { RegistryKey subkey; String name; foreach (String keyName in key.GetSubKeyNames()) { try { subkey = key.OpenSubKey(keyName); name = subkey.GetValue("DisplayName").ToString(); if (name.IndexOf(process, StringComparison.OrdinalIgnoreCase) >= 0) { foreach (String filePath in Directory.GetFiles(subkey.GetValue("InstallLocation").ToString(), "*.exe")) { if (ProcessesToStartList.Where(x => x.FileName == filePath).Count() == 0) { ProcessPrototype pts = new ProcessPrototype(ProcessesToStartList.Count(), filePath, name); ProcessesToStartList.Add(pts); } } } } catch (Exception e) { Utils.Log(LogLevels.ERROR, e.ToString()); } } }
/// <summary> /// Send process icon to the client /// </summary> private void SendProcessIcon(int previousProcessID) { if (ProcessPrototypesList != null && ProcessPrototypesList.Count > 0) { ProcessPrototype prototype = null; if (previousProcessID == 0) { prototype = ProcessPrototypesList.FirstOrDefault(); } else { prototype = ProcessPrototypesList.SkipWhile(x => x.ProcessID != previousProcessID).Skip(1).FirstOrDefault(); } if (prototype != null) { Icon ico = Icon.ExtractAssociatedIcon(prototype.FileName); if (ico != null) { Bitmap bitmap = ico.ToBitmap(); RemoteAppManager.Packets.Message message = new RemoteAppManager.Packets.Message(MessageTypes.RESPONSE_IMAGE, Utils.BitmapToBase64String(bitmap) + ConnectionService.PROCESS_START_DELIMITER + prototype.ProcessID + ConnectionService.PROCESS_END_DELIMITER); Send(this.Socket, message.Data, true); } } } }
protected void AddProcessToStart(Message message) { if (message != null) { String[] dataArray = message.Text.Split(';'); int processID; if (dataArray.Count() >= 2 && Int32.TryParse(dataArray[0], out processID)) { ProcessPrototype process = ProcessToStartCollection.FirstOrDefault(x => x.ID == processID); if (process == null) { process = new ProcessPrototype(processID, dataArray[1]); Application.Current.Dispatcher.BeginInvoke( DispatcherPriority.Background, new Action(() => { ProcessToStartCollection.Add(process); })); Connection.Send(Connection.Socket, new Message(MessageTypes.REQUEST_NEXT_PROCESS_TO_START, process.ID.ToString())); } } } }
protected override void RemoveProcess(Message message) { if (message != null) { String data = message.Text; int processID; if (Int32.TryParse(data, out processID)) { ProcessPrototype process = ProcessCollection.FirstOrDefault(x => x.ID == processID); if (process != null) { Application.Current.Dispatcher.BeginInvoke( DispatcherPriority.Background, new Action(() => { ProcessCollection.Remove(process); })); } if (SelectedPrototype != null && SelectedPrototype.ID == processID) { SelectedPrototype = null; RefreshProperties(); } } } }
public void SendProcessToStart(int previousProcessID) { if (ProcessesToStartList != null) { ProcessPrototype process = ProcessesToStartList.SkipWhile(x => x.ProcessID != previousProcessID).Skip(1).FirstOrDefault(); if (process != null) { TrySendProcessToStart(process); } else { Send(this.Socket, new RemoteAppManager.Packets.Message(MessageTypes.RESPONSE_PROCESS_TO_START_END).Data); } } }
private void TrySendProcessToStart(ProcessPrototype process) { try { if (Socket.Connected && process != null && process.ProcessID >= 0) { String data = process.ProcessID + ";" + process.Name; RemoteAppManager.Packets.Message message = new RemoteAppManager.Packets.Message(MessageTypes.RESPONSE_PROCESS_TO_START, data); Send(Socket, message.Data, true); } } catch (Exception e) { Utils.Log(LogLevels.WARNING, "Process not sent " + process.ToString()); } }
private void RefreshProcessPrototypesList() { ProcessPrototypesList.Clear(); //build filename list if (_processesCacheList != null) { foreach (Process process in _processesCacheList) { String fileName = TryGetProcessFilename(process); if (!String.IsNullOrEmpty(fileName)) { ProcessPrototype proto = new ProcessPrototype(process.Id, fileName); ProcessPrototypesList.Add(proto); } } } }
protected override void AddProcessIcon(Message message) { if (message != null) { int processID; if (Int32.TryParse(Utils.GetTextBetween(message.Text, ConnectionService.PROCESS_START_DELIMITER, ConnectionService.PROCESS_END_DELIMITER), out processID)) { String imageText = message.Text.Substring(0, message.Text.IndexOf(ConnectionService.PROCESS_START_DELIMITER)); Bitmap bitmap = Utils.Base64StringToBitmap(imageText); if (bitmap != null) { ProcessPrototype prototype = null; prototype = ProcessCollection.FirstOrDefault(x => x.ID == processID); if (prototype == null) { prototype = ProcessToStartCollection.FirstOrDefault(x => x.ID == processID); } if (prototype != null) { ImageSource imageSource = Utils.BitmapToImageSource(bitmap); bitmap.Dispose(); prototype.AddIcon(imageSource); } Connection.Send(Connection.Socket, new Message(MessageTypes.REQUEST_NEXT_ICON, prototype.ID.ToString())); } } } }