1
0
mirror of https://github.com/chylex/Backup-Essentials.git synced 2025-06-02 06:34:08 +02:00

Moved Explorer Integration to location IDs instead of text

This commit is contained in:
chylex 2015-04-10 18:33:21 +02:00
parent 10265fb501
commit c65973bb3f
3 changed files with 24 additions and 5 deletions

View File

@ -13,11 +13,32 @@ namespace BackupEssentials{
[DllImport("USER32.DLL")]
public static extern bool SetForegroundWindow(IntPtr hwnd);
/// <summary>
/// List of arguments
/// =================
/// -runshell = switch to backup runner
/// [ required -src and either -dest or -locid ]
/// -src = backup source (folder or file)
/// -dest = backup destination (folder)
/// -locid = backup location id
/// </summary>
private void StartApp(object sender, StartupEventArgs args){
ProgramArgsParser parser = new ProgramArgsParser(args.Args);
if (parser.HasFlag("runshell")){
new BackupWindow(new BackupRunner(parser.GetValue("src",null),parser.GetValue("dest",null))).Show();
int locid = -1;
string dest = parser.GetValue("dest","");
if (int.TryParse(parser.GetValue("locid","-1"),out locid) && locid >= 0){
DataStorage.Load(DataStorage.Type.Locations);
if (locid < DataStorage.BackupLocationList.Count){
dest = DataStorage.BackupLocationList[locid].Directory;
}
}
if (dest.Length > 0)Application.Current.Shutdown();
else new BackupWindow(new BackupRunner(parser.GetValue("src",null),dest)).Show();
}
else{
Process[] running = Process.GetProcessesByName(Path.GetFileNameWithoutExtension(Assembly.GetEntryAssembly().Location));

View File

@ -74,9 +74,9 @@ namespace BackupEssentials.Backup{
foreach(BackupLocation loc in valid){
string key = @"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell\BackupEssentials"+cmd;
++cmd;
Registry.SetValue(key,null,loc.Name);
Registry.SetValue(key+@"\command",null,path+" -runshell -dest \""+loc.Directory+"\" -src \"%1\"");
Registry.SetValue(key+@"\command",null,path+" -runshell -locid "+cmd+" -src \"%1\"");
++cmd;
}
return true;

View File

@ -1,7 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace BackupEssentials.Utils{
class ProgramArgsParser{