TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Dave
NA
1
0
Vista & .NET quirks - obtaining system info.
Aug 7 2007 4:38 PM
Has anyone seen this behaviour? Using Environment.osVersion.ToString in Vista appends an extra .0 after the build number. This is a problem for me because my VBA code that obtains the version info does not have this behaviour. (For rationale, see bottom.)
Return string from VB.net
Microsoft Windows NT 6.0.6000.0
Return string from VBA (code at the bottom if you wish) Microsoft Windows NT 6.0.6000
Of course, this works fine for me in other flavours of Windows (2k, XP, 2k3)
The other problem I'm having with Vista is that I can't return the ProductID from the registry... I've tried running the app with Admin privledges, but no change. And I can get the info I'm looking for if I run:
<CODE>
reg query "hklm\software\microsoft
\windows nt\currentversion" /v ProductID </CODE>
I've tried three different methods of retrieving the Windows ProductID:
<CODE>
winProdID =
My.Computer.Registry.GetValue("HKEY_LOCAL_MACHINE\SOFTWARE
\Microsoft\Windows\CurrentVersi
on\",
"ProductID", "Value Not Found!")
winProdID =
My.Computer.Registry.LocalMachi
ne.OpenSubKey ("SOFTWARE\Microsoft\Windows
\CurrentVersion").GetValue(
"ProductID",
"Value Not Found!")
winProdID =
Microsoft.Win32.Registry
.GetValue("HKEY_LOCAL_MACHINE\SOFTWARE
\Microsoft\Windows\CurrentVersi
on",
"ProductID", "Value Not Found!").ToString() </CODE>
Each one returns the same thing... "Value Not Found!" (my default string if not found)
Rationale:
My software is installed by a .NET program and consists mainly of a .DOT template file for MS Word with VBA inside it to check the registration information (a serial number generated from system information).
Sure I could add a .0 at the end of osVersion string in VBA (and I have for the time being) but how will this affected by later versions of Windows? What about Vista SP1, etc??
VBA code for version info (which works in all other flavours, remember)
<CODE>
Type OSVERSIONINFO
dwOSVersionInfoSize As Long
dwMajorVersion As Long
dwMinorVersion As Long
dwBuildNumber As Long
dwPlatformId As Long
szCSDVersion As String * 128
End Type
Private Declare Function GetVersionEx Lib "kernel32" _ Alias "GetVersionExA" (lpVersionInformation As OSVERSIONINFO) As Boolean
' dwPlatforID Constants
Public Const VER_PLATFORM_WIN32s = 0
Public Const VER_PLATFORM_WIN32_WINDOWS = 1 Public Const VER_PLATFORM_WIN32_NT = 2
Public Function IdentifyOperatingSystem() As String
Dim rOsVersionInfo As OSVERSIONINFO
Dim sOperatingSystem As String
sOperatingSystem = "NONE"
' Pass the size of the structure into itself for the API call
rOsVersionInfo.dwOSVersionInfoS
ize = Len(rOsVersionInfo)
If GetVersionEx(rOsVersionInfo) Then
Select Case rOsVersionInfo.dwPlatformId
Case VER_PLATFORM_WIN32_NT
sOperatingSystem = "Microsoft Windows NT " & rOsVersionInfo.dwMajorVersion & "." & _
rOsVersionInfo.dwMinorVersion & "." & rOsVersionInfo.dwBuildNumber & " " & rOsVersionInfo.szCSDVersion
Case VER_PLATFORM_WIN32_WINDOWS
If rOsVersionInfo.dwMajorVersion >= 5 Then
sOperatingSystem = "Microsoft Windows ME"
ElseIf rOsVersionInfo.dwMajorVersion = 4 And rOsVersionInfo.dwMinorVersion > 0 Then
sOperatingSystem = "Microsoft Windows 98"
Else
sOperatingSystem = "Microsoft Windows 95"
End If
Case VER_PLATFORM_WIN32s
sOperatingSystem = "Win32s"
End Select
End If
IdentifyOperatingSystem = StripTerminator(sOperatingSyste
m) ' ,
Len(sOperatingSystem) - 2)
End Function
Private Function StripTerminator(sString As String) As String
StripTerminator = Left$(sString, InStr(sString, Chr$(0)) - 1) End Function
</CODE>
Reply
Answers (
0
)
How to write a C-sharp code to export slide, video or picture on projector using VGA DE-15 and/or DVI connection
Foreign Key constraints