Słuchajcie.
Piszę program do blokowania folderów na hasło. Mam już gotowe wszystko, chcę go dodać do menu kontekstowego.
Zrobiłem to dodając w regedit następujący klucz:
HKEY_CLASSES_ROOT\Folder\shell\Folder Locker\command
a w nim wartość domyślną ustawiłem na:
C:\Users\XXX\Documents\Visual Studio 2012\Projects\FolderLockerContext\FolderLockerContext\bin\Debug\FolderLockerContext.exe "%1""
( ścieżka oczywiście tymczasowa bo lepiej mi debugować ).
Potrzebuję w kodzie programu przypisać do zmiennej ścieżkę tego folderu, na którym uruchamiam aplikację z menu kontekstowego. Bez tego nie mogę sprawdzić czy jest zablokowany / odblokowany oraz podjąć dalsze czynności.
Niestety nie chce mi działać to przypisywanie ścieżki a zrobiłem to tak:
Program.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace FolderLockerContext
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
FolderLocker flock = new FolderLocker();
if (args.Length > 0)
{
flock.pathkey = args[0];
}
Application.Run(new FolderLocker());
}
}
}
FolderLocker.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace FolderLockerContext
{
public partial class FolderLocker : Form
{
public FolderLocker()
{
InitializeComponent();
}
private string _pathkey;
public string pathkey
{
get { return _pathkey; }
set { _pathkey = value; }
}
private void FolderLocker_Load(object sender, EventArgs e)
{
MessageBox.Show(pathkey);
}
}
}
Próbowałem sobie wyświetlić pathkey jednak widzę puste okienko...
Bardzo proszę o pomoc bo na pewno to prosta sprawa a ja już walczę z nią kilka godzin...