Click here to Skip to main content
15,891,248 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Working with Dll Pin
Suresh H12-Feb-07 22:45
Suresh H12-Feb-07 22:45 
QuestionAnybody with hyperthreading Pin
Waldermort12-Feb-07 13:37
Waldermort12-Feb-07 13:37 
AnswerRe: Anybody with hyperthreading Pin
Mark Salsbery12-Feb-07 13:59
Mark Salsbery12-Feb-07 13:59 
GeneralRe: Anybody with hyperthreading Pin
Waldermort12-Feb-07 14:15
Waldermort12-Feb-07 14:15 
AnswerRe: Anybody with hyperthreading Pin
Naveen12-Feb-07 16:31
Naveen12-Feb-07 16:31 
AnswerRe: Anybody with hyperthreading Pin
kakan12-Feb-07 19:21
professionalkakan12-Feb-07 19:21 
QuestionMSDN examples Pin
Waldermort12-Feb-07 12:16
Waldermort12-Feb-07 12:16 
AnswerRe: MSDN examples Pin
Mark Salsbery12-Feb-07 12:49
Mark Salsbery12-Feb-07 12:49 
Laugh | :laugh: I've never actually tried that code verbatim, but that article changes with every version
of Windows. I've always updated my code with every version release but by going through each
API carefully in the latest SDK.

The latest (PSDK 2003 Server R2) Requires #define _WIN32_WINNT 0x0501 to compile and the
latest SDK headers (plus it won't compile on Unicode build LOL)...
#include <windows.h>
#include <stdio.h>

#define BUFSIZE 80

int main()
{
   OSVERSIONINFOEX osvi;
   SYSTEM_INFO si;
   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)) )
   {
      osvi.dwOSVersionInfoSize = sizeof (OSVERSIONINFO);
      if (! GetVersionEx ( (OSVERSIONINFO *) &osvi) ) 
         return FALSE;
   }


   switch (osvi.dwPlatformId)
   {
      // Test for the Windows NT product family.

      case VER_PLATFORM_WIN32_NT:

      // Test for the specific product.

      if ( osvi.dwMajorVersion == 6 && osvi.dwMinorVersion == 0 )
      {
         if( osvi.wProductType == VER_NT_WORKSTATION )
             printf ("Microsoft Windows Vista ");
         else printf ("Windows Server \"Longhorn\" " );
      }

      if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 2 )
      {
         GetNativeSystemInfo(&si);

         if( GetSystemMetrics(SM_SERVERR2) )
            printf( "Microsoft Windows Server 2003 \"R2\" ");
         else if( si.wProcessorArchitecture==PROCESSOR_ARCHITECTURE_IA64 &&
                  osvi.wProductType == VER_NT_WORKSTATION )
         {
            printf( "Microsoft Windows XP Professional x64 Edition ");
         }
         else printf ("Microsoft Windows Server 2003, ");
      }

      if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 1 )
         printf ("Microsoft Windows XP ");

      if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 0 )
         printf ("Microsoft Windows 2000 ");

      if ( osvi.dwMajorVersion <= 4 )
         printf ("Microsoft Windows NT ");

      // Test for specific product on Windows NT 4.0 SP6 and later.
      if( bOsVersionInfoEx )
      {
         // Test for the workstation type.
         if ( osvi.wProductType == VER_NT_WORKSTATION )
         {
            if( osvi.dwMajorVersion == 4 )
               printf ( "Workstation 4.0 " );
            else if( osvi.wSuiteMask & VER_SUITE_PERSONAL )
               printf ( "Home Edition " );
            else printf ( "Professional " );
         }
            
         // Test for the server type.
         else if ( osvi.wProductType == VER_NT_SERVER || 
                   osvi.wProductType == VER_NT_DOMAIN_CONTROLLER )
         {
            if(osvi.dwMajorVersion==5 && osvi.dwMinorVersion==2)
            {
               if ( si.wProcessorArchitecture==PROCESSOR_ARCHITECTURE_IA64 )
               {
                   if( osvi.wSuiteMask & VER_SUITE_DATACENTER )
                      printf ( "Datacenter Edition for Itanium-based Systems" );
                   else if( osvi.wSuiteMask & VER_SUITE_ENTERPRISE )
                      printf ( "Enterprise Edition for Itanium-based Systems" );
               }

               else if ( si.wProcessorArchitecture==PROCESSOR_ARCHITECTURE_AMD64 )
               {
                   if( osvi.wSuiteMask & VER_SUITE_DATACENTER )
                      printf ( "Datacenter x64 Edition " );
                   else if( osvi.wSuiteMask & VER_SUITE_ENTERPRISE )
                      printf ( "Enterprise x64 Edition " );
                   else printf( "Standard x64 Edition " );
               }

               else
               {
                   if( osvi.wSuiteMask & VER_SUITE_DATACENTER )
                      printf ( "Datacenter Edition " );
                   else if( osvi.wSuiteMask & VER_SUITE_ENTERPRISE )
                      printf ( "Enterprise Edition " );
                   else if ( osvi.wSuiteMask == VER_SUITE_BLADE )
                      printf ( "Web Edition " );
                   else printf ( "Standard Edition " );
               }
            }
            else if(osvi.dwMajorVersion==5 && osvi.dwMinorVersion==0)
            {
               if( osvi.wSuiteMask & VER_SUITE_DATACENTER )
                  printf ( "Datacenter Server " );
               else if( osvi.wSuiteMask & VER_SUITE_ENTERPRISE )
                  printf ( "Advanced Server " );
               else printf ( "Server " );
            }
            else  // Windows NT 4.0 
            {
               if( osvi.wSuiteMask & VER_SUITE_ENTERPRISE )
                  printf ("Server 4.0, Enterprise Edition " );
               else printf ( "Server 4.0 " );
            }
         }
      }
      // Test for specific product on Windows NT 4.0 SP5 and earlier
      else  
      {
         HKEY hKey;
         char szProductType[BUFSIZE];
         DWORD dwBufLen=BUFSIZE;
         LONG lRet;

         lRet = RegOpenKeyEx( HKEY_LOCAL_MACHINE,
            "SYSTEM\\CurrentControlSet\\Control\\ProductOptions",
            0, KEY_QUERY_VALUE, &hKey );
         if( lRet != ERROR_SUCCESS )
            return FALSE;

         lRet = RegQueryValueEx( hKey, "ProductType", NULL, NULL,
            (LPBYTE) szProductType, &dwBufLen);
         RegCloseKey( hKey );

         if( (lRet != ERROR_SUCCESS) || (dwBufLen > BUFSIZE) )
            return FALSE;

         if ( lstrcmpi( "WINNT", szProductType) == 0 )
            printf( "Workstation " );
         if ( lstrcmpi( "LANMANNT", szProductType) == 0 )
            printf( "Server " );
         if ( lstrcmpi( "SERVERNT", szProductType) == 0 )
            printf( "Advanced Server " );
         printf( "%d.%d ", osvi.dwMajorVersion, osvi.dwMinorVersion );
      }

      // Display service pack (if any) and build number.

      if( osvi.dwMajorVersion == 4 && 
          lstrcmpi( osvi.szCSDVersion, "Service Pack 6" ) == 0 )
      { 
         HKEY hKey;
         LONG lRet;

         // Test for SP6 versus SP6a.
         lRet = RegOpenKeyEx( HKEY_LOCAL_MACHINE,
  "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Hotfix\\Q246009",
            0, KEY_QUERY_VALUE, &hKey );
         if( lRet == ERROR_SUCCESS )
            printf( "Service Pack 6a (Build %d)\n", 
            osvi.dwBuildNumber & 0xFFFF );         
         else // Windows NT 4.0 prior to SP6a
         {
            printf( "%s (Build %d)\n",
               osvi.szCSDVersion,
               osvi.dwBuildNumber & 0xFFFF);
         }

         RegCloseKey( hKey );
      }
      else // not Windows NT 4.0 
      {
         printf( "%s (Build %d)\n",
            osvi.szCSDVersion,
            osvi.dwBuildNumber & 0xFFFF);
      }

      break;

      // Test for the Windows Me/98/95.
      case VER_PLATFORM_WIN32_WINDOWS:

      if (osvi.dwMajorVersion == 4 && osvi.dwMinorVersion == 0)
      {
          printf ("Microsoft Windows 95 ");
          if (osvi.szCSDVersion[1]=='C' || osvi.szCSDVersion[1]=='B')
             printf("OSR2 " );
      } 

      if (osvi.dwMajorVersion == 4 && osvi.dwMinorVersion == 10)
      {
          printf ("Microsoft Windows 98 ");
          if ( osvi.szCSDVersion[1]=='A' || osvi.szCSDVersion[1]=='B')
             printf("SE " );
      } 

      if (osvi.dwMajorVersion == 4 && osvi.dwMinorVersion == 90)
      {
          printf ("Microsoft Windows Millennium Edition\n");
      } 
      break;

      case VER_PLATFORM_WIN32s:

      printf ("Microsoft Win32s\n");
      break;
   }
   return TRUE; 
}

GeneralRe: MSDN examples Pin
Waldermort12-Feb-07 13:35
Waldermort12-Feb-07 13:35 
GeneralRe: MSDN examples [modified] Pin
Anilkumar K V12-Feb-07 22:26
Anilkumar K V12-Feb-07 22:26 
QuestionOrphan process Pin
convivial.developer12-Feb-07 11:37
convivial.developer12-Feb-07 11:37 
AnswerRe: Orphan process Pin
Stephen Hewitt12-Feb-07 12:05
Stephen Hewitt12-Feb-07 12:05 
Questionare there any real time simulation program easier that opengl? Pin
Mir_As12-Feb-07 11:32
Mir_As12-Feb-07 11:32 
AnswerRe: are there any real time simulation program easier that opengl? Pin
El Corazon12-Feb-07 14:07
El Corazon12-Feb-07 14:07 
QuestionHow to get number of ports on a USB Root HUB device? Pin
Ingeer12-Feb-07 10:32
Ingeer12-Feb-07 10:32 
AnswerRe: How to get number of ports on a USB Root HUB device? Pin
cmk13-Feb-07 13:10
cmk13-Feb-07 13:10 
QuestionGetProcesses(); Help pls Pin
van-ux12-Feb-07 10:29
van-ux12-Feb-07 10:29 
AnswerRe: GetProcesses(); Help pls Pin
Mark Salsbery12-Feb-07 10:39
Mark Salsbery12-Feb-07 10:39 
GeneralRe: GetProcesses(); Help pls Pin
van-ux12-Feb-07 11:16
van-ux12-Feb-07 11:16 
GeneralRe: GetProcesses(); Help pls Pin
Ravi Bhavnani12-Feb-07 11:22
professionalRavi Bhavnani12-Feb-07 11:22 
GeneralRe: GetProcesses(); Help pls Pin
Mark Salsbery12-Feb-07 11:53
Mark Salsbery12-Feb-07 11:53 
GeneralRe: GetProcesses(); Help pls Pin
van-ux12-Feb-07 12:40
van-ux12-Feb-07 12:40 
GeneralRe: GetProcesses(); Help pls [modified] Pin
Mark Salsbery12-Feb-07 12:57
Mark Salsbery12-Feb-07 12:57 
GeneralRe: GetProcesses(); Help pls Pin
van-ux12-Feb-07 13:22
van-ux12-Feb-07 13:22 
GeneralRe: GetProcesses(); Help pls Pin
Mark Salsbery12-Feb-07 13:32
Mark Salsbery12-Feb-07 13:32 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.