comp.lang.ada
 help / color / mirror / Atom feed
From: Bernd.Specht@gmx.com (Bernd Specht)
Subject: Re: How to detect OS type and version?
Date: 13 Oct 2005 20:25:51 GMT
Date: 2005-10-13T22:25:51+02:00	[thread overview]
Message-ID: <Xns96EEE42996281BerndSpechgmxcom@151.189.20.10> (raw)
In-Reply-To: BJj3f.711$QM5.65@tornado.socal.rr.com

"Roger Blum" <rogerblum@hawaii.rr.com> wrote in
news:BJj3f.711$QM5.65@tornado.socal.rr.com: 

> Is there a way within Ada (GNAT 3.15p) to tell whether the application
> is running on Linux or Windows (and the version of the OS)?
> 
> Regards,
> Roger 
> 
> 

Determination of the os is relative simple, the os version of a linux also. 
Windows is a bit more complicated.

Use "Text_IO" and try "Open" the file "/proc/sys/kernel/osrelease". On a 
Windows system, you will get an exception (Name_Error ?), on a Linux system 
you can read the file which contains the kernel version. You can use 
"/proc/sys/kernel/version" to get the build (release?) date.

If you cannot determine a linux system as described above, then try to open 
a file that is typically for windows (e.g. "c:\winnt\system32\command.com"). 
If you get _no_ exception, then you are on a windows system. To find the 
version, look for the file "prodspec.ini" (in c:\winnt\system32 and in c:
\system32). You can find the Window type (2000, XP) and the build number. 
But - not on all Windows systems :-( (Win98 do not have this file).

Hope this helps.


Regards,
Bernd

PS: Don't forget to close the files ;-)







  parent reply	other threads:[~2005-10-13 20:25 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-10-13  2:35 How to detect OS type and version? Roger Blum
2005-10-13  6:05 ` Martin Dowie
2005-10-13  9:50   ` Stefan Bellon
2005-10-13 10:39     ` Martin Dowie
2005-10-13 18:12     ` Jeffrey R. Carter
2005-10-13 18:37       ` Stefan Bellon
2005-10-13 21:21         ` Robert A Duff
2005-10-13 21:25           ` Stefan Bellon
2005-10-13 21:52             ` Robert A Duff
2005-10-16  0:13       ` Ray Blaak
2005-10-16  0:29         ` Robert A Duff
2005-10-16  4:48           ` Ray Blaak
2005-10-16 14:16             ` Larry Kilgallen
2005-10-16 15:55               ` Robert A Duff
2005-10-16 20:06               ` Pascal Obry
2005-10-18 16:58                 ` Ray Blaak
2005-10-16 15:59             ` Robert A Duff
2005-10-17 17:19               ` Ray Blaak
2005-10-13 18:11   ` Jeffrey R. Carter
2005-10-13 19:44   ` Simon Wright
2005-10-13 21:04   ` Michael Bode
2005-10-14  1:33     ` Steve
2005-10-13 12:06 ` Rob Norris
2005-10-13 11:59   ` Martin Dowie
2005-10-14  0:21     ` Randy Brukardt
2005-10-14  8:02       ` Martin Dowie
2005-10-14 23:27         ` Randy Brukardt
2005-10-15 12:28           ` Larry Kilgallen
2005-10-15 14:12             ` Martin Dowie
2005-10-14  9:52     ` Rob Norris
2005-10-13 20:25 ` Bernd Specht [this message]
2005-10-13 20:36   ` Michael Bode
2005-10-13 20:41     ` Bernd Specht
2005-10-13 20:58       ` Stefan Bellon
2005-10-14  0:27         ` Randy Brukardt
2005-10-15 19:48           ` Bernd Specht
2005-10-14  6:30 ` Roger Blum
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox