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:
parent
10265fb501
commit
c65973bb3f
BackupEssentials
@ -13,11 +13,32 @@ namespace BackupEssentials{
|
|||||||
[DllImport("USER32.DLL")]
|
[DllImport("USER32.DLL")]
|
||||||
public static extern bool SetForegroundWindow(IntPtr hwnd);
|
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){
|
private void StartApp(object sender, StartupEventArgs args){
|
||||||
ProgramArgsParser parser = new ProgramArgsParser(args.Args);
|
ProgramArgsParser parser = new ProgramArgsParser(args.Args);
|
||||||
|
|
||||||
if (parser.HasFlag("runshell")){
|
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{
|
else{
|
||||||
Process[] running = Process.GetProcessesByName(Path.GetFileNameWithoutExtension(Assembly.GetEntryAssembly().Location));
|
Process[] running = Process.GetProcessesByName(Path.GetFileNameWithoutExtension(Assembly.GetEntryAssembly().Location));
|
||||||
|
@ -74,9 +74,9 @@ namespace BackupEssentials.Backup{
|
|||||||
|
|
||||||
foreach(BackupLocation loc in valid){
|
foreach(BackupLocation loc in valid){
|
||||||
string key = @"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell\BackupEssentials"+cmd;
|
string key = @"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell\BackupEssentials"+cmd;
|
||||||
++cmd;
|
|
||||||
Registry.SetValue(key,null,loc.Name);
|
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;
|
return true;
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace BackupEssentials.Utils{
|
namespace BackupEssentials.Utils{
|
||||||
class ProgramArgsParser{
|
class ProgramArgsParser{
|
||||||
|
Loading…
Reference in New Issue
Block a user