コード例 #1
0
        private bool IniciarAntiCopia()
        {
            bool res = false;

            // verificar llave
            try
            {
                if (!usbKey.IniciarConexion("00"))
                {
                    DialogResult dr;
                    do
                    {
                        dr = usbKey.MensajeFalloProteccion(usbKey.Estado);
                        if (dr == DialogResult.Retry)
                        {
                            res = usbKey.IniciarConexion("00");
                        }
                    } while (res == false && dr == DialogResult.Retry);
                    if (res == false || dr == DialogResult.Cancel)
                    {
                        //System.Windows.Forms.Application.Exit();
                        return(false);
                    }
                    // iniciar timer de verificacion
                    var r = new Random();
                    llavePresente = true;
                    VerificacionLlave.Interval = r.Next(1200000) + 600000;
                    VerificacionLlave.Start();
                    return(true);
                }
                else
                {
                    llavePresente = true;
                    // iniciar timer de verificacion
                    var r = new Random();
                    llavePresente = true;
                    VerificacionLlave.Interval = r.Next(1200000) + 600000;
                    VerificacionLlave.Start();
                    return(true);
                }
            }
            catch (DllNotFoundException)
            {
                MessageBox.Show("Error fatal: no se ha encontrado la librería de protección, el sistema se cerrará.",
                                "Librería de Protección no encontrada", MessageBoxButtons.OK, MessageBoxIcon.Error);
                //System.Windows.Forms.Application.Exit();
                return(false);
            }
        }
コード例 #2
0
        private void Hora_Tick(object sender, EventArgs e)
        {
            // actualizar hora
            tsHora.Text = DateTime.Now.ToString();
            if (DateTime.Now.Hour.ToString() == "0" && estadoWek == true)
            {
                CeroHoras.Enabled = true;
                estadoWek         = false;
            }

            if (DateTime.Now.Hour.ToString() == "1" && estadoWek == true)
            {
                estadoWek = true;
            }

            // verificar llave
#if USBKEY
            if (!llavePresente)
            {
                VerificacionLlave.Stop();
                if (FormHelper.IsActive(this))
                {
                    DialogResult dr;
                    do
                    {
                        dr = usbKey.MensajeFalloProteccion(usbKey.Estado);
                        if (dr == DialogResult.Retry)
                        {
                            llavePresente = usbKey.VerificarLlaveUSB();
                        }
                    } while (dr == DialogResult.Retry && !llavePresente);
                    // verificar que hacer
                    if (!llavePresente)
                    {
                        //salir!
                        System.Windows.Forms.Application.Exit();
                    }
                    else
                    {
                        VerificacionLlave.Start();
                    }
                }
            }
#endif
        }