Lotus Notes FAQ Visit Our Sponsor!

How do you determine the NT Service Pack Level using LotusScript?

Put this code into a button:

(Declarations)
Declare Function RegOpenKeyEx Lib "advapi32.dll" Alias "RegOpenKeyExA" (Byval hkey As Long, Byval lpSubKey As String, Byval ulOptions As Long, Byval samDesired As Long, phkResult As Long) As Long
Declare Function RegQueryValueEx Lib "advapi32.dll" Alias "RegQueryValueExA" (Byval hkey As Long, Byval lpValueName As String, Byval lpReserved As Long, lpType As Long, Byval lpData As String, lpcbData As Long) As Long
Declare Function RegCloseKey Lib "advapi32.dll" (Byval hkey As Long) As Long

Const HKEY_LOCAL_MACHINE = &H80000002
Const SYNCHRONIZE = &H100000
Const STANDARD_RIGHTS_READ = &H20000
Const KEY_QUERY_VALUE = &H1
Const KEY_ENUMERATE_SUB_KEYS = &H8
Const KEY_NOTIFY = &H10
Const KEY_READ = ((STANDARD_RIGHTS_READ Or KEY_QUERY_VALUE Or KEY_ENUMERATE_SUB_KEYS Or KEY_NOTIFY) And (Not SYNCHRONIZE))
Const ERROR_SUCCESS = 0&
Const REG_SZ = 1

Sub Click(Source As Button)
     ' from Paul Ray @ IRI_SOFTWARE
     Dim hKey As Long, result As Long, length As Long
     Dim sValue As String
     
     ' open the key
     result=RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\Microsoft\Windows NT\CurrentVersion", 0, KEY_READ, hKey) 
     
     If result <> ERROR_SUCCESS Then
          Messagebox "Can't open key"
     Else
          sValue=Space$(128)
          length=128
          
          ' query the value of the key
          result=RegQueryValueEx(hKey, "CSDVersion", 0, REG_SZ, sValue, length)
          
          ' display it
          If result = ERROR_SUCCESS Then
               Messagebox Left$(sValue, length) 
          End If
          
          ' close the key
          Call RegCloseKey(hKey)  
     End If
     
End Sub


Applies to Notes Versions: 4
4.5
4.6
5
Last Modified: August 31, 1999