Test Foro de elhacker.net SMF 2.1

Programación => Programación General => .NET (C#, VB.NET, ASP) => Mensaje iniciado por: adan-2994 en 11 Enero 2013, 21:21 PM

Título: Option Strict on no permtite el enlace en tiempo de ejecucion
Publicado por: adan-2994 en 11 Enero 2013, 21:21 PM
Ya se que para evitar esto debería indicar mas específicamente de que tipo de objeto se trata, osea, si se trata de un Textbox o un Button
pero en este caso no tengo idea que pueda hacer

El codigo que me da error es este (la parte de Regwrite)


Código (vbnet) [Seleccionar]
Dim WSHShell As Object

WSHShell = CreateObject("Wscript.Shell")

WSHShell.RegWrite("BLA BLA BLA COSAS DE REGISTRO")



En otros problemas he resuelto esto con un Ctype o DirectCast para convertir el objet directamente a lo que quiero, pero aqui la verdad no se que tipo es  :-X

¿Existe solucion, o lo mejor seria Option Stric Off ?
             
Título: Re: Option Strict on no permtite el enlace en tiempo de ejecucion
Publicado por: Danyfirex en 11 Enero 2013, 21:37 PM
http://javascripts.astalaweb.com/Ayuda/html/wsmthregwrite.asp

saludos
Título: Re: Option Strict on no permtite el enlace en tiempo de ejecucion
Publicado por: Eleкtro en 11 Enero 2013, 21:57 PM
Si quieres un consejo, usa esto:

Código (vbnet) [Seleccionar]
    '  RegCreateKey(Registry.CurrentUser, "Software\MyProgram")
    '  RegDeleteKey(Registry.CurrentUser, "Software\MyProgram")
    '  RegDeleteValue(Registry.CurrentUser, "Software\MyProgram", "Value name")
    '  RegSetValue("HKEY_CURRENT_USER\Software\MyProgram", "Value name", "Data", RegistryValueKind.String)
    '  Dim RegValue = RegGetValue("HKEY_CURRENT_USER\Software\MyProgram", "Value name"))

#Region "Registry Edit"

    Public Sub RegCreateKey(ByVal RegRoot As Microsoft.Win32.RegistryKey, ByVal RegKey As String)
        RegRoot.CreateSubKey(RegKey)
        RegRoot.Close()
    End Sub

    Public Sub RegDeleteKey(ByVal RegRoot As Microsoft.Win32.RegistryKey, ByVal RegKey As String)
        RegRoot.DeleteSubKey(RegKey)
        RegRoot.Close()
    End Sub

    Public Sub RegDeleteValue(ByVal RegRoot As Microsoft.Win32.RegistryKey, ByVal RegKey As String, ByVal RegValue As String)
        Using key As Microsoft.Win32.RegistryKey = RegRoot.OpenSubKey(RegKey, True)
            key.DeleteValue(RegValue)
            key.Close()
        End Using
    End Sub

    Public Sub RegSetValue(ByVal RegKey As String, ByVal RegValue As String, ByVal RegData As String, ByVal RegDataType As RegistryValueKind)
        My.Computer.Registry.SetValue(RegKey, RegValue, RegData, RegDataType)
    End Sub

    Public Function RegGetValue(ByVal RegKey As String, ByVal RegValue As String)
        Return My.Computer.Registry.GetValue(RegKey, RegValue, Nothing)
    End Function

#End Region


Saludos
Título: Re: Option Strict on no permtite el enlace en tiempo de ejecucion
Publicado por: seba123neo en 11 Enero 2013, 22:14 PM
no uses el objeto Wscript.Shell, es obsoleto en .NET, usa las clases de .NET que ya vienen para acceder al registro.