From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,f890526de6a8a218 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news3.google.com!news2.volia.net!npeer.de.kpn-eurorings.net!newsfeed.arcor.de!news.arcor.de!not-for-mail Newsgroups: comp.lang.ada Subject: Re: How to detect OS type and version? From: Bernd.Specht@gmx.com (Bernd Specht) References: Organization: No company Message-ID: User-Agent: Xnews/4.05.03 Date: 13 Oct 2005 20:25:51 GMT NNTP-Posting-Date: 13 Oct 2005 22:25:51 MEST NNTP-Posting-Host: 565a55ff.newsread4.arcor-online.net X-Trace: DXC=REjNSU0?G`ca1IKbSTkC[i:ejgIfPPlddjW\KbG]kaMhea\9g\;7Nme<`_;9j0m09hWEh14DWb8Dhm]HkGKJ4]8hbDF2;<:^Pbc X-Complaints-To: abuse@arcor.de Xref: g2news1.google.com comp.lang.ada:5609 Date: 2005-10-13T22:25:51+02:00 List-Id: "Roger Blum" 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 ;-)