Update Application After Registry Change

D

Digga

Hi

I've posted this question over on the Outlook discussion group and have been
advised to try and use something like the wm_settingchange as this maybe the
only way, however, I'm unable to implement this as I really don't have a clue
and after reading about this, I'm not sure it would do it anyway.

The Problem>>
I have a piece of VBA code in Outlook to make setting changes to the
registry using the Windows API utilising RegOpenKeyEx, RegQueryValueEx,
RegCloseKey and RegSetValueEx functions, this works fine.

It appears that Outlook stores the registry settings on initilisation and
are not updated when making changes to it's registry settings. I need to know
how I can force Outlook to update it's stored registry setting for the key
that has been changed.

Is it possible to do this? If you make the change in Outlook, then the
changes are applied when you hit the OK button. I've posted the procedure
below that's making the registry changes.

Thanks in advance, all suggestion regarding this problem or the code are
welcome.

Regards,

Digga

The Procedure>>

Sub dhMarkComments()

Dim hKeyMarkComments As Long
Dim lngResult As Long
Dim lngBuffer As Long
Dim cb As Long

'Open the
HKCU\Software\Microsoft\Office\11.0\Common\MailSettings\MarkComments key
lngResult = RegOpenKeyEx(dhcHKeyCurrentUser,
"Software\Microsoft\Office\11.0\Common\MailSettings", 0&, dhcKeyAllAccess,
hKeyMarkComments)

'Make sure the call succeeded
If lngResult = dhcSuccess Then

'Create the buffer
'lngBuffer = Space(255)
cb = Len(lngBuffer)

'Read the Mark Comments value
lngResult = RegQueryValueEx(hKeyMarkComments, "MarkComments", 0&,
dhcRegDWord, lngBuffer, cb)

'Check return value
If lngResult = dhcSuccess Then

'Set new value
If lngBuffer = 0 Then

lngBuffer = 1
lngResult = RegSetValueEx(hKeyMarkComments, "MarkComments",
0&, dhcRegDWord, lngBuffer, cb)

MsgBox "Mark Comments changed to: " & lngBuffer

ElseIf lngBuffer = 1 Then

lngBuffer = 0
lngResult = RegSetValueEx(hKeyMarkComments, "MarkComments",
0&, dhcRegDWord, lngBuffer, cb)

MsgBox "Mark Comments changed to: " & lngBuffer

End If

End If

'Close the Mark Comments key
lngResult = RegCloseKey(hKeyMarkComments)

End If

End Sub
 
S

Steve Rindsberg

We've run into similar problems with PowerPoint. Apparently, the app reads its
registry settings at startup, writes any that are changed by the user during the
session back to its internal copy and to the registry but doesn't re-read the
registry again during the current session.

For properties that aren't exposed to VBA, the only way to affect the current
session seems to be using SendKeys to modify dialog boxes.

Blechhh.
 
T

Tom Winter

I've also ran into this with Outlook when changing the settings for
signatures in the registry. Actually, different versions of Outlook do this
differently. Some versions (sorry, don't remember off the top of my head)
read the value from the registry every time its needed. Some only read it at
startup. You'll see this limiting some commercial applications too. Plaxo
for example, which changes your signature settings in Outlook, will prompt
you (depending on your version of Outlook) that you'll need to restart
Outlook for its changes to take effect. I've found no way around this.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top