Results 1 to 3 of 3

Thread: Vc++

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2001
    Posts
    2

    Vc++

    I need help with VC++, i know how to do alot in C++ well ever thing but classes, and a few other things..

    But i want to make a program in VC++ and for starters i want to out put what version of windows you are using.. windows 98, windows 95, etc..

    thank you very much

    Becker
    #include <geek.h>

  2. #2
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Well, if you can't use classes and the other things then it's not really C++ and you're closer to C. Anyway, VC++ is a product, not a language, and you don't have to have it to make windows programs - any compiler will do.

    When you compile a Console program, it still has access to the Win32 API - therefore, head off to msdn.microsoft.com/library and see what you find :) Look for the GetVersionEx function :)
    Code:
    #include <windows.h>
    #include <stdio.h>
    
    BOOL DisplaySystemVersion()
    {
       OSVERSIONINFOEX osvi;
       BOOL bOsVersionInfoEx;
    
       // Try calling GetVersionEx using the OSVERSIONINFOEX structure.
       //
       // If that fails, try using the OSVERSIONINFO structure.
    
       ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX));
       osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
    
       if( !(bOsVersionInfoEx = GetVersionEx ((OSVERSIONINFO *) &osvi)) )
       {
          // If OSVERSIONINFOEX doesn't work, try OSVERSIONINFO.
    
          osvi.dwOSVersionInfoSize = sizeof (OSVERSIONINFO);
          if (! GetVersionEx ( (OSVERSIONINFO *) &osvi) ) 
             return FALSE;
       }
    
       switch (osvi.dwPlatformId)
       {
          case VER_PLATFORM_WIN32_NT:
    
          // Test for the product.
    
             if ( osvi.dwMajorVersion <= 4 )
                printf("Microsoft Windows NT ");
    
             if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 0 )
                printf ("Microsoft Windows 2000 ");
    
             if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 1 )
                printf ("Whistler ");
    
          // Test for product type.
    
             if( bOsVersionInfoEx )
             {
                if ( osvi.wProductType == VER_NT_WORKSTATION )
                {
                   if( osvi.wSuiteMask & VER_SUITE_PERSONAL )
                      printf ( "Personal " );
                   else
                      printf ( "Professional " );
                }
    
                else if ( osvi.wProductType == VER_NT_SERVER )
                {
                   if( osvi.wSuiteMask & VER_SUITE_DATACENTER )
                      printf ( "DataCenter Server " );
                   else if( osvi.wSuiteMask & VER_SUITE_ENTERPRISE )
                      printf ( "Advanced Server " );
                   else
                      printf ( "Server " );
                }
             }
             else
             {
                HKEY hKey;
                char szProductType[80];
                DWORD dwBufLen;
    
                RegOpenKeyEx( HKEY_LOCAL_MACHINE,
                   "SYSTEM\\CurrentControlSet\\Control\\ProductOptions",
                   0, KEY_QUERY_VALUE, &hKey );
                RegQueryValueEx( hKey, "ProductType", NULL, NULL,
                   (LPBYTE) szProductType, &dwBufLen);
                RegCloseKey( hKey );
                if ( lstrcmpi( "WINNT", szProductType) == 0 )
                   printf( "Workstation " );
                if ( lstrcmpi( "SERVERNT", szProductType) == 0 )
                   printf( "Server " );
             }
    
          // Display version, service pack (if any), and build number.
    
             if ( osvi.dwMajorVersion <= 4 )
             {
                printf ("version %d.%d %s (Build %d)\n",
                   osvi.dwMajorVersion,
                   osvi.dwMinorVersion,
                   osvi.szCSDVersion,
                   osvi.dwBuildNumber & 0xFFFF);
             }
             else
             { 
                printf ("%s (Build %d)\n",
                   osvi.szCSDVersion,
                   osvi.dwBuildNumber & 0xFFFF);
             }
             break;
    
          case VER_PLATFORM_WIN32_WINDOWS:
    
             if (osvi.dwMajorVersion == 4 && osvi.dwMinorVersion == 0)
             {
                 printf ("Microsoft Windows 95 ");
                 if ( osvi.szCSDVersion[1] == 'C' )
                    printf("OSR2 " );
             } 
    
             if (osvi.dwMajorVersion == 4 && osvi.dwMinorVersion == 10)
             {
                 printf ("Microsoft Windows 98 ");
                 if ( osvi.szCSDVersion[1] == 'A' )
                    printf("SE " );
             } 
    
             if (osvi.dwMajorVersion == 4 && osvi.dwMinorVersion == 90)
             {
                 printf ("Microsoft Windows Me ");
             } 
             break;
    
          case VER_PLATFORM_WIN32s:
    
             printf ("Microsoft Win32s ");
             break;
       }
       return TRUE; 
    }
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  3. #3

    Thread Starter
    New Member
    Join Date
    Sep 2001
    Posts
    2

    Talking :)

    Thank you!

    Becker
    #include <geek.h>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width