The following code example demonstrates how to retrieve the platform and version information of the current operating system. This information is stored in the
Example
В | ![]() |
---|---|
// os_ver.cpp // compile with: /clr using namespace System; int main() { OperatingSystem^ osv = Environment::OSVersion; PlatformID id = osv->Platform; Console::Write("Operating system: "); if (id == PlatformID::Win32NT) Console::WriteLine("Win32NT"); else if (id == PlatformID::Win32S) Console::WriteLine("Win32S"); else if (id == PlatformID::Win32Windows) Console::WriteLine("Win32Windows"); else Console::WriteLine("WinCE"); Version^ version = osv->Version; if (version) { int build = version->Build; int major = version->Major; int minor = version->Minor; int revision = Environment::Version->Revision; Console::Write("OS Version: "); Console::WriteLine("{0}.{1}.{2}.{3}", build, major, minor, revision); } return 0; } |