Results 1 to 5 of 5

Thread: [RESOLVED] Backup Registry Keys for app

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Apr 2005
    Location
    Debug.Print
    Posts
    3,885

    Resolved [RESOLVED] Backup Registry Keys for app

    I know how to backup a registry key from within regedit.exe but would like to know how I can go about creating a text file with the registry keys for my app and then saving that as backup.reg. (getting those keys from the registry)

    Please advise if this can be done and if so, how would I go about doing this? Have searched VBF and found nothing that answers this question. Thanks in advance for any suggestions.

  2. #2

    Thread Starter
    PowerPoster
    Join Date
    Apr 2005
    Location
    Debug.Print
    Posts
    3,885

    Re: Backup Registry Keys for app

    I tried the following and nothing is happening... (.reg file isnt created)
    Date: 4/14/2006
    Time: 6:15:20 AM
    Error Number: 75
    Error Description: Path/File access error
    Function ID: RegKey
    Line Number: 140
    ----------------------------------------
    VB Code:
    1. Option Explicit
    2.  
    3. Private Sub Form_Load()
    4. 10        On Error GoTo Form_Load_Err
    5.           Dim strGetUN As String
    6.           Dim strGetEM As String
    7.           Dim strGetSN As String
    8.          
    9. 20        hParentWnd = SetWindowLong(Me.hWnd, GWL_HWNDPARENT, frmBRL.hWnd)
    10.          
    11. 30        strGetUN = GetSetting("Braille Quick Reference Guide", "Registration Information", "UN", "")
    12. 40        strGetEM = GetSetting("Braille Quick Reference Guide", "Registration Information", "EM", "")
    13. 50        strGetSN = GetSetting("Braille Quick Reference Guide", "Registration Information", "SN", "")
    14.          
    15. 60        lblUsername(1).Caption = strGetUN
    16. 70        lblEmailAddress(1).Caption = strGetEM
    17. 80        lblSerialNumber(1).Caption = strGetSN
    18.          
    19. 90        Exit Sub
    20.          
    21. Form_Load_Err:
    22. 100       WriteToErrorLog "BRG023"
    23. End Sub
    24.  
    25. Private Sub cmdBackupRegistrationFile_Click()
    26. 10        On Error GoTo cmdBackupRegistrationFile
    27.           Dim intRet As Integer
    28.          
    29. 20        intRet = MsgBox("You are about to backup your registration file for" & vbNewLine & _
    30.                  "Braille Quick Reference Guide (Version: " & App.Major & "." & App.Minor & "." & App.Revision & ")" & vbNewLine & _
    31.                  "Please click Yes to complete backup or click No to cancel the backup." & vbNewLine & vbNewLine & _
    32.                  "Make sure that you have a floppy disk in your floppy disk drive before you continue.", vbYesNo + vbQuestion, "Backup Registration Information?")
    33.                  
    34. 30        If intRet = vbYes Then
    35. 40            FileCopy (App.Path & "\licence.lic"), "C:\licence.lic"
    36. 50            CreateRegFile
    37. 60            MsgBox "File copied to your floppy disk successfully!", vbInformation, "File Copied Successfully!!"
    38. 70        Else
    39.               'do nothing
    40. 80        End If
    41.          
    42. 90        Exit Sub
    43. cmdBackupRegistrationFile:
    44. 100       If Err.Number = 76 Then
    45. 110           MsgBox "You do not have a floppy disk" & vbNewLine & _
    46.                      "in your floppy disk drive!", vbExclamation, "Floppy disk not found."
    47. 120       End If
    48. 130           WriteToErrorLog "BRG024"
    49. End Sub
    50.  
    51. Public Function CreateRegFile()
    52. 10        On Error GoTo CreateRegFile_Err
    53.          
    54.           Dim strUNValue                      As String
    55.           Dim strEMValue                      As String
    56.           Dim strSNValue                      As String
    57.           Dim strStartupValue                 As String
    58.           Dim strRegFileName                  As String
    59.           Dim strDirectory                    As String
    60.           Dim strRegFileNameSave              As String
    61.           Dim intFreeFile                     As Integer
    62.          
    63. 20        strDirectory = "Backup"
    64.          
    65. 30        If Len(Dir$(App.Path & "\Backup\", vbDirectory)) > 0 Then
    66.               'do nothing because the directory exists
    67. 40        Else
    68. 50            MkDir (strDirectory)
    69. 60        End If
    70.          
    71. 70            intFreeFile = FreeFile
    72. 80            strUNValue = GetSetting("Braille Quick Reference Guide", "Registration Information", "UN", "")
    73. 90            strEMValue = GetSetting("Braille Quick Reference Guide", "Registration Information", "EM", "")
    74. 100           strSNValue = GetSetting("Braille Quick Reference Guide", "Registration Information", "SN", "")
    75. 110           strStartupValue = GetSetting("Braille Quick Reference Guide", "Startup", "Show At Startup", "")
    76. 120           strRegFileName = "backup"
    77.              
    78. 130           strRegFileNameSave = App.Path & "\Backup\" & strRegFileName & ".reg"
    79.              
    80. 140           Open strRegFileName For Append As #intFreeFile
    81. 150           Print #intFreeFile, "Windows Registry Editor Version 5.00"
    82. 160           Print #intFreeFile, "[HKEY_CURRENT_USER\Software\VB and VBA Program Settings\Braille Quick Reference Guide]"
    83. 170           Print #intFreeFile, "[HKEY_CURRENT_USER\Software\VB and VBA Program Settings\Braille Quick Reference Guide\Registration Information]"
    84. 180           Print #intFreeFile, Chr("34") & "UN" & Chr("34") & Chr("61") & Chr("34") & strUNValue & Chr("34")
    85. 190           Print #intFreeFile, Chr("34") & "EM" & Chr("34") & Chr("61") & Chr("34") & strEMValue & Chr("34")
    86. 200           Print #intFreeFile, Chr("34") & "SN" & Chr("34") & Chr("61") & Chr("34") & strSNValue & Chr("34")
    87. 210           Print #intFreeFile, "[HKEY_CURRENT_USER\Software\VB and VBA Program Settings\Braille Quick Reference Guide\Startup]"
    88. 220           Print #intFreeFile, Chr("34") & "Show At Startup" & Chr("34") & Chr("61") & Chr("34") & strStartupValue & Chr("34")
    89. 230           Close #intFreeFile
    90.              
    91. 240           FileCopy (App.Path & "\Backup\backup.reg"), "C:\backup.reg"
    92.              
    93. CreateRegFile_Err:
    94. 250           WriteToErrorLog "RegKey"
    95. End Function

  3. #3

  4. #4
    Frenzied Member
    Join Date
    Apr 2005
    Posts
    1,907

    Arrow Re: Backup Registry Keys for app

    Quote Originally Posted by BrailleSchool
    found the problem. self resolved.
    i am intrested in same thing . I tried to run the above code but i get compile error in the bold part: variable not defined
    hParentWnd = SetWindowLong(Me.hWnd, GWL_HWNDPARENT, frmBRL.hWnd)


    Could u tell me what is wrong.Furthermore if i wantbackup complete registery directory that has many directories inside it what part do i need to change.I be happy if u help me here. Thanks
    Last edited by tony007; Apr 14th, 2006 at 06:05 AM.

  5. #5

    Thread Starter
    PowerPoster
    Join Date
    Apr 2005
    Location
    Debug.Print
    Posts
    3,885

    Re: Backup Registry Keys for app

    Quote Originally Posted by tony007
    i am intrested in same thing . I tried to run the above code but i get compile error in the bold part: variable not defined
    hParentWnd = SetWindowLong(Me.hWnd, GWL_HWNDPARENT, frmBRL.hWnd)


    Could u tell me what is wrong.Furthermore if i wantbackup complete registery directory that has many directories inside it what part do i need to change.I be happy if u help me here. Thanks
    remove that line as you dont need it. its used for something else in my app

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