Registry Woes

Registry Woes

Anonymous
Not applicable
442 Views
1 Reply
Message 1 of 2

Registry Woes

Anonymous
Not applicable

Ok Chaps,

 

I'm losing the will to live with this one. The attached VbScript mods the registry and turns the selected Addins Off/On. I've been trying to replicate this in VB2008 Express to no avail. I've got no idea why the changes aren't being seen within the registry.

 

Can anyone help?

 

The code is called from:

 Sub...

        Dim DXInventor As New RegistryEntry
        DXInventor.ChangeRegistryKey("B4A1FDAE-DF01-4F8F-BDF0-6F349DEC69B5", strOn)

End Sub...

----------------------------------------------------------------------------------------------------------------

Imports Microsoft.Win32


Public Class RegistryEntry
    Public Sub ChangeRegistryKey(ByVal strMainKey As String, ByVal StrOn As String)
        Dim key As String = "{" & strMainKey & "}"
        Dim RegKey As RegistryKey = My.Computer.Registry.ClassesRoot.OpenSubKey _
        ("CLSID\{" & strMainKey & "}\Settings", True)

        If Not RegKey Is Nothing Then
            RegKey.SetValue("LoadOnStartUp", StrOn)
            RegKey.Close()
        End If
    End Sub
End Class

 

Any help would be greatly appreciated.

 

Kind regards

 

Jon.

0 Likes
Accepted solutions (1)
443 Views
1 Reply
Reply (1)
Message 2 of 2

Anonymous
Not applicable
Accepted solution

Ok,

 

I've figured it - **** 64bit/32bit registry again.

 

The program has to be 32 bit to use the dwf viewer (as identified in my previous posts!), which then means that the registry cannot be written to.

 

To over comve this, I copied my code into a second program (written as 64 bit), and set this to run as shown below:

 

 Private Sub SetRegistry(ByVal blnOn As Boolean)
        Dim strFileName As String = "WAChangeRegistryOff"
        If blnOn = True Then strFileName = "WAChangeRegistryOn"
        Shell("C:\" & strFileName & ".exe", AppWinStyle.Hide)
        Sleep(100)
        For Each proc As Process In Process.GetProcessesByName(strFileName)
            proc.Kill()
        Next
    End Sub

 

There is probably a better way of doing this, and please feel free to offer suggestions.

 

Cheers

 

Jon.

0 Likes