Results 1 to 14 of 14

Thread: Change Registries

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2005
    Posts
    537

    Resolved Change Registries

    I am in the middle of coding a program that changes the name of the Recycle Bin, here is the code I have so far.

    VB Code:
    1. Private Sub Command1_Click()
    2. On Error Resume Next
    3. Dim REGIS As IWshShell_Class
    4. Set regis = New IWshShell_Class
    5. regis.RegWrite "HKCU\software\microsoft\windows\currentversion\explorer\clsid" _
    6. & "\{645FF040-5081-101B-9F08-00AA002F954E}\(Default)", Text1.Text, "REG_SZ"
    7. End Sub

    The problem is it doesn't change "(Default)" it makes a new one. How should I fix it?

    Thanks,
    Sir Loin
    Last edited by Sir Loin; Apr 28th, 2005 at 12:38 PM.

  2. #2
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: Change Registries

    Why would you want to do that?

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2005
    Posts
    537

    Re: Change Registries

    Because it's just a silly program I want to code. People ask me how to change its name all the time, so I want to code a program that does it form them.


    -Sir Loin

  4. #4
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: Change Registries

    In that case take a look at this tip from allapi ...

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2005
    Posts
    537

    Re: Change Registries

    Thanks!

  6. #6

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2005
    Posts
    537

    Re: Change Registries

    That's pretty tough, isn't there any other way to edit the registry?


    Thanks,
    -Sir Loin

  7. #7
    Frenzied Member sciguyryan's Avatar
    Join Date
    Sep 2003
    Location
    Wales
    Posts
    1,763

    Re: Change Registries

    Quote Originally Posted by Sir Loin
    That's pretty tough, isn't there any other way to edit the registry?


    Thanks,
    -Sir Loin
    Other than the API method and yours? I don't think there is.

    The API is the best and most flexible though but can be complicated to use

    EDIT: I have attatched a file I found useful, I did not write this I downloaded it from somewhere but no author information was included....

    Cheers,

    RyanJ
    Attached Files Attached Files
    Last edited by sciguyryan; Apr 28th, 2005 at 02:30 PM.
    My Blog.

    Ryan Jones.

  8. #8

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2005
    Posts
    537

    Re: Change Registries

    Cool, thanks.
    I was thinking, for my way i should add a .regdelete (Default), then a reg write, but I don't think it would work...

    -Sir Loin

  9. #9
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: Change Registries

    Quote Originally Posted by Sir Loin
    That's pretty tough, isn't there any other way to edit the registry?

    Thanks,
    -Sir Loin
    What's so though? Copy and paste ready to go small sample? Common ...

  10. #10

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2005
    Posts
    537

    Re: Change Registries

    I guess so, but I want to use a textbox to get the name of the Recycle Bin, the sample uses an inputbox. I tried editing it, but to no avail. Here is the code, any help would be very much appreciated.

    VB Code:
    1. Public Const EWX_LOGOFF = 0
    2. Public Const EWX_SHUTDOWN = 1
    3. Public Const EWX_REBOOT = 2
    4. Public Const EWX_FORCE = 4
    5.  
    6. Declare Function ExitWindowsEx Lib "user32" (ByVal _
    7. uFlags As Long, ByVal dwReserved As Long) As Long
    8.  
    9. Public Const HKEY_CLASSES_ROOT = &H80000000
    10. Declare Function RegCreateKey Lib "advapi32.dll" _
    11. Alias "RegCreateKeyA" (ByVal Hkey As Long, ByVal _
    12. lpSubKey As String, phkResult As Long) As Long
    13. Declare Function RegCloseKey Lib "advapi32.dll" _
    14. (ByVal Hkey As Long) As Long
    15. Declare Function RegSetValueEx Lib "advapi32.dll" _
    16. Alias "RegSetValueExA" (ByVal Hkey As Long, ByVal _
    17. lpValueName As String, ByVal Reserved As Long, ByVal _
    18. dwType As Long, lpData As Any, ByVal cbData As Long) _
    19. As Long
    20.  
    21. Public Const REG_SZ = 1
    22. Public Const REG_DWORD = 4  
    23.  
    24. Public Sub savestring(Hkey As Long, strPath As _
    25. String, strValue As String, strdata As String)
    26. Dim keyhand As Long
    27. Dim r As Long
    28. r = RegCreateKey(Hkey, strPath, keyhand)
    29. r = RegSetValueEx(keyhand, strValue, 0, _
    30. REG_SZ, ByVal strdata, Len(strdata))
    31. r = RegCloseKey(keyhand)
    32. End Sub
    33.  
    34. Form Code
    35.  
    36. On the form put 1 command button and add the following code to the click event:
    37.  
    38. Private Sub Command1_Click()
    39. 'prompts for new name
    40.  
    41. strString$ = InputBox("Please type in a string to save to the Registry.", "Recycle Bin")
    42. If strString$ = Empty Then
    43.     'string is empty or cancel is pressed
    44.     MsgBox "Empty String", vbCritical, "Error"
    45.     Exit Sub
    46. End If
    47.  
    48. 'API call to store new name
    49. Call savestring(HKEY_CLASSES_ROOT, _
    50. "CLSID\{645FF040-5081-101B-9F08-00AA002F954E}", _
    51. (pre), strString$)
    52.  
    53. MsgBox "Reset your PC", , "Changes are made"
    54. 'resets your PC
    55.  
    56. t& = ExitWindowsEx(EWX_FORCE Or EWX_REBOOT, 0)
    57. End Sub

    Thanks,
    -Sir Loin

  11. #11
    Banned Psychopathetica's Avatar
    Join Date
    Jan 2005
    Posts
    31

    Re: Change Registries

    The API approach is too much code to do something so simple. Sir Loin you were on the right trach using VBScript. It's shorter code and gets the job done. Heres the link to my code. No download is nessesary.

    http://www.planet-source-code.com/vb...55910&lngWId=1

  12. #12

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2005
    Posts
    537

    Re: Change Registries

    For real? I was doing something right for a change!? Wow..you made my day...

    -Sir Loin

  13. #13
    Banned Psychopathetica's Avatar
    Join Date
    Jan 2005
    Posts
    31

    Re: Change Registries

    Anytime man. That's what I'm here for.

  14. #14

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2005
    Posts
    537

    Re: Change Registries

    That's a great example for reading/writing, but how do I edit a registry? Like "HKLM\software\microsoft\windows nt\current version\blah\something\(Default)"



    Thanks,
    Sir Loin

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