[Mono-list] How can the assembly check the OS it's on?
Tue, 11 Mar 2003 16:02:06 +1100
On 07-Mar-2003, Charles-Louis <email@example.com> wrote:
> I was wondering if it was possible for an assembly to now on which OS it
> is running?
In general it's much better to write your application so that it tests
for features, rather than testing the OS type. code which tests the OS type
is generally harder to port to new systems.
> eg. if I'm running on windows, I'll use the Windows System logs, and if
> I'm on Linux, i'll use the Linux logs...
What will you do on Windows 2030, when Windows is running a Linux kernel
and supports the Unix syslog interface? ;-)
If you think that's far-fetched, consider MacOS X!
Probably it's best to just try each method in turn. If none of the
above methods work, you can resort to some fall-back such as printing
to stderr and/or logging the messages to your own log file.
Fergus Henderson <firstname.lastname@example.org> | "I have always known that the pursuit
The University of Melbourne | of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh> | -- the last words of T. S. Garp.