Results 1 to 7 of 7

Thread: Changing registry.

  1. #1

    Thread Starter
    Fanatic Member arsmakman's Avatar
    Join Date
    Dec 2001
    Location
    Leiden, Netherlands.
    Posts
    719

    Changing registry.

    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.

    Was a post helpful to you? Rate it!

  2. #2
    Addicted Member
    Join Date
    Aug 2002
    Location
    Coventry, England
    Posts
    169
    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:
    1. ' Write to registry
    2. WriteRegistry HKEY_LOCAL_MACHINE, "Software\Prodman Limited\CoshhMan\", "Task Frequency", ValString
    3.    
    4. ' Get the details from the registry
    5. If Not DefaultFrequency = (GetRegValue(HKEY_LOCAL_MACHINE, "Software\Prodman Limited\CoshhMan\", "Task Frequency")) Then Exit Sub


    Daz
    Attached Files Attached Files
    Last edited by seh; Oct 10th, 2002 at 11:23 AM.

  3. #3
    Fanatic Member Avatarp's Avatar
    Join Date
    Sep 2002
    Location
    Calgary
    Posts
    826

    Question Could I use this code too...

    I want to make the default email handler Outlook Express. Can I use your code to do this? How would I do it?

  4. #4
    Addicted Member
    Join Date
    Aug 2002
    Location
    Coventry, England
    Posts
    169

    Re: Could I use this code too...

    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

  5. #5
    Fanatic Member Avatarp's Avatar
    Join Date
    Sep 2002
    Location
    Calgary
    Posts
    826

    Would

    Would this registry key be the same on any Windows system?

  6. #6
    Fanatic Member Avatarp's Avatar
    Join Date
    Sep 2002
    Location
    Calgary
    Posts
    826

    Here is my code...

    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

  7. #7
    Addicted Member
    Join Date
    Aug 2002
    Location
    Coventry, England
    Posts
    169

    Re: Would

    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.

    Sorry I can't help any more : /

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width