How do I do that. I know the easy way out: Create a .reg file and execute it. Yes, I know but that makes two pop-ups. I want to do this without any probs.
It's nothing harmfull, I want to change the background picture.
No matter how fool-proof your program is, there will always be a better fool.
Have a play with this module (attachment). I have used it before to read and write to the registry. It includes a commented example if I remember correctly.
Originally posted by Avatarp I want to make the default email handler Outlook Express. Can I use your code to do this? How would I do it?
It's not my code. It's a public domain module I downloaded.
You should be able to change any value with that module. So I guess you need to find out where the default mail handler is stored within the registry, then use that key (the whole key, starting from my computer) as a parameter in the WriteRegistry sub. Find the key and I'll have a go for you
What variable(s) to you need to know the value of?
Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
Private Declare Function RegQueryValueEx Lib "advapi32.dll" Alias "RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, lpType As Long, lpData As Any, lpcbData As Long) As Long
Private Declare Function RegOpenKeyEx Lib "advapi32.dll" Alias "RegOpenKeyExA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal Reserved As Long, ByVal samDesired As Long, phkResult As Long) As Long
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (pDst As Any, pSrc As Any, ByVal ByteLen As Long)
Public Function getDefaultEmailClient()
'Find the default Email Client in the
'registry.
Dim arrBuffer() As Byte
Dim lType, lSuccess As Long
Dim lKey, lLength As Long
Dim strSubKey, strKeyValue As String
Dim strValue As String
Dim Finish As Integer
Dim MyString As String
'Set the Key and Value that we want to
'retrieve.
strSubKey = "Software\Clients\Mail"
strKeyValue = ""
'Open the appropriate Key
lSuccess = RegOpenKeyEx(HKEY_LOCAL_MACHINE, strSubKey, 0, KEY_READ, lKey)
'Get the length of the Key Value
lSuccess = RegQueryValueEx(lKey, strKeyValue, 0&, ByVal 0&, ByVal 0&, lLength)
'Initialize the buffer to lLength
ReDim arrBuffer(0 To lLength - 1) As Byte
'Get the Key Value
lSuccess = RegQueryValueEx(lKey, strKeyValue, 0, lType, arrBuffer(0), lLength)
'Initialize to lLength
strValue = String$(lLength, 0)
'Copy memory from the byte array to
'the string buffer.
CopyMemory ByVal strValue, arrBuffer(0), lLength - 1
'Close the open Key
RegCloseKey lKey
'Set the value of the function to the
'retrieved Key Value
Finish = Len(strValue) - 1
MyString = Mid(strValue, 1, Finish)
getDefaultEmailClient = MyString
End Function
Originally posted by Avatarp Would this registry key be the same on any Windows system?
That's a good question, that I don't know the answer to.
Like I say, I used the module a while back, and it seemed quite easy to use. Although I was writing a new key whereas you seem to want to modify an existing entry. But the module still works the same, all you need to do is know what to modify. I have no idea where outlook keeps it's settings.