Results 1 to 4 of 4

Thread: Really need help with registry

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Aug 2000
    Location
    Dullawhere
    Posts
    100

    Question

    OK i need to do two things.
    1. Create The Registry directory: HKEY_LOCAL_MACHINE\Software\AIM Password Decoder\
    and add the following strings to it:
    Runtime (and set it's value to:) Normal
    Copyright (value:) 2000
    Programmer (value:) John Doe

    and

    2. ON Form Load, check the registry settings to see if they are the what they should be, and if they aren't, change them to what they should be.

    Any help would be appreciated. (and i mean ANYTHING)!
    I am stupid..but I AM 15 !
    *a line from a song i wrote*
    """"""""""""""""""""""""""""""""""""""""
    so i came to say life bites away
    whats done is done the past is gone
    i cant believe the sh*t I know
    i always wish it would just go
    """"""""""""""""""""""""""""""""""""""""
    "remember you Ps And Qs Boy !"

  2. #2
    Hyperactive Member marnitzg's Avatar
    Join Date
    Oct 2000
    Location
    South Africa
    Posts
    372
    Code:
    'Declares
    Public Declare Function RegSetValueEx Lib "advapi32.dll" _
    Alias "RegSetValueExA" (ByVal hKey As Long, ByVal _
    lpValueName As String, ByVal Reserved As Long, ByVal _
    dwType As Long, lpData As Any, ByVal cbData As Long) As Long
    
    Public Declare Function RegCreateKey Lib "advapi32.dll" _
    Alias "RegCreateKeyA" (ByVal hKey As Long, ByVal lpSubKey _
    As String, phkResult As Long) As Long
    
    Public Declare Function RegCloseKey Lib "advapi32.dll" _
    (ByVal hKey As Long) As Long
    
    
    'Use to save a string somewhere
    Public Sub SaveSettingString(hKey As Long, strPath _
    As String, strValue As String, strData As String)
    Dim hCurKey As Long
    Dim lRegResult As Long
    
    lRegResult = RegCreateKey(hKey, strPath, hCurKey)
    
    lRegResult = RegSetValueEx(hCurKey, strValue, 0, REG_SZ, _
    ByVal strData, Len(strData))
    
    If lRegResult <> ERROR_SUCCESS Then
        MsgBox "There was an error writing to the registry. Make sure you have administrative rights."
    End If
    
    lRegResult = RegCloseKey(hCurKey)
    End Sub

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Aug 2000
    Location
    Dullawhere
    Posts
    100
    Ok...but...How do i make it do what i want?
    I am stupid..but I AM 15 !
    *a line from a song i wrote*
    """"""""""""""""""""""""""""""""""""""""
    so i came to say life bites away
    whats done is done the past is gone
    i cant believe the sh*t I know
    i always wish it would just go
    """"""""""""""""""""""""""""""""""""""""
    "remember you Ps And Qs Boy !"

  4. #4
    Hyperactive Member marnitzg's Avatar
    Join Date
    Oct 2000
    Location
    South Africa
    Posts
    372
    Ok, here's everything!
    Code:
    Public Const HKEY_CLASSES_ROOT = &H80000000
    Public Const HKEY_CURRENT_USER = &H80000001
    Public Const HKEY_LOCAL_MACHINE = &H80000002
    Public Const HKEY_USERS = &H80000003
    Public Const HKEY_CURRENT_CONFIG = &H80000005
    Public Const HKEY_DYN_DATA = &H80000006
    Public Const REG_SZ = 1 'Unicode nul terminated string
    Public Const REG_BINARY = 3 'Free form binary
    Public Const REG_DWORD = 4 '32-bit number
    Public Const ERROR_SUCCESS = 0&
    
    Public Declare Function RegCloseKey Lib "advapi32.dll" _
    (ByVal hKey As Long) As Long
    
    Public Declare Function RegCreateKey Lib "advapi32.dll" _
    Alias "RegCreateKeyA" (ByVal hKey As Long, ByVal lpSubKey _
    As String, phkResult As Long) As Long
    
    Public Declare Function RegDeleteKey Lib "advapi32.dll" _
    Alias "RegDeleteKeyA" (ByVal hKey As Long, ByVal lpSubKey _
    As String) As Long
    
    Public Declare Function RegDeleteValue Lib "advapi32.dll" _
    Alias "RegDeleteValueA" (ByVal hKey As Long, ByVal _
    lpValueName As String) As Long
    
    Public Declare Function RegOpenKey Lib "advapi32.dll" _
    Alias "RegOpenKeyA" (ByVal hKey As Long, ByVal lpSubKey _
    As String, phkResult As Long) As Long
    
    Public 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
    
    Public Declare Function RegSetValueEx Lib "advapi32.dll" _
    Alias "RegSetValueExA" (ByVal hKey As Long, ByVal _
    lpValueName As String, ByVal Reserved As Long, ByVal _
    dwType As Long, lpData As Any, ByVal cbData As Long) As Long
    Public Sub DeleteValue(ByVal hKey As Long, _
    ByVal strPath As String, ByVal strValue As String)
    Dim hCurKey As Long
    Dim lRegResult As Long
    
    lRegResult = RegOpenKey(hKey, strPath, hCurKey)
    
    lRegResult = RegDeleteValue(hCurKey, strValue)
    
    lRegResult = RegCloseKey(hCurKey)
    
    End Sub
    
    Public Function GetSettingString(hKey As Long, _
    strPath As String, strValue As String, Optional _
    Default As String) As String
    Dim hCurKey As Long
    Dim lResult As Long
    Dim lValueType As Long
    Dim strBuffer As String
    Dim lDataBufferSize As Long
    Dim intZeroPos As Integer
    Dim lRegResult As Long
    
    'Set up default value
    If Not IsEmpty(Default) Then
    GetSettingString = Default
    Else
    GetSettingString = ""
    End If
    
    lRegResult = RegOpenKey(hKey, strPath, hCurKey)
    lRegResult = RegQueryValueEx(hCurKey, strValue, 0&, _
    lValueType, ByVal 0&, lDataBufferSize)
    
    If lRegResult = ERROR_SUCCESS Then
    
    If lValueType = REG_SZ Then
    
    strBuffer = String(lDataBufferSize, " ")
    lResult = RegQueryValueEx(hCurKey, strValue, 0&, 0&, _
    ByVal strBuffer, lDataBufferSize)
    
    intZeroPos = InStr(strBuffer, Chr$(0))
    If intZeroPos > 0 Then
    GetSettingString = Left$(strBuffer, intZeroPos - 1)
    Else
    GetSettingString = strBuffer
    End If
    
    End If
    
    Else
    'there is a problem
    End If
    
    lRegResult = RegCloseKey(hCurKey)
    End Function
    Public Sub SaveSettingString(hKey As Long, strPath _
    As String, strValue As String, strData As String)
    Dim hCurKey As Long
    Dim lRegResult As Long
    
    lRegResult = RegCreateKey(hKey, strPath, hCurKey)
    
    lRegResult = RegSetValueEx(hCurKey, strValue, 0, REG_SZ, _
    ByVal strData, Len(strData))
    
    If lRegResult <> ERROR_SUCCESS Then
    'there is a problem
    End If
    
    lRegResult = RegCloseKey(hCurKey)
    End Sub
    You know how to save.
    To get the setting again:
    Code:
    Ans = GetSettingString(HKEY_LOCAL_MACHINE, "Software\AIM Password Decoder", "Runtime")
    To delete the setting:
    Code:
    DeleteValue HKEY_LOCAL_MACHINE, "AIM Password Decoder", "Runtime"

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