Click to See Complete Forum and Search --> : Service Pack info
wayneh
Nov 22nd, 1999, 11:38 AM
Anyone know how to get the current service pack number from an NT oS?
I can get os, version and build, but not sp!
Serge
Nov 22nd, 1999, 11:44 AM
Sure. If you use GetVersionEx API. You would have to pass OSVERSIONINFO structure. So, the element szCSDVersion of that structure is holding that information i.e. string like "Service Pack 3")
------------------
Serge
Software Developer
Serge_Dymkov@vertexinc.com
Access8484@aol.com
ICQ#: 51055819 (http://www.icq.com/51055819)
[This message has been edited by Serge (edited 11-22-1999).]
wayneh
Nov 22nd, 1999, 10:47 PM
I tried a couple variations of your suggestion and got errors or no information. I must be implementing it wrong. This is what I did:
In a module I put:
Declare Function GetVersionEx Lib "kernel32" Alias "GetVersionExA" (ByVal lpVersionInformation As OSVERSIONINFO) As Long
Type OSVERSIONINFO
dwOSVersionInfoSize As Long
dwMajorVersion As Long
dwMinorVersion As Long
dwBuildNumber As Long
dwPlatformId As Long
szCSDVersion As String * 128 ' Maintenance string for PSS usage
End Type
Public myosversion As OSVERSIONINFO
in my form code I put:
GetVersionEx myosversion
Text1.Text = Text1.Text & "buildno" & myosversion.dwBuildNumber
With this code i get errors "user defined type may not be passed byVal"
VB help suggested removing 'byval' from the declaration. When I did that, all elements of the 'type' returned '0' except szCSDVersion which returned a null string.
What am I doing wrong?
Serge
Nov 23rd, 1999, 12:25 AM
Even though I sent you the correct code, I'll post it here anyway, so other people can use it.
Copy this to a module:
Public Declare Function GetVersionEx Lib "kernel32" Alias "GetVersionExA" (lpVersionInformation As OSVERSIONINFO) As Long
Public Type OSVERSIONINFO
dwOSVersionInfoSize As Long
dwMajorVersion As Long
dwMinorVersion As Long
dwBuildNumber As Long
dwPlatformId As Long
szCSDVersion As String * 128 ' Maintenance string for PSS usage
End Type
Public g_udtOS As OSVERSIONINFO
Use this on any event you want:
Dim lRet As Long
g_udtOS.dwOSVersionInfoSize = Len(g_udtOS)
lRet = GetVersionEx(g_udtOS)
If lRet Then
Text1.Text = g_udtOS.dwBuildNumber
Else
MsgBox "Error retrieving OS version."
End If
Note: szCSDVersion element will show you Service Pack Number only in WindowsNT. For Windows95/98 it will return arbitrary additional information about the operating system.
------------------
Serge
Software Developer
Serge_Dymkov@vertexinc.com
Access8484@aol.com
ICQ#: 51055819 (http://www.icq.com/51055819)
badgers
Nov 23rd, 1999, 01:11 AM
I have not been at this very long so I am most likely wrong since serge is a lot more experienced then I am but;
how about this
Text1.Text = g_udtOS.dwBuildNumber
changing to this
Text1.Text = g_udtOS.szCSDVersion
to get the service pack info.
thank you for your time and have a good day
------------------
I am so skeptacle, I can hardly believe it!
wayneh
Nov 23rd, 1999, 07:40 PM
Badgers -
Thanks, but the code I posted was just a small sample. I did in fact have the line you suggested, but the problem I encountered was unrelated to which information I was showing.
See the reply from Serge above - he hit the nail on the head - it was a problem with the way the GetVersionEx function was described in the API viewer. Thanks anyway!
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.