Solved

how can i identify if what kind of operating system am i using?

Posted on 2002-03-10
21
209 Views
Last Modified: 2010-04-05
PLEASE GIVE ME A COMPLETE SOURCE CODE FOR IT.
NOT A SUGGESTED LINK OR OTHERS

that will identify which kind of O.S.
Windows95,windows98,windows2000,windowsNT,windowsXP,
windows ME,windows98 SE
etc. all kinds of Microsoft operating system software...

0
Comment
Question by:ryan_sabarre
  • 7
  • 5
  • 5
  • +3
21 Comments
 

Author Comment

by:ryan_sabarre
ID: 6855243
help me please
0
 
LVL 4

Expert Comment

by:StevenB
ID: 6855273
Use GetVersionEx thus:

var
  VersionInfo: TOSVersionInfo;
begin
  VersionInfo.dwOSVersionInfoSize := SizeOf(VersionInfo);
  GetVersionEx(VersionInfo);
end;
0
 
LVL 4

Expert Comment

by:StevenB
ID: 6855283
Then from the Win SDK Help you can query the TOSVersionInfo result:




The OSVERSIONINFO data structure contains operating system version information. The information includes major and minor version numbers, a build number, a platform identifier, and descriptive text about the operating system. This structure is used with the GetVersionEx function.

typedef struct _OSVERSIONINFO{  
    DWORD dwOSVersionInfoSize;
    DWORD dwMajorVersion;
    DWORD dwMinorVersion;
    DWORD dwBuildNumber;
    DWORD dwPlatformId;
    TCHAR szCSDVersion[ 128 ];
} OSVERSIONINFO;
 

Members

dwOSVersionInfoSize

Specifies the size, in bytes, of this data structure. Set this member to sizeof(OSVERSIONINFO) before calling the GetVersionEx function.

dwMajorVersion

Identifies the major version number of the operating system. For example, for Windows NT version 3.51, the major version number is 3; and for Windows NT version 4.0, the major version number is 4.

dwMinorVersion

Identifies the minor version number of the operating system. For example, for Windows NT version 3.51, the minor version number is 51; and for Windows NT version 4.0, the minor version number is 0.

dwBuildNumber

Windows NT: Identifies the build number of the operating system.
Windows 95: Identifies the build number of the operating system in the low-order word. The high-order word contains the major and minor version numbers.

dwPlatformId

Identifies the operating system platform. This member can be one of the following values:

Value     Platform
VER_PLATFORM_WIN32s     Win32s on Windows 3.1.
VER_PLATFORM_WIN32_WINDOWS     Win32 on Windows 95.
VER_PLATFORM_WIN32_NT     Win32 on Windows NT.
 

szCSDVersion

Windows NT: Contains a null-terminated string, such as "Service Pack 3", that indicates the latest Service Pack installed on the system. If no Service Pack has been installed, the string is empty.
Windows 95: Contains a null-terminated string that provides arbitrary additional information about the operating system.
0
 

Author Comment

by:ryan_sabarre
ID: 6855325
anybody can give me like this one

....
function getsystemType:string;
...
..
..
begin
 showmessage(getsystemtype);
 {return "windowsXP"}
end;
0
 

Author Comment

by:ryan_sabarre
ID: 6855345
PLEASE includet the windowsXP and the windows 2000 or all kinds of windows OS running.
0
 
LVL 6

Expert Comment

by:Stuart_Johnson
ID: 6855367
What Stephen_B provided you will do this.  It just needs to you do a bit of coding.  Or do you want the whole thing coded for you?
0
 
LVL 6

Expert Comment

by:Stuart_Johnson
ID: 6855384
function GetSystemType: String;
var
  verInfo : TOSVERSIONINFO;
begin
  verInfo.dwOSVersionInfoSize := SizeOf(TOSVersionInfo);
  if GetVersionEx(verInfo) then begin
    Result:= IntToStr(verInfo.dwMajorVersion) + '.' +
      IntToStr(verInfo.dwMinorVersion) + '.' +
      IntToStr(verInfo.dwBuildNumber);

    case verInfo.dwPlatformId of
      VER_PLATFORM_WIN32s         : Result:= Result + '  Win16 running Win32s';
      VER_PLATFORM_WIN32_WINDOWS  : Result := Result + '  Win32 Windows (95, 98, ME)';
      VER_PLATFORM_WIN32_NT       : Result := Result + '  WinNT/2000, full 32-bit';
    end;
end;

Windows XP will be detected as NT/2000.  I don't have XP (or plan to get it), so I don't know how you can tell the difference between NT/2000/XP.

To work out what windows 9x version you're using, use :
if (dwMajorVersion = 3 and dwMinorVersion = 95) then Windows=95
if (dwMajorVersion = 3) and dwMinorVersion = 98) then Windows=98

Don't know about ME either because we don't use it at work.

I'm also not sure how you detect if you're running 2000 Pro/Server/Advanced Server other than looking in the registry.  Same goes with XP.  You'll need to do a bit of extra research.

All of ths was done in about 2 minutes using the code Stephen_B posted.
0
 
LVL 6

Expert Comment

by:Stuart_Johnson
ID: 6855388
FYI.  I would GUESS that XP will be detected as dwMajorVersion = 5, as NT 4.0 detects as 4.  But that's just a guess.
0
 
LVL 4

Expert Comment

by:StevenB
ID: 6855399
Ryan, just found this:

http://www.experts-exchange.com/jsp/qShow.jsp?ta=delphi&qid=20274797

What was wrong with the answers provided there previously?
0
 

Author Comment

by:ryan_sabarre
ID: 6855409
i already do that coding but its not specifying what kind of OS is running
you can say

VER_PLATFORM_WIN32s         : Result:= Result + '  Win16 running Win32s';
VER_PLATFORM_WIN32_WINDOWS  : Result := Result + '  Win32 Windows (95, 98, ME)';
VER_PLATFORM_WIN32_NT       : Result := Result + '  WinNT/2000, full 32-bit';


what if i want to know if that is a windows 95 not windows 98 is running? or a windowsME not a windows98 is running or
a windowsNT not a Windows 2000 is running
0
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 

Author Comment

by:ryan_sabarre
ID: 6855423
StevenB, right you supplied some ideas but its not the i really need. i need some complete source code.

hope everybody here understand what i mean.

Ryan.
0
 
LVL 4

Expert Comment

by:StevenB
ID: 6855428
To be honest I'm not sure how to make it more complete. If you want a string value returned from the function, use the one supplied by Stuart, but add an extra "end;" in there :o)


function GetSystemType: String;
var
 verInfo : TOSVERSIONINFO;
begin
 verInfo.dwOSVersionInfoSize := SizeOf(TOSVersionInfo);
 if GetVersionEx(verInfo) then begin
   Result:= IntToStr(verInfo.dwMajorVersion) + '.' +
     IntToStr(verInfo.dwMinorVersion) + '.' +
     IntToStr(verInfo.dwBuildNumber);

   case verInfo.dwPlatformId of
     VER_PLATFORM_WIN32s         : Result:= Result + '  Win16 running Win32s';
     VER_PLATFORM_WIN32_WINDOWS  : Result := Result + '  Win32 Windows (95, 98, ME)';
     VER_PLATFORM_WIN32_NT       : Result := Result + '  WinNT/2000, full 32-bit';
   end;
 end;  
end;
0
 
LVL 6

Expert Comment

by:Stuart_Johnson
ID: 6855445
Ryan,

As Stephen has just pointed out, you have another question with exactly the same question.  You need to delete one of these questions, other wise you'll have to award the points to two different people of an exact answer.

In your other question, robert_marquardt provided a link to some components which would solve your problem.  On top of that, other people have supplied you with code.  You have not told anyone (in either question) if anything they've done is usefull except "please give me complete source".

Did you check the link that robert_marquardt provided too you?  Maybe there is something perfect for your needs there.

Stu.
0
 
LVL 4

Expert Comment

by:StevenB
ID: 6855467
>>what if i want to know if that is a windows 95 not
>>windows 98 is running? or a windowsME not a windows98
>>is running or
>>a windowsNT not a Windows 2000 is running


You'll heve to deduce that from the Version Numbers, I'm not sure what they are, but I can tell you that my Win2000 machine returns

dwPlatformId = VER_PLATFORM_WIN32_NT
dwMajorVersion = 5
dwMinorVersion = 0
dwBuildNumber = 2195

The dwPlatformId, dwMajorVersion, dwMinorVersion and dwBuildNumber should be enough to deduce the information that you need, but you'll have to work out the results on all the platforms. Some likely values are:

Windows95
  dwPlatformId = VER_PLATFORM_WIN32_WINDOWS  
  dwMajorVersion = 3
  dwMinorVersion = 95
Windows98
  dwPlatformId = VER_PLATFORM_WIN32_WINDOWS  
  dwMajorVersion = 3
  dwMinorVersion = 98
  dwBuildNumber = ??
Windows98 SE
  dwPlatformId = VER_PLATFORM_WIN32_WINDOWS  
  dwMajorVersion = ??
  dwMinorVersion = ??
  dwBuildNumber = ??
Windows ME
  dwPlatformId = VER_PLATFORM_WIN32_WINDOWS  
  dwMajorVersion = ??
  dwMinorVersion = ??
  dwBuildNumber = ??
WindowsNT
  dwPlatformId = VER_PLATFORM_WIN32_NT
  dwMajorVersion = 3 or 4
  dwMinorVersion = ??
Windows2000
  dwPlatformId = VER_PLATFORM_WIN32_NT
  dwMajorVersion = 5
  dwMinorVersion = 0
WindowsXP
  dwPlatformId = VER_PLATFORM_WIN32_NT
  dwMajorVersion = ??
  dwMinorVersion = ??
0
 
LVL 6

Expert Comment

by:Stuart_Johnson
ID: 6855478
function GetSystemType: Integer;
const
  { operating system constants }
  cOsUnknown = -1;
  cOsWin95 = 0;
  cOsWin98 = 1;
  cOsWin98SE = 2;
  cOsWinME = 3;
  cOsWinNT = 4;
  cOsWin2000 = 5;
  cOsWinXP = 6;

var
  osVerInfo : TOSVersionInfo;
  majorVer, minorVer : Integer;

begin
  result := cOsUnknown;
{ set operating system type flag }
  osVerInfo.dwOSVersionInfoSize := SizeOf(TOSVersionInfo);
  if GetVersionEx(osVerInfo) then
    begin
      majorVer := osVerInfo.dwMajorVersion;
      minorVer := osVerInfo.dwMinorVersion;
      case osVerInfo.dwPlatformId of
        VER_PLATFORM_WIN32_NT : { Windows NT/2000 }
          begin
            if majorVer <= 4 then
              result := cOsWinNT
            else
              if (majorVer = 5) AND (minorVer= 0) then
                result := cOsWin2000
              else
                if (majorVer = 5) AND (minorVer = 1) then
                  result := cOsWinXP
            else
            result := cOsUnknown;
          end; {case }
      VER_PLATFORM_WIN32_WINDOWS : { Windows 9x/ME }
        begin
          if (majorVer = 4) AND (minorVer = 0) then
            result := cOsWin95
          else
            if (majorVer = 4) AND (minorVer = 10) then
              begin
                if osVerInfo.szCSDVersion[1] = 'A' then
                  result := cOsWin98SE
                else
                   result := cOsWin98;
                end {if Version = 'A'}
              else
                if (majorVer = 4) AND (minorVer = 90) then
                  result := cOsWinME
                else
                   result := cOsUnknown;
        end; {case VER_PLATFORM_WIN32_WINDOWS}
      else
       result := cOsUnknown;
    end;
  end
else
   result := cOsUnknown;
end;



procedure TForm1.Button1Click(Sender: TObject);
const
  OSTypes: Array[-1..6] of String = ('Unknown','Windows 95','Windows 98',
    'Windows 98 SE','Windows ME','Windows NT 4.0','Windows 2000','Windows XP');

begin
  Showmessage('You are running '+OSTypes[GetSystemType]);
end;
0
 
LVL 8

Expert Comment

by:TOndrej
ID: 6856042
The most complete routine I know of is in the JCL (JEDI Code Library), get it from http://www.delphi-jedi.org/

Have a look at JclSysInfo unit, functions:

function GetWindowsVersion: TWindowsVersion;
function NtProductType: TNtProductType;
function GetWindowsVersionString: string;

and more...

HTH
TOndrej
0
 
LVL 9

Expert Comment

by:ginsonic
ID: 6856398
listening
0
 
LVL 6

Expert Comment

by:Stuart_Johnson
ID: 6856565
Any news, Ryan?
0
 
LVL 1

Expert Comment

by:Moondancer
ID: 6939291
ADMINISTRATION WILL BE CONTACTING YOU SHORTLY.  Moderators Computer101 or Netminder will return to finalize these if still open in seven days.  Please post closing recommendations before that time.

Question(s) below appears to have been abandoned. Your options are:
 
1. Accept a Comment As Answer (use the button next to the Expert's name).
2. Close the question if the information was not useful to you, but may help others. You must tell the participants why you wish to do this, and allow for Expert response.  This choice will include a refund to you, and will move this question to our PAQ (Previously Asked Question) database.  If you found information outside this question thread, please add it.
3. Ask Community Support to help split points between participating experts, or just comment here with details and we'll respond with the process.
4. Delete the question (if it has no potential value for others).
   --> Post comments for expert of your intention to delete and why
   --> YOU CANNOT DELETE A QUESTION with comments; special handling by a Moderator is required.

For special handling needs, please post a zero point question in the link below and include the URL (question QID/link) that it regards with details.
http://www.experts-exchange.com/jsp/qList.jsp?ta=commspt
 
Please click this link for Help Desk, Guidelines/Member Agreement and the Question/Answer process.  http://www.experts-exchange.com/jsp/cmtyHelpDesk.jsp

Click you Member Profile to view your question history and keep them updated as the collaboration effort continues, to maintain your open and locked questions.  If you are a  KnowledgePro user, use the Power Search option to find them.  Anytime you have questions which are LOCKED with a Proposed Answer which does not serve your needs, please reject it and add comments as to why.  In addition, when you do grade the question, if the grade is less than an A, please add a comment as to why.  This helps all involved, as well as future persons who may access this item for help.

To view your open questions, please click the following link(s) and keep them all current with updates.
http://www.experts-exchange.com/questions/Q.20132001.html
http://www.experts-exchange.com/questions/Q.20179430.html
http://www.experts-exchange.com/questions/Q.20275585.html




**** PLEASE DO NOT AWARD THE POINTS TO ME. *****
 
------------>  EXPERTS:  Please leave your closing recommendations if this item remains inactive another seven (7) days.  If you are interested in the cleanup effort, please click this link http://www.experts-exchange.com/jsp/qManageQuestion.jsp?ta=commspt&qid=20274643
POINTS FOR EXPERTS awaiting comments are listed here -> http://www.experts-exchange.com/commspt/Q.20277028.html
 

Moderators will finalize this question if still open in @7 days, by either moving this to the PAQ (Previously Asked Questions) at zero points, deleting it or awarding expert(s) when recommendations are made, or an independent determination can be made.  Expert input is always appreciated to determine the fair outcome.
 
Thank you everyone.
 
Moondancer
Moderator @ Experts Exchange
0
 
LVL 6

Accepted Solution

by:
Stuart_Johnson earned 50 total points
ID: 6943336
I'm locking this question as the code I posted on 03/10/2002 06:40PM has been the only code posted which returns everything Ryan was looking for.  If anyone thinks this is unfair can they let it be known so Ryan can cancel my proposal.

Stu
0
 
LVL 1

Expert Comment

by:Moondancer
ID: 6948469
No disputes ensued, finalized today.  In the event Asker returns with additional requests related here, please respond.
Thanks,
Moondancer - EE Moderator
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

708 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now