コード例 #1
0
        public static void MyGetOsVersionExample()
        {
            OSVERSIONINFO_1 os1 = new OSVERSIONINFO_1();

            os1.dwOSVersionInfoSize = Marshal.SizeOf(os1);  //determines the unmanaged memory size
            os1.szCSDVersion        = new string(' ', 128); //only 127 chars are actually available, our string is far less

            if (GetVersionEx(ref os1))
            {
                Console.WriteLine("os1.szCSDVersion == '" + os1.szCSDVersion + "'");
            }

            OSVERSIONINFO_2 os2 = new OSVERSIONINFO_2();

            os2.dwOSVersionInfoSize = Marshal.SizeOf(os2);
            os2.szCSDVersion        = new char[128];

            if (GetVersionEx(ref os2))
            {
                string expectedResult = new string(os2.szCSDVersion).Trim('\0');
                Console.WriteLine("expected result == '" + expectedResult + "'");
            }
        }
コード例 #2
0
        public static void MyGetOsVersionExample()
        {
            OSVERSIONINFO_1 os1 = new OSVERSIONINFO_1();
            os1.dwOSVersionInfoSize = Marshal.SizeOf(os1); //determines the unmanaged memory size
            os1.szCSDVersion = new string(' ', 128); //only 127 chars are actually available, our string is far less

            if (GetVersionEx(ref os1))
            {
                Console.WriteLine("os1.szCSDVersion == '" + os1.szCSDVersion + "'");
            }

            OSVERSIONINFO_2 os2 = new OSVERSIONINFO_2();
            os2.dwOSVersionInfoSize = Marshal.SizeOf(os2);
            os2.szCSDVersion = new char[128];

            if (GetVersionEx(ref os2))
            {
                string expectedResult = new string(os2.szCSDVersion).Trim('\0');
                Console.WriteLine("expected result == '" + expectedResult + "'");
            }
        }
コード例 #3
0
 public static extern bool GetVersionEx(ref OSVERSIONINFO_2 lpVersionInfo);
コード例 #4
0
 public static extern bool GetVersionEx(ref OSVERSIONINFO_2 lpVersionInfo);