我的 vb.net 程序创建/打开/编辑注册表文件。开发后,当我将该程序用于另一台计算机时,它会返回错误:
如果我将注册表文件导入计算机,程序运行正常,所以我猜这个错误与注册表文件的创建有关。
这是程序创建注册表文件的方式:
Function createRegistrykey()
Dim openKey As RegistryKey
openKey = Registry.CurrentUser.OpenSubKey("SOFTWARE\RobinsonsRetailGroup\LogSettings", True)
'[SPECIFICATION]
If (openKey.GetValue("STORENAME") = Nothing) Then
openKey.SetValue("STORENAME", "RRR", RegistryValueKind.String)
End If
If (openKey.GetValue("STORENUMBER") = Nothing) Then
openKey.SetValue("STORENUMBER", "000", RegistryValueKind.String)
End If
'[DEFAULT]
If (openKey.GetValue("UTILFLR") = Nothing) Then
openKey.SetValue("UTILFLR", "C:\Util", RegistryValueKind.String)
End If
If (openKey.GetValue("GRSFLR") = Nothing) Then
openKey.SetValue("GRSFLR", "D:\DC\Instances\", RegistryValueKind.String)
End If
If (openKey.GetValue("EXPORTFLR") = Nothing) Then
openKey.SetValue("EXPORTFLR", "C:\Export", RegistryValueKind.String)
End If
If (openKey.GetValue("OFFICEIMPFLR") = Nothing) Then
openKey.SetValue("OFFICEIMPFLR", "C:\Program Files\", RegistryValueKind.String)
End If
If (openKey.GetValue("PCMSTBAKFLR") = Nothing) Then
openKey.SetValue("PCMSTBAKFLR", "C:\BAK", RegistryValueKind.String)
End If
If (openKey.GetValue("DBASEBAKFLR") = Nothing) Then
openKey.SetValue("DBASEBAKFLR", "D:\Backup\Store", RegistryValueKind.String)
End If
If (openKey.GetValue("INTBACKUPFLR") = Nothing) Then
openKey.SetValue("INTBACKUPFLR", "D:\BACKUP", RegistryValueKind.String)
End If
If (openKey.GetValue("EXTBACKUPFLR") = Nothing) Then
openKey.SetValue("EXTBACKUPFLR", "none", RegistryValueKind.String)
End If
'[POS]
If (openKey.GetValue("POSUSER") = Nothing) Then
openKey.SetValue("POSUSER", "Administrator", RegistryValueKind.String)
End If
If (openKey.GetValue("POSPASS") = Nothing) Then
openKey.SetValue("POSPASS", hashEncoding("isd"), RegistryValueKind.String)
End If
If (openKey.GetValue("LOGVIEWERPASS") = Nothing) Then
openKey.SetValue("LOGVIEWERPASS", hashEncoding("BBOEY"), RegistryValueKind.String)
End If
openKey.Close()
Return vbNull
End Function
有谁知道为什么会发生这个错误?