You can also retreive the OS from the registry...i'm not 100% sure about win2k though.
That's alot of code and you might wanna stick to the GetVersionEx API, but i'm not sure how it would work for Win2k.Code:Private Const HKEY_LOCAL_MACHINE = &H80000002 Private Const REG_SZ = 1 Private Const REG_BINARY = 3 Private Const REG_DWORD = 4 Private Const ERROR_SUCCESS = 0& Private Declare Function RegSetValueEx Lib "advapi32.dll" Alias "RegSetValueExA" (ByVal Hkey As Long, ByVal lpValueName As String, ByVal Reserved As Long, ByVal dwType As Long, lpData As Any, ByVal cbData As Long) As Long Private Declare Function RegCreateKey Lib "advapi32.dll" Alias "RegCreateKeyA" (ByVal Hkey As Long, ByVal lpSubKey As String, phkResult As Long) As Long Private Declare Function RegOpenKey Lib "advapi32.dll" _ Alias "RegOpenKeyA" (ByVal Hkey As Long, ByVal lpSubKey _ As String, phkResult As Long) As Long Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal Hkey As Long) As Long Private Declare Function RegQueryValueEx Lib "advapi32.dll" _ Alias "RegQueryValueExA" (ByVal Hkey As Long, ByVal lpValueName _ As String, ByVal lpReserved As Long, lpType As Long, lpData _ As Any, lpcbData As Long) As Long Private Function getstring(Hkey As Long, strPath As String, strValue As String) Dim keyhand As Long Dim datatype As Long Dim lResult As Long Dim strBuf As String Dim lDataBufSize As Long Dim intZeroPos As Integer r = RegOpenKey(Hkey, strPath, keyhand) lResult = RegQueryValueEx(keyhand, strValue, 0&, lValueType, ByVal 0&, lDataBufSize) If lValueType = REG_SZ Then strBuf = String(lDataBufSize, " ") lResult = RegQueryValueEx(keyhand, strValue, 0&, 0&, ByVal strBuf, lDataBufSize) If lResult = ERROR_SUCCESS Then intZeroPos = InStr(strBuf, Chr$(0)) If intZeroPos > 0 Then getstring = Left$(strBuf, intZeroPos - 1) Else getstring = strBuf End If End If End If End Function Public Sub Command1_Click() Text1.Text = getstring(HKEY_LOCAL_MACHINE, "SOFTWARE\Microsoft\Windows\CurrentVersion", "ProductName") End Sub
Gl,
D!m
PS. have a look around the registry for any other keys that you can retreive that could help you.
#500
[Edited by Dim on 10-04-2000 at 12:57 AM]




Reply With Quote