Option Explicit
Private Sub Form_Load()
10 On Error GoTo Form_Load_Err
Dim strGetUN As String
Dim strGetEM As String
Dim strGetSN As String
20 hParentWnd = SetWindowLong(Me.hWnd, GWL_HWNDPARENT, frmBRL.hWnd)
30 strGetUN = GetSetting("Braille Quick Reference Guide", "Registration Information", "UN", "")
40 strGetEM = GetSetting("Braille Quick Reference Guide", "Registration Information", "EM", "")
50 strGetSN = GetSetting("Braille Quick Reference Guide", "Registration Information", "SN", "")
60 lblUsername(1).Caption = strGetUN
70 lblEmailAddress(1).Caption = strGetEM
80 lblSerialNumber(1).Caption = strGetSN
90 Exit Sub
Form_Load_Err:
100 WriteToErrorLog "BRG023"
End Sub
Private Sub cmdBackupRegistrationFile_Click()
10 On Error GoTo cmdBackupRegistrationFile
Dim intRet As Integer
20 intRet = MsgBox("You are about to backup your registration file for" & vbNewLine & _
"Braille Quick Reference Guide (Version: " & App.Major & "." & App.Minor & "." & App.Revision & ")" & vbNewLine & _
"Please click Yes to complete backup or click No to cancel the backup." & vbNewLine & vbNewLine & _
"Make sure that you have a floppy disk in your floppy disk drive before you continue.", vbYesNo + vbQuestion, "Backup Registration Information?")
30 If intRet = vbYes Then
40 FileCopy (App.Path & "\licence.lic"), "C:\licence.lic"
50 CreateRegFile
60 MsgBox "File copied to your floppy disk successfully!", vbInformation, "File Copied Successfully!!"
70 Else
'do nothing
80 End If
90 Exit Sub
cmdBackupRegistrationFile:
100 If Err.Number = 76 Then
110 MsgBox "You do not have a floppy disk" & vbNewLine & _
"in your floppy disk drive!", vbExclamation, "Floppy disk not found."
120 End If
130 WriteToErrorLog "BRG024"
End Sub
Public Function CreateRegFile()
10 On Error GoTo CreateRegFile_Err
Dim strUNValue As String
Dim strEMValue As String
Dim strSNValue As String
Dim strStartupValue As String
Dim strRegFileName As String
Dim strDirectory As String
Dim strRegFileNameSave As String
Dim intFreeFile As Integer
20 strDirectory = "Backup"
30 If Len(Dir$(App.Path & "\Backup\", vbDirectory)) > 0 Then
'do nothing because the directory exists
40 Else
50 MkDir (strDirectory)
60 End If
70 intFreeFile = FreeFile
80 strUNValue = GetSetting("Braille Quick Reference Guide", "Registration Information", "UN", "")
90 strEMValue = GetSetting("Braille Quick Reference Guide", "Registration Information", "EM", "")
100 strSNValue = GetSetting("Braille Quick Reference Guide", "Registration Information", "SN", "")
110 strStartupValue = GetSetting("Braille Quick Reference Guide", "Startup", "Show At Startup", "")
120 strRegFileName = "backup"
130 strRegFileNameSave = App.Path & "\Backup\" & strRegFileName & ".reg"
140 Open strRegFileName For Append As #intFreeFile
150 Print #intFreeFile, "Windows Registry Editor Version 5.00"
160 Print #intFreeFile, "[HKEY_CURRENT_USER\Software\VB and VBA Program Settings\Braille Quick Reference Guide]"
170 Print #intFreeFile, "[HKEY_CURRENT_USER\Software\VB and VBA Program Settings\Braille Quick Reference Guide\Registration Information]"
180 Print #intFreeFile, Chr("34") & "UN" & Chr("34") & Chr("61") & Chr("34") & strUNValue & Chr("34")
190 Print #intFreeFile, Chr("34") & "EM" & Chr("34") & Chr("61") & Chr("34") & strEMValue & Chr("34")
200 Print #intFreeFile, Chr("34") & "SN" & Chr("34") & Chr("61") & Chr("34") & strSNValue & Chr("34")
210 Print #intFreeFile, "[HKEY_CURRENT_USER\Software\VB and VBA Program Settings\Braille Quick Reference Guide\Startup]"
220 Print #intFreeFile, Chr("34") & "Show At Startup" & Chr("34") & Chr("61") & Chr("34") & strStartupValue & Chr("34")
230 Close #intFreeFile
240 FileCopy (App.Path & "\Backup\backup.reg"), "C:\backup.reg"
CreateRegFile_Err:
250 WriteToErrorLog "RegKey"
End Function