Results 1 to 4 of 4

Thread: Registry...?????

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Oct 1999
    Location
    chicago (hope)
    Posts
    146

    Post

    I want to make a dir in the registry with some keys for programm settings, but i want it on "hkey_localmachine\software\timer" (timer = programm's name...).

    this doesn't work with the savesettings-function (only hkey_currentuser\software\vb and vba program\timer ........)

    is there a OCX or somethiny else, that could help me ?
    thanx for help

    vbAlex

  2. #2
    Frenzied Member Mark Sreeves's Avatar
    Join Date
    Nov 1999
    Location
    UK
    Posts
    1,845

    Post

    email me directly

    ------------------
    Mark Sreeves
    Analyst Programmer

    Mark.Sreeves@Softlab.co.uk
    A BMW Group Company

  3. #3
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744

    Post

    Sure thing:

    Code:
    Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
    Private Declare Function RegOpenKeyEx Lib "advapi32.dll" Alias "RegOpenKeyExA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal ulOptions As Long, ByVal samDesired As Long, phkResult 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 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
    Private Declare Function RegCreateKeyEx Lib "advapi32.dll" Alias "RegCreateKeyExA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal Reserved As Long, ByVal lpClass As String, ByVal dwOptions As Long, ByVal samDesired As Long, lpSecurityAttributes As SECURITY_ATTRIBUTES, phkResult As Long, lpdwDisposition As Long) As Long
    
    Private Const HKEY_LOCAL_MACHINE = &H80000002
    Private Const REG_SZ = 1
    Private Const KEY_SET_VALUE = &H2
    Private Const ERROR_SUCCESS = 0&
    Private Type SECURITY_ATTRIBUTES
            nLength As Long
            lpSecurityDescriptor As Long
            bInheritHandle As Long
    End Type
    
    Public Sub SaveProgram(pHive As Long, pKeyName As String, pProgramName As String)
        Dim lKeyHandle As Long
        Dim lRet As Long
        Dim strValue As String
        Dim strKey As String
        Dim sec As SECURITY_ATTRIBUTES
        Dim lDummy As Long
        
        sec.nLength = Len(sec)
        strKey = "Software\Timer"
        strValue = "MyProgram"
        lRet = RegCreateKeyEx(HKEY_LOCAL_MACHINE, strKey, 0, vbNullString, 0, KEY_SET_VALUE, sec, lKeyHandle, lDummy)
        If lRet <> ERROR_SUCCESS Then
            MsgBox "Error creating a KEY", vbCritical
            Exit Sub
        End If
        RegCloseKey lKeyHandle
        lRet = RegOpenKeyEx(HKEY_LOCAL_MACHINE, strKey, 0, KEY_SET_VALUE, lKeyHandle)
        If lRet = ERROR_SUCCESS Then
            lRet = RegSetValueEx(lKeyHandle, strValue, 0, REG_SZ, ByVal "", 1)
            RegCloseKey lKeyHandle
        End If
    End Sub
    Usage: SaveProgram KEYROOT, KeyValue, ProgramName

    Example: SaveProgram HKEY_LOCAL_MACHINE, "Software\Timer", "MyProgram"


    Regards,

    ------------------

    Serge

    Software Developer
    Serge_Dymkov@vertexinc.com
    Access8484@aol.com



  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Oct 1999
    Location
    chicago (hope)
    Posts
    146

    Post

    thanx!

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