重启Windows Mobile掌上电脑后,只能删除一次注册表项

时间:2014-08-01 18:41:51

标签: vb.net windows-mobile compact-framework windows-mobile-5.0 windows-mobile-6.1

我正在开发一个在Windows Mobile手持设备上运行的VB.Net应用程序。我正在使用.Net compact framework 3.5。我遇到的特定问题已经在不同制造商的3个不同设备上复制,一个使用WM 6.1,两个使用WM 5.我试图使用以下代码删除注册表项:

Public Shared Sub DeleteRegistryKey(ByVal RootKey As Microsoft.Win32.RegistryKey, ByVal KeyName As String)
  Try
    Dim RegistryKey As RegistryKey = RootKey.OpenSubKey("Software\COMPANY\Printers\", True)
    RegistryKey.DeleteSubKey(KeyName, True)
    RegistryKey.Flush()
    RegistryKey.Close()
  Catch ex As Exception
    MobileLogging.LogException(ex)
  End Try
End Sub

如果我软重启设备,代码将完美运行一次,并删除所选密钥(我已使用注册表编辑器验证了这一点)。如果我再次运行它,我会收到“unauthorizedaccessexception”错误。无论是否有冲洗和关闭呼叫,都会发生这种情况。我搜索过并搜索过,但没有找到解决办法。任何帮助将不胜感激。

0 个答案:

没有答案