Usuário com melhor resposta
DLL registrada ou não?

Pergunta
-
Boa Tarde Pessoal,
Existe alguma biblioteca que de suporte a manipulação de DLL?
Quero desenvolver um aplicativo que registre e desregistre determinada DLL em determinada pasta. Qual método usar para ter este retorno de registro?
Grato,
PCGSG
Respostas
-
Então, é isso mesmo!!
É só você fazer um loop na pasta efetuando o comando abaixo, veja o exemplo:
Exemplo (Vb.Net) :
Dim Arquivos As New System.IO.DirectoryInfo("Caminho dos arquivos")
For Each Arquivo As IO.FileInfo In Arquivos.GetFiles("*.dll")
If Registra Then
'Para registrar
Shell(String.Format("regsvr32 {0}", Arquivo.FullName))
Else
'Para desregistrar
Shell(String.Format("regsvr32 -u {0}", Arquivo.FullName))
End If
Next
Todas as Respostas
-
Boa tarde,
Se você quer apenas registrar a dll no local, sem utilizar o COM+ é simples, utiliza o método "SHELL" para executar o comando "regsvr32 c:\teste\teste.dll" para registrar a DLL e o comando "regsvr32 -u c:\teste\teste.dll" para desregistra-la.
-
-
Então, é isso mesmo!!
É só você fazer um loop na pasta efetuando o comando abaixo, veja o exemplo:
Exemplo (Vb.Net) :
Dim Arquivos As New System.IO.DirectoryInfo("Caminho dos arquivos")
For Each Arquivo As IO.FileInfo In Arquivos.GetFiles("*.dll")
If Registra Then
'Para registrar
Shell(String.Format("regsvr32 {0}", Arquivo.FullName))
Else
'Para desregistrar
Shell(String.Format("regsvr32 -u {0}", Arquivo.FullName))
End If
Next
-
Valeuuuu AndesBh exatamente isso meu caro!!!!!!!
PCGSG!
Pra quem interessar:Public Class frmRegDLL
Private Sub frmRegDLL_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Me.SetDesktopLocation(1070, 890)
End Sub
Private Sub btnReg_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnReg.Click
RegistroDll(True)
End Sub
Private Sub btnDereg_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDereg.Click
RegistroDll(False)
End Sub
Public Sub RegistroDll(ByVal flag As Boolean)
Dim caminho As String
If (txtDll.Text <> "XXX") AndAlso (txtDll.Text <> "XXX") Then
caminho = ("C:\Manut\Componente\" & txtDll.Text & "\Dll\Servidor")
Else
caminho = ("C:\Manut\Componente\" & txtDll.Text & "\Servidor")
End If
Try
Dim Arquivos As New System.IO.DirectoryInfo(caminho)
If flag = True Then
For Each Arquivo As IO.FileInfo In Arquivos.GetFiles("*.dll")
Shell(String.Format("regsvr32 {0}", Arquivo.FullName))
Next
MsgBox("DLLs Registradas com Sucesso!")
ElseIf flag = False Then
For Each Arquivo As IO.FileInfo In Arquivos.GetFiles("*.dll")
Shell(String.Format("regsvr32 -u {0}", Arquivo.FullName))
Next
MsgBox("DLLs Desregistradas com Sucesso!")
End If
Catch ex As System.IO.DirectoryNotFoundException
MsgBox("Esta pasta não foi encontrada!")
End Try
End Sub
Private Sub txtDll_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtDll.TextChanged
If IsNumeric(txtDll.Text) And txtDll.Text <> "" Then
MsgBox("Informe apenas a sigla do sistema !")
txtDll.Text = ""
Exit Sub
End If
End Sub
End Class
- Editado PCGSG quinta-feira, 3 de novembro de 2011 20:31