Solved

Windows Serial Number?

Posted on 2001-06-19
8
328 Views
Last Modified: 2010-05-02
I'm trying to find a way of getting the operating systems serial number, be it Win9x, Millenium, 2000, NT4 etc. I know I can get it from the registry, but I'd rather get it from someplace non-editable. Is this possible?
0
Comment
Question by:Dhag
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 18

Expert Comment

by:deighton
ID: 6207307
Option Explicit

Type OSVERSIONINFO
  dwOSVersionInfoSize As Long
  dwMajorVersion As Long
  dwMinorVersion As Long
  dwBuildNumber As Long
  dwPlatformId As Long
  szCSDVersion As String * 128
End Type


Declare Function GetVersionEx Lib "kernel32.dll" Alias "GetVersionExA" (lpVersionInformation As OSVERSIONINFO) As Long

Public Sub versionstuff()



' Display the major and minor version numbers of Windows.
' For example, 4.0 could represent Windows 95.
Dim os As OSVERSIONINFO  ' receives version information
Dim retval As Long  ' return value

os.dwOSVersionInfoSize = Len(os)  ' set the size of the structure
retval = GetVersionEx(os)  ' read Windows's version information
Debug.Print "Windows version number:"; os.dwPlatformId, os.dwMajorVersion; "."; os.dwMinorVersion

End Sub





'some details

OSVERSIONINFO-type variables hold information about the version of Windows currently running. This structure holds various pieces of information identifying the version number, platform, and more about Windows.

dwOSVersionInfoSize
The size of the structure.
dwMajorVersion
The major version number; i.e., the part of the version number before the first period.
dwMinorVersion
The minor version number; i.e., the part of the version number after the first period.
dwBuildNumber
The build number of the version.
dwPlatformID
Exactly one of the following flags identifying which platform of Windows is running (for example, Windows 95, Windows NT, etc.):
VER_PLATFORM_WIN32s = 0
Windows 3.x is running, using the Win32s pseudo-32-bit enhancements.
VER_PLATFORM_WIN32_WINDOWS = 1
Windows 95 or 98 is running.
VER_PLATFORM_WIN32_NT = 2
Windows NT is running.
szCSDVersion
More information about the operating system.
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 6207474
yes, it is possible but, unfortunately, diferent version save the serial on diferent place.
You need some api stuff to read registry entries and locate some keys under \software\microsoft\windows\currentversion\productid
0
 
LVL 5

Accepted Solution

by:
gbaren earned 50 total points
ID: 6207594
I don't think the serial number exists anywhere but the registry. Here's a function to get it:

You need to set a reference to Windows Script Host Object Model.

Function GetWindowsID() as string
Dim oShell As IWshShell

   Set oShell = New IWshShell_Class
   
   GetWindowsID = oShell.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\ProductId")

End Function


 
0
MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 6208381
Yeah!
Gbaren post in code what i said in simply words. Nice job.
;)
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 7139525
Hi Dhag,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will suggest to:

    Split points between: Richie_Simonetti and gbaren

Dhag, if you think your question was not answered at all or if you need help, you can simply post a new comment here.  Community Support moderators will follow up.

EXPERTS: If you disagree with that recommendation, please post an explanatory comment.
==========
DanRollins -- EE database cleanup volunteer
0
 

Author Comment

by:Dhag
ID: 7143262
I'd like to split the points between the two, but don't know how to do that :(
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 7144297
Hi Dhag,
Thanks for responding.  An EE Moderator will split the points for you when she pases through here in about a week.  -- Dan
0
 
LVL 5

Expert Comment

by:Netminder
ID: 7181561
Per recommendation, force-accepted.

Netminder
CS Moderator

Richie_Simonetti: points for you at http://www.experts-exchange.com/jsp/qShow.jsp?ta=visualbasic&qid=20328617
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses
Course of the Month10 days, 15 hours left to enroll

628 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question