Solved

knowing what kind of windows used

Posted on 2002-03-08
11
184 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
Comment Utility
help me please
0
 
LVL 11

Expert Comment

by:robert_marquardt
Comment Utility
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
Comment Utility
listening
0
 
LVL 17

Expert Comment

by:Wim ten Brink
Comment Utility
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
Comment Utility
Can i have a complete code for this problem?
0
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
LVL 6

Accepted Solution

by:
Stuart_Johnson earned 50 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
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…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

762 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

11 Experts available now in Live!

Get 1:1 Help Now