Get your OS Version

enum   Win32Type{  
  Win32s,  
  WinNT3,  
  Win95,  
  Win98,  
  WinME,  
  WinNT4,  
  Win2000,  
  WinXP  
  };  
   
  Win32Type   IsShellType()  
  {  
   Win32Type     ShellType;  
   DWORD   winVer;  
   OSVERSIONINFO   *osvi;  
   
   winVer=GetVersion();
  dwMajorVersion=(DWORD)(LOBYTE(LOWORD(winVer)));
  dwMinorVersion=(DWORD)(HIBYTE(LOWORD)(winVer))); 
   if(winVer<0x80000000){/*NT   */  
     ShellType=WinNT3;  
     osvi=   (OSVERSIONINFO   *)malloc(sizeof(OSVERSIONINFO));  
      if   (osvi!=NULL){  
    memset(osvi,0,sizeof(OSVERSIONINFO));  
    osvi->dwOSVersionInfoSize=sizeof(OSVERSIONINFO);  
    GetVersionEx(osvi);  
    if(osvi->dwMajorVersion==4L)ShellType=WinNT4;  
    else   if(osvi->dwMajorVersion==5L&&osvi->dwMinorVersion==0L)ShellType=Win2000; //version 5.0 
    else   if(osvi->dwMajorVersion==5L&&osvi->dwMinorVersion==1L)ShellType=WinXP;   //version 5.1
    free(osvi);  
      }  
         }  
   else if (LOBYTE(LOWORD(winVer))<4)  
    ShellType=Win32s;  
   else{  
    ShellType=Win95;  
    osvi=   (OSVERSIONINFO   *)malloc(sizeof(OSVERSIONINFO));  
    if   (osvi!=NULL){  
     memset(osvi,0,sizeof(OSVERSIONINFO));  
     osvi->dwOSVersionInfoSize=sizeof(OSVERSIONINFO);  
    GetVersionEx(osvi);  
     if(osvi->dwMajorVersion==4L&&osvi->dwMinorVersion==10L)ShellType=Win98;  
     else   if(osvi->dwMajorVersion==4L&&osvi->dwMinorVersion==90L)ShellType=WinME;  
     free(osvi);  
    }  
  }  
   return   ShellType;  
  }


VC6.0 Windows XP SP2 运行正常