How to detect if my app is running under Windows Vista

CA-Visual Objects developer system

Pedro
Is there any function to detect under which version of Windows is my
app running?
I need to find that out in order to disable a call a DLL that has
problem running under Vista.
TIA
Pedro                                            
Willie
Pedro,

Here is come code.

Regards,

Willie

CLASS OsVersion
 
 EXPORT sOsName        AS STRING 
 
 EXPORT dwMajorVersion     AS DWORD
 EXPORT dwMinorVersion     AS DWORD
 EXPORT dwBuildNumber      AS DWORD   
 EXPORT dwPlatformId      AS DWORD // Plattform ID (defines see VER_PLATFORM_WIN32)
 EXPORT DIM szCSDVersion[ 128 ]  AS BYTE  
 
 EXPORT wServicePackMajor   AS WORD
 EXPORT wServicePackMinor   AS WORD
 EXPORT wSuiteMask      AS WORD
 EXPORT wProductType     AS BYTE 

METHOD Init() CLASS OsVersion

 SELF:sOsName     := ""

 SELF:dwMajorVersion  := 0
 SELF:dwMinorVersion  := 0
 SELF:dwBuildNumber   := 0
 SELF:dwPlatformId    := 0
 
 SELF:wServicePackMajor := 0
 SELF:wServicePackMinor := 0
 SELF:wSuiteMask    := 0
 SELF:wProductType   := 0

 SELF:Refresh()
 
 RETURN SELF
METHOD Refresh() CLASS OsVersion
 LOCAL strWinOsVersionInfo  IS _WinOSVersionInfoEx
 LOCAL sMessage     AS STRING 
 
 strWinOsVersionInfo.dwOSVersionInfoSize := _SIZEOF( _WINOSVERSIONINFOEX ) 

 IF GetVersionEx( @strWinOsVersionInfo ) 
  // Get the Version Info's from the OS
  
  SELF:dwMajorVersion  := strWinOsVersionInfo.dwMajorVersion
  SELF:dwMinorVersion   := strWinOsVersionInfo.dwMinorVersion
  SELF:dwBuildNumber    := strWinOsVersionInfo.dwBuildNumber
  SELF:dwPlatformId      := strWinOsVersionInfo.dwPlatformId
  SELF:szCSDVersion      := strWinOsVersionInfo.szCSDVersion  
   
  SELF:wServicePackMajor := strWinOsVersionInfo.wServicePackMajor
  SELF:wServicePackMinor := strWinOsVersionInfo.wServicePackMinor
  SELF:wSuiteMask    := strWinOsVersionInfo.wSuiteMask
  SELF:wProductType   := strWinOsVersionInfo.wProductType 
 
  // 
  IF SELF:dwPlatformId == VER_PLATFORM_WIN32S
   sMessage := "Win32S  Version on Windows 3.1 "
   
  ELSEIF SELF:dwPlatformId == VER_PLATFORM_WIN32_WINDOWS
   
   IF SELF:dwMinorVersion == 0     
    sMessage := "Windows 95"
    
   ELSEIF SELF:dwMinorVersion == 10
   
    IF SELF:szCSDVersion == 65
     sMessage := "Windows 98 Second Edition"
     
    ELSE   
     sMessage := "Windows 98"
     
    ENDIF    
    
   ELSEIF SELF:dwMinorVersion == 90
    sMessage := "Windows ME"
  
   ENDIF
  
  ELSEIF SELF:dwPlatformId == VER_PLATFORM_WIN32_NT
   
   IF SELF:dwMajorVersion == 3   
    sMessage := "Windows NT 3.51" 
    
   ELSEIF SELF:dwMajorVersion == 4   
    sMessage := "Windows NT4"     
    
   ELSEIF SELF:dwMajorVersion == 5  .AND. SELF:dwMinorVersion == 0
    sMessage := "Windows 2000"  
    
   ELSEIF SELF:dwMajorVersion == 5  .AND. SELF:dwMinorVersion == 1       
    sMessage := "Windows XP"     
    
   ELSEIF SELF:dwMajorVersion == 5  .AND. SELF:dwMinorVersion == 2
    sMessage := "Windows Server 2003"
    
   ELSEIF SELF:dwMajorVersion == 6  .AND. SELF:dwMinorVersion == 0
    
    IF SELF:wProductType == VER_NT_WORKSTATION   
     sMessage := "Windows Vista"    
    ELSE
     sMessage := "Windows Server Longhorn"    
    ENDIF 
       
   ENDIF   
  
   
   //
   IF SELF:wProductType == VER_NT_WORKSTATION
    **    
    
    IF _AND( SELF:wSuiteMask, VER_SUITE_PERSONAL )  ==  VER_SUITE_PERSONAL
     sMessage += "     Home Edition"      
    ELSE
     sMessage += "     Professional" 
    ENDIF
   
   ELSEIF SELF:wProductType == VER_NT_SERVER
           **  bit flags

    IF _AND( SELF:wSuiteMask, VER_SUITE_DATACENTER )  == VER_SUITE_DATACENTER
     sMessage += "   DataCenter Server"
     
    ELSEIF _AND( SELF:wSuiteMask, VER_SUITE_ENTERPRISE ) == VER_SUITE_ENTERPRISE
     sMessage += "   Advanced Server"

    ELSEIF SELF:dwMinorVersion == 2 .AND. _AND( SELF:wSuiteMask, VER_SUITE_BLADE ) == VER_SUITE_BLADE       
     sMessage += "   Web Server"
     
    ELSE
     sMessage += "   Standard Server"  
     
    ENDIF

   ENDIF 
   
  ENDIF 
  
  // "Windows 2000   Version 5.0" 
  sMessage += "      Version:  " + NTrim(SELF:dwMajorVersion) + "." + NTrim(SELF:dwMinorVersion)
  
  //  
  sMessage +=  "      SP:  " + NTrim(SELF:wServicePackMajor) + "." + NTrim(SELF:wServicePackMinor)

  //
  sMessage += "      Build:  " + NTrim(SELF:dwBuildNumber)    
  

  // terminal services
  IF GetSystemMetrics( SM_REMOTECONTROL ) != 0
   sMessage += "       Terminal Services currently Running" 
  ENDIF
 
  // terminal services
  IF GetSystemMetrics( SM_REMOTESESSION ) != 0
   sMessage += "       App running on a Remote Session" 
  ENDIF     
  
  //   
  SELF:sOsName := sMessage
  
 ELSE
  SELF:dwMajorVersion  := 0
  SELF:dwMinorVersion  := 0
  SELF:dwBuildNumber  := 0
  SELF:dwPlatformId   := 0
  SELF:sOsName    := "Error in Geting Windows Version"
  
 ENDIF

 RETURN NIL
 STRUCT _WinOSVersionInfoEx
 MEMBER dwOSVersionInfoSize   AS DWORD
 MEMBER dwMajorVersion    AS DWORD
 MEMBER dwMinorVersion    AS DWORD
 MEMBER dwBuildNumber        AS DWORD
 MEMBER dwPlatformId      AS DWORD
 MEMBER DIM szCSDVersion[ 128 ]  AS BYTE

 // add EX members  
 MEMBER wServicePackMajor   AS WORD
 MEMBER wServicePackMinor   AS WORD
 MEMBER wSuiteMask      AS WORD
 MEMBER wProductType     AS BYTE
 MEMBER wReserved      AS BYTE
DEFINE VER_NT_WORKSTATION    := 1
DEFINE VER_NT_DOMAIN_CONTROLLER := 2
DEFINE VER_NT_SERVER       := 3

DEFINE VER_SUITE_SMALLBUSINESS  := 0x00000001
DEFINE VER_SUITE_ENTERPRISE   := 0x00000002
DEFINE VER_SUITE_TERMINAL    := 0x00000010
DEFINE VER_SUITE_DATACENTER   := 0x00000080
DEFINE VER_SUITE_PERSONAL    := 0x00000200
DEFINE VER_SUITE_BLADE     := 0x00000400

DEFINE SM_REMOTECONTROL    := 0x00002001
DEFINE SM_REMOTESESSION    := 0x00001000