Results 1 to 6 of 6

Thread: [RESOLVED] Edit Registry

  1. #1

    Thread Starter
    Frenzied Member met0555's Avatar
    Join Date
    Jul 2006
    Posts
    1,385

    Resolved [RESOLVED] Edit Registry

    Hi i waned to edit one of the value that is found in the registry, but don't know how:S, can someone show me a sample code, for example HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\FontSubstitutes

    thanks

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Edit Registry

    Search the forums for RegOpenKey and RegSetValueEx and you will find many code examples.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  3. #3

    Thread Starter
    Frenzied Member met0555's Avatar
    Join Date
    Jul 2006
    Posts
    1,385

    Re: Edit Registry

    Well, i've tried this code and it don't seems working

    vb Code:
    1. Option Explicit
    2.          
    3.          Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal HKey As Long) _
    4.          As Long
    5.          Private Declare Function RegCreateKey Lib "advapi32.dll" Alias "RegCreateKeyA" _
    6.          (ByVal HKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
    7.          Private Declare Function RegDeleteValue Lib "advapi32.dll" Alias "" ()
    8.    
    9.          Private Declare Function RegSetValueEx Lib "advapi32.dll" Alias "RegSetValueExA" _
    10.          (ByVal HKey As Long, ByVal lpValueName As String, ByVal Reserved As Long, _
    11.          ByVal dwType As Long, lpData As Any, ByVal cbData As Long) As Long
    12.    
    13.         Private Const REG_SZ = 1
    14.         Private Const HKEY_LOCAL_MACHINE = &H80000001
    15.          
    16.  
    17.        
    18.         Private Sub SaveString(HKey As Long, Path As String, Name As String, Data As String)
    19.          
    20.            Dim KeyHandle As Long
    21.             Dim RetVal As Long
    22.             RetVal = RegCreateKey(HKey, Path, KeyHandle)
    23.             RetVal = RegSetValueEx(KeyHandle, Name, 0, REG_SZ, ByVal Data, Len(Data))
    24.             RetVal = RegCloseKey(KeyHandle)
    25.          
    26.         End Sub
    27.      
    28.         Private Sub MSShellDlg(text As String)
    29.         Call SaveString(HKEY_LOCAL_MACHINE, "SOFTWARE\Microsoft\Windows NT\CurrentVersion\FontSubstitutes", "MS Shell Dlg", text)
    30.        MsgBox "done1"
    31.         End Sub
    32.          
    33.        
    34.         Private Sub Command1_Click()
    35.         MSShellDlg ("Tahoma")
    36.   MsgBox "done"
    37.       End Sub

  4. #4
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Edit Registry

    Since you now want to create the actual key then do you also have proper permissions and have you tried refreshing the registry?
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  5. #5

    Thread Starter
    Frenzied Member met0555's Avatar
    Join Date
    Jul 2006
    Posts
    1,385

    Re: Edit Registry

    Yes i have the admin permission , and i tried refreshing but it's still the same.

    Thanks

  6. #6

    Thread Starter
    Frenzied Member met0555's Avatar
    Join Date
    Jul 2006
    Posts
    1,385

    Re: Edit Registry

    well i found the problem, i changed
    vb Code:
    1. Private Const HKEY_LOCAL_MACHINE = &H80000001
    to
    vb Code:
    1. Private Const HKEY_LOCAL_MACHINE = &H80000002
    and it's working perfect

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