Solved

knowing what kind of windows used

Posted on 2002-03-08
11
187 Views
Last Modified: 2010-04-05
how can i identify if what kind of operating system am i using?

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
  • 3
  • 3
  • 2
  • +3
11 Comments
 

Author Comment

by:ryan_sabarre
ID: 6849888
help me please
0
 
LVL 11

Expert Comment

by:robert_marquardt
ID: 6849901
There are several components/units out there which solve the problem.
Have a look at http://delphi-jedi.org/CODELIBJCL for example.
The Jedi Code Librarycontains the function you need.

(and please be more patient. after 15 minutes not many experts have read your question).
0
 
LVL 9

Expert Comment

by:ginsonic
ID: 6850231
listening
0
 
LVL 17

Expert Comment

by:Wim ten Brink
ID: 6850265
Use the Windows API GetSystemInfo for this.
<Quote>
The GetSystemInfo function returns information about the current system.

VOID GetSystemInfo(
    LPSYSTEM_INFO lpSystemInfo      // address of system information structure  
   );

Parameters:
* lpSystemInfo - Points to a SYSTEM_INFO structure to be filled in by this function.
Return Values: This function does not return a value.

See Also SYSTEM_INFO
</Quote>

Which just means in Delphi:
var SystemInfo: TSystemInfo;
begin
  GetSystemInfo(SystemInfo);
  // Do something with the SystemInfo variable.
end;

The SystemInfo variable in this case will identify the type of processor. Now you also want the Windows version. That's an easy one too. Use the Windows API GetVersionEx function:
<Quote>
The GetVersionEx function obtains extended information about the version of the operating system that is currently running.

BOOL GetVersionEx(
    LPOSVERSIONINFO lpVersionInformation      // pointer to version information structure
   );    

Parameters:
* lpVersionInformation - Pointer to an OSVERSIONINFO data structure that the function fills with operating system version information. Before calling the GetVersionEx function, set the dwOSVersionInfoSize member of the OSVERSIONINFO data structure to sizeof(OSVERSIONINFO).

Return Values:
If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero. To get extended error information, call GetLastError. The function fails if you specify an invalid value for the dwOSVersionInfoSize member of the OSVERSIONINFO structure.

Remarks:
The GetVersionEx function supersedes the GetVersion function and is the preferred method for obtaining operating system version number information. New applications should use the GetVersionEx function rather than the GetVersion function.

See Also OSVERSIONINFO
</Quote>

This you use as follows:
var VersionInfo: TOSVersionInfo;
begin
  VersionInfo.dwOSVersionInfoSize := SizeOf(TOSVersionInfo);
  if GetVersionEx(VersionInfo) then begin
    // Examine version info.
  end;
end;

This structure should provide you all the information you need about the OS.
0
 

Author Comment

by:ryan_sabarre
ID: 6855186
Can i have a complete code for this problem?
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 6

Accepted Solution

by:
Stuart_Johnson earned 50 total points
ID: 6855479
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
 

Expert Comment

by:nclong
ID: 6875961
Pls. try the code below :-

function GetWinVersion: String;
var
VerInfo: TOSVersionInfo;
ResultStr: string;
begin
ResultStr := '';
VerInfo.dwOSVersionInfoSize := SizeOf(VerInfo);
GetVersionEx(VerInfo);
with VerInfo do
 begin
   case dwPlatformID of
     VER_PLATFORM_WIN32S: ResultStr := ResultStr + 'Windows 3.1x running Win32s ';
     VER_PLATFORM_WIN32_WINDOWS:
       begin
         if IntToStr(dwMajorVersion) + '.' + IntToStr(dwMinorVersion) < '4.10' then
           ResultStr := ResultStr + 'Windows 95 ' + szCSDVersion + ' '
         else
           ResultStr := ResultStr + 'Windows 98 ' + szCSDVersion + ' ';
       end;
     VER_PLATFORM_WIN32_NT:
       begin
         if dwMajorVersion = 5 then
           ResultStr := ResultStr + 'Windows 2000 '
         else
           ResultStr := ResultStr + 'Windows NT ';
       end;
   end;
   ResultStr := ResultStr + IntToStr(dwMajorVersion) + '.' + IntToStr(dwMinorVersion) + ' ';
   ResultStr := ResultStr + '(Build ' +  IntToStr(LoWord(dwBuildNumber)) + ') ';
   if dwPlatformID = VER_PLATFORM_WIN32_NT then
     ResultStr := ResultStr + szCSDVersion;
 end;
Result := ResultStr;
end;


procedure TForm1.Button1Click(Sender: TObject);
begin
ShowMessage(GetWinVersion);
end;
0
 
LVL 6

Expert Comment

by:Stuart_Johnson
ID: 6876002
nclong,

You're not showing the different OS's as requested (95/98/ME/NT/2000/XP).

Stu.
0
 
LVL 6

Expert Comment

by:Stuart_Johnson
ID: 6876006
ryan_sabarre,

This question has been open for 10 days without any comment from you.  You were very quick to ask for help when none was supplied in 13 minutes, but now a working solution has been posted, you've become very quite.

Can you please provide some feed back to the people who have spent their time solving the problem for you, and either accept a comment as an answer, or request more details to further assist you in your problem.

I will lock this question with an answer in two days if I don't here from you (to prevent the autograder kicking in).

Thank-you,

Stuart.
0
 
LVL 11

Expert Comment

by:robert_marquardt
ID: 6876012
The Jedi Code Library is still out there. It even detects Windows ME when posing as Windows 98 to programs named Setup.exe
0
 

Author Comment

by:ryan_sabarre
ID: 6887990
sorry and im very sorry if ever i did not grade anyone of you there!!, and its been long also i havent hold my computer, coz it was infected with win.cih and fun-love virus. the problem i have is already solved. i found a component that can identify if what kind of OS is running.
this will return the exact "words" or "letters" as spelled -[windows 98]-[windows XP] etc.

your answer Stuart Johnson is Good it also detect the kind of OS in my computer. im very thankfull.

Sorry all of you if i did not responds right away.

sorry.
Ryan.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
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…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

912 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

17 Experts available now in Live!

Get 1:1 Help Now