代码:

Public Const READ_CONTROL = &H20000
Public Const STANDARD_RIGHTS_READ = (READ_CONTROL)
Public Const STANDARD_RIGHTS_WRITE = (READ_CONTROL)

Public Const KEY_QUERY_VALUE = &H1
Public Const KEY_SET_VALUE = &H2
Public Const KEY_CREATE_SUB_KEY = &H4
Public Const KEY_ENUMERATE_SUB_KEYS = &H8
Public Const KEY_NOTIFY = &H10
Public Const KEY_CREATE_LINK = &H20

Public Const SYNCHRONIZE = &H100000
Public Const STANDARD_RIGHTS_ALL = &H1F0000

Public Const KEY_READ = ((STANDARD_RIGHTS_READ Or KEY_QUERY_VALUE Or KEY_ENUMERATE_SUB_KEYS Or KEY_NOTIFY) And (Not SYNCHRONIZE))

Public Const KEY_WRITE = ((STANDARD_RIGHTS_WRITE Or KEY_SET_VALUE Or KEY_CREATE_SUB_KEY) And (Not SYNCHRONIZE))

Public Const KEY_ALL_ACCESS = ((STANDARD_RIGHTS_ALL Or KEY_QUERY_VALUE Or KEY_SET_VALUE Or KEY_CREATE_SUB_KEY Or KEY_ENUMERATE_SUB_KEYS Or KEY_NOTIFY Or KEY_CREATE_LINK) And (Not SYNCHRONIZE))

Public Const KEY_EXECUTE = ((KEY_READ) And (Not SYNCHRONIZE))

升级后:

Public Const READ_CONTROL As Integer = &H20000
Public Const STANDARD_RIGHTS_READ As Integer = (READ_CONTROL)
Public Const STANDARD_RIGHTS_WRITE As Integer = (READ_CONTROL)

Public Const KEY_QUERY_VALUE As Integer = &H1
Public Const KEY_SET_VALUE As Integer = &H2
Public Const KEY_CREATE_SUB_KEY As Integer = &H4
Public Const KEY_ENUMERATE_SUB_KEYS As Integer = &H8
Public Const KEY_NOTIFY As Integer = &H10
Public Const KEY_CREATE_LINK As Integer = &H20

Public Const SYNCHRONIZE As Integer = &H100000
Public Const STANDARD_RIGHTS_ALL As Integer = &H1F0000

Public Const KEY_READ As Boolean = ((STANDARD_RIGHTS_READ Or KEY_QUERY_VALUE Or KEY_ENUMERATE_SUB_KEYS Or KEY_NOTIFY) And (Not SYNCHRONIZE))

Public Const KEY_WRITE As Boolean = ((STANDARD_RIGHTS_WRITE Or KEY_SET_VALUE Or KEY_CREATE_SUB_KEY) And (Not SYNCHRONIZE))

Public Const KEY_ALL_ACCESS As Boolean = ((STANDARD_RIGHTS_ALL Or KEY_QUERY_VALUE Or KEY_SET_VALUE Or KEY_CREATE_SUB_KEY Or KEY_ENUMERATE_SUB_KEYS Or KEY_NOTIFY Or KEY_CREATE_LINK) And (Not SYNCHRONIZE))

Public Const KEY_EXECUTE As Boolean = ((KEY_READ) And (Not SYNCHRONIZE))

请看红色的标注处,赫然给升级成了Boolean类型,而正确的应该是Integer。很明显升级向导将与运算当成了逻辑运算最终导致类型侦测试错误