|
-
Nov 22nd, 1999, 12:38 PM
#1
Thread Starter
Hyperactive Member
Anyone know how to get the current service pack number from an NT oS?
I can get os, version and build, but not sp!
-
Nov 22nd, 1999, 12:44 PM
#2
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
[email protected]
[email protected]
ICQ#: 51055819
[This message has been edited by Serge (edited 11-22-1999).]
-
Nov 22nd, 1999, 11:47 PM
#3
Thread Starter
Hyperactive Member
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?
-
Nov 23rd, 1999, 01:25 AM
#4
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:
Code:
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:
Code:
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
[email protected]
[email protected]
ICQ#: 51055819
-
Nov 23rd, 1999, 02:11 AM
#5
Hyperactive Member
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!
-
Nov 23rd, 1999, 08:40 PM
#6
Thread Starter
Hyperactive Member
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!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|