private void btnImportarDLL_Click(object sender, EventArgs e)
        {
            OpenFileDialog op = new OpenFileDialog();

            op.Title      = "Selecionar DLL";
            op.DefaultExt = "dll";
            op.Filter     = "dll files (*.dll)|*.dll|All files (*.*)|*.*";
            op.ShowDialog();

            txtImportarDLL.Text = op.FileName;
            string SATDLL = txtImportarDLL.Text;

            int tamanho = IntPtr.Size;

            tamanho.ToString();

            ptr = FuncoesDll.LoadLibrary(SATDLL);

            if ((tamanho == 4) && (ptr != IntPtr.Zero))
            {
                FuncoesDLL();
            }
            else if ((tamanho == 8) && (ptr != IntPtr.Zero))
            {
                FuncoesDLL();
            }
            else
            {
                MessageBox.Show("Erro ao importar DLL");
                grpBoxFuncoes.Enabled = false;
                return;
            }
        }
        public Codigo_de_Ativacao(string dll)
        {
            InitializeComponent();
            string SATDLL = dll;

            ptr = FuncoesDll.LoadLibrary(SATDLL);

            intptr_trocarCodigoDeAtivacao = FuncoesDll.GetProcAddress(ptr, "TrocarCodigoDeAtivacao");
            trocarCodigoDeAtivacao        = (TrocarCodigoDeAtivacao)Marshal.GetDelegateForFunctionPointer
                                                (intptr_trocarCodigoDeAtivacao,
                                                typeof(TrocarCodigoDeAtivacao));
        }
Exemplo n.º 3
0
        public Configurar_Rede(string dll)
        {
            InitializeComponent();
            string SATDLL = dll;

            ptr = FuncoesDll.LoadLibrary(SATDLL);

            intptr_ConfigurarInterfaceDeRede = FuncoesDll.GetProcAddress(ptr, "ConfigurarInterfaceDeRede");
            configurarInterfaceDeRede        = (ConfigurarInterfaceDeRede)Marshal.GetDelegateForFunctionPointer
                                                   (intptr_ConfigurarInterfaceDeRede,
                                                   typeof(ConfigurarInterfaceDeRede));
        }
        private void Tela_Principal_FormClosing(object sender, FormClosingEventArgs e)
        {
            DialogResult dr = MessageBox.Show("Tem certeza de que deseja sair do aplicativo ? ",
                                              "Sair", MessageBoxButtons.YesNo);

            if (dr == DialogResult.No)
            {
                e.Cancel = true;
            }
            else
            {
                FuncoesDll.FreeLibrary(ptr);
            }
        }
        public void FuncoesDLL()
        {
            try
            {
                intptr_ConsultarSAT = FuncoesDll.GetProcAddress(ptr, "ConsultarSAT");
                consultarSAT        = (ConsultarSAT)Marshal.GetDelegateForFunctionPointer(intptr_ConsultarSAT, typeof(ConsultarSAT));

                intptr_ConsultarStastusOperacional = FuncoesDll.GetProcAddress(ptr, "ConsultarStatusOperacional");
                consultarStatusOperacional         = (ConsultarStatusOperacional)Marshal.GetDelegateForFunctionPointer
                                                         (intptr_ConsultarStastusOperacional,
                                                         typeof(ConsultarStatusOperacional));

                intptr_AtivarSAT = FuncoesDll.GetProcAddress(ptr, "AtivarSAT");
                ativarSAT        = (AtivarSAT)Marshal.GetDelegateForFunctionPointer
                                       (intptr_AtivarSAT,
                                       typeof(AtivarSAT));

                intptr_AssociarAssinatura = FuncoesDll.GetProcAddress(ptr, "AssociarAssinatura");
                associarAssinatura        = (AssociarAssinatura)Marshal.GetDelegateForFunctionPointer
                                                (intptr_AssociarAssinatura,
                                                typeof(AssociarAssinatura));

                intptr_TesteFimAFim = FuncoesDll.GetProcAddress(ptr, "TesteFimAFim");
                testeFimAFim        = (TesteFimAFim)Marshal.GetDelegateForFunctionPointer
                                          (intptr_TesteFimAFim,
                                          typeof(TesteFimAFim));

                intptr_ExtrairLogs = FuncoesDll.GetProcAddress(ptr, "ExtrairLogs");
                extrairLogs        = (ExtrairLogs)Marshal.GetDelegateForFunctionPointer
                                         (intptr_ExtrairLogs,
                                         typeof(ExtrairLogs));

                intptr_AtualizarSoftware = FuncoesDll.GetProcAddress(ptr, "AtualizarSoftwareSAT");
                atualizarSoftware        = (AtualizarSoftwareSAT)Marshal.GetDelegateForFunctionPointer
                                               (intptr_AtualizarSoftware,
                                               typeof(AtualizarSoftwareSAT));

                intptr_DesbloquearSAT = FuncoesDll.GetProcAddress(ptr, "DesbloquearSAT");
                desbloquearSAT        = (DesbloquearSAT)Marshal.GetDelegateForFunctionPointer
                                            (intptr_DesbloquearSAT,
                                            typeof(DesbloquearSAT));

                intptr_EnviarDadosVenda = FuncoesDll.GetProcAddress(ptr, "EnviarDadosVenda");
                enviarDadosVenda        = (EnviarDadosVenda)Marshal.GetDelegateForFunctionPointer
                                              (intptr_EnviarDadosVenda,
                                              typeof(EnviarDadosVenda));

                intptr_CancelarUltimaVenda = FuncoesDll.GetProcAddress(ptr, "CancelarUltimaVenda");
                cancelarUltimaVenda        = (CancelarUltimaVenda)Marshal.GetDelegateForFunctionPointer
                                                 (intptr_CancelarUltimaVenda,
                                                 typeof(CancelarUltimaVenda));

                intptr_BloquearSAT = FuncoesDll.GetProcAddress(ptr, "BloquearSAT");
                bloquearSAT        = (BloquearSAT)Marshal.GetDelegateForFunctionPointer
                                         (intptr_BloquearSAT,
                                         typeof(BloquearSAT));

                intptr_ConsultarNumeroSessao = FuncoesDll.GetProcAddress(ptr, "ConsultarNumeroSessao");
                consultarNumeroSessao        = (ConsultarNumeroSessao)Marshal.GetDelegateForFunctionPointer
                                                   (intptr_ConsultarNumeroSessao,
                                                   typeof(ConsultarNumeroSessao));

                MessageBox.Show("DLL carregada com sucesso");
                grpBoxFuncoes.Enabled = true;
                return;
            }
            catch
            {
                MessageBox.Show("DLL importada não é uma dll SAT", "Erro", MessageBoxButtons.OK);
                txtImportarDLL.Text   = "";
                grpBoxFuncoes.Enabled = false;
                return;
            }
        }