Beispiel #1
0
        private void ConfirgureRegistryStart()
        {
            if (!WindowsLocking.CanLock())
            {
                return;
            }
            const string startupLocation = "hkcu\\Software\\Microsoft\\Windows\\CurrentVersion\\Run";
            const string valueName       = "fpalock";
            string       appLocation     = $"{Application.ExecutablePath} forcelock";

            if (!RegistryHelper.ValueExists(startupLocation, valueName))
            {
                RegistryHelper.AddValue(startupLocation, valueName, appLocation);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Form Shown Event Handler
        /// </summary>
        /// <param name="sender">Sender</param>
        /// <param name="e">EventArgs</param>
        private void Form1_Shown(object sender, EventArgs e)
        {
            string[] arguments  = Environment.GetCommandLineArgs();
            int      protectPid = -1;

            if (arguments.Length == 3 && arguments[1] == "protect")
            {
                protectPid = (int.TryParse(arguments[2], out int result)) ? result : -1;
            }

            if (protectPid == -1)
            {
#if DEBUG
                LoadDebugWindow();
#endif
                //LoadToTraybar();
                qrCodeGenerator = new QRGenerator();
                qrCodeGenerator.SetData(AndroidServer.GetLocalIPAddress(), 9624);
                LoadKeyGeneration();
                LoadAndroidServer();
                LoadJavascriptServer();
                int protectorPID = -1;
                if (arguments.Length == 3 && arguments[1] == "lock")
                {
                    protectorPID = (int.TryParse(arguments[2], out int result)) ? result : -1;
                    if (!WindowsLocking.CanLock())
                    {
                        protectorPID = -1;
                    }
                }

                systemLocking = new WindowsLocking(qrCodeGenerator, androidServer, protectorPID);
                if (protectorPID != -1)
                {
                    androidServer.SendLockSignal();
                }
                if (arguments.Length == 2 && arguments[2] == "forcelock" && WindowsLocking.CanLock())
                {
                    androidServer.SendLockSignal();
                }
            }
            else
            {
                Hide();
                ProcessLocker locker = new ProcessLocker();
                locker.StartProtectProcess(protectPid, $"lock {System.Diagnostics.Process.GetCurrentProcess().Id}");
            }
        }