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.
Printable View
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.
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.
Example from an old application of mine:
VB Code:
' Write to registry WriteRegistry HKEY_LOCAL_MACHINE, "Software\Prodman Limited\CoshhMan\", "Task Frequency", ValString ' Get the details from the registry If Not DefaultFrequency = (GetRegValue(HKEY_LOCAL_MACHINE, "Software\Prodman Limited\CoshhMan\", "Task Frequency")) Then Exit Sub
Daz
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.Quote:
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?
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
Would this registry key be the same on any Windows system?
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)
Private Const HKEY_LOCAL_MACHINE = &H80000002
Private Const READ_CONTROL = &H20000
Private Const SYNCHRONIZE = &H100000
Private Const STANDARD_RIGHTS_READ = (READ_CONTROL)
Private Const KEY_CREATE_LINK = &H20
Private Const KEY_CREATE_SUB_KEY = &H4
Private Const KEY_ENUMERATE_SUB_KEYS = &H8
Private Const KEY_NOTIFY = &H10
Private Const KEY_QUERY_VALUE = &H1
Private Const KEY_SET_VALUE = &H2
Private Const KEY_READ = ((STANDARD_RIGHTS_READ Or KEY_QUERY_VALUE Or KEY_ENUMERATE_SUB_KEYS Or KEY_NOTIFY) And (Not SYNCHRONIZE))
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
That's a good question, that I don't know the answer to.Quote:
Originally posted by Avatarp
Would this registry key be the same on any Windows system?
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.
Sorry I can't help any more : /