특이한가요? 이 const를 delcarations에 추가하고 또는 오픈 레지스트리 호출의 값을 사용해보십시오. KEY_WOW64_32KEY and KEY_WOW64_64KEY에 대한 대답은 매우 잘 설명되어 있습니다.
Private Const KEY_WOW64_64KEY As Long = &H100& '32 bit app to access 64 bit hive
Private Function GetWindowsProductId() As String
Dim strReturn As String
Dim strBuffer As String
Dim lngType As Long
Dim lngBufLen As Long
Dim lngRst As Long
Dim hKeyHandle As Long
lngRst = RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\Microsoft\Windows NT\CurrentVersion", 0, KEY_READ Or KEY_WOW64_64KEY, hKeyHandle)
If hKeyHandle <> 0 Then
strBuffer = String(255, vbNullChar)
lngBufLen = Len(strBuffer)
lngRst = RegQueryValueEx(hKeyHandle, "ProductId", ByVal 0&, lngType, ByVal strBuffer, lngBufLen)
If lngRst = 0 Then
If lngType = REG_SZ Then
If lngBufLen > 0 Then
strReturn = Left$(strBuffer, lngBufLen - 1)
Else
strReturn = "nothing was returned"
End If
Else
strReturn = "there was an error"
End If
ElseIf lngRst = 2 Then 'the key does not exist
strReturn = "the key was not found"
Else 'if the return is non-zero there was an error
strReturn = "There was an error " & CStr(lngRst) & " reading the key"
End If
End If
GetWindowsProductId = strReturn
End Function
출처
2013-11-15 16:55:01
jac
Windows 7 32 비트 또는 64? –