Announcement

Collapse
No announcement yet.

WIn Vista IsOS function

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • WIn Vista IsOS function

    Can someone with 64bit windows test to see if 30 or %OS_WOW6432 returns true.
    This Function should work long as shlwapi.dll is 5.0 or greater

    Code:
    'http://msdn.microsoft.com/en-us/library/bb773795(VS.85).aspx
    'http://vbnet.mvps.org/index.html?code/helpers/isos.htm
    'IsOS Function
    'Checks for specified operating systems and operating system features.
    'Minimum DLL Version shlwapi.dll version 5.0 or later
    'BOOL IsOS(DWORD dwOS);
    'Values are 0 - 37
    'Name                   Value   Description
    %OS_WINDOWS             = 0     'The program is not running on Microsoft Windows NT or one of its successors.
    %OS_NT                  = 1     'The program is running on Windows NT or one of its successors.
    %OS_WIN95ORGREATER      = 2     'The program is running on Windows 95 or one of its successors.
    %OS_NT4ORGREATER        = 3     'The program is running on Windows NT 4.0 or one of its successors.
    %OS_WIN2000ORGREATER_ALT = 4    'This value is obsolete.
                                    'Use OS_WIN2000ORGREATER instead.
    %OS_WIN98ORGREATER      = 5     'The program is running on Windows 98 or one of its successors.
    %OS_WIN98_GOLD          = 6     'The program is running on Windows 98 exactly.
    %OS_WIN2000ORGREATER    = 7    'The program is running on Windows 2000 or one of its successors.
    %OS_WIN2000PRO          = 8     'The program is running on Windows 2000 Professional or Windows XP Professional.
    %OS_WIN2000SERVER       = 9     'The program is running on Windows 2000 Server (Standard) or Windows Server 2003 Standard Edition.
    %OS_WIN2000ADVSERVER    = 10    'The program is running on Windows 2000 Advanced Server or Windows Server 2003 Enterprise Edition.
    %OS_WIN2000DATACENTER   = 11    'The program is running on Windows 2000 Datacenter Server or Windows Server 2003 Datacenter Edition.
    %OS_WIN2000TERMINAL     = 12    'The program is running on Windows 2000 Terminal Server in either Remote Administration mode or
                                    'Application Server mode, or Windows Server 2003 (or one of its successors) in Terminal Server
                                    'mode or Remote Desktop for Administration mode.
    %OS_EMBEDDED            = 13    'The program is running on Windows Embedded, any version.
    %OS_TERMINALCLIENT      = 14    'The program is running as a Terminal Server client.
                                    'Equivalent to GetSystemMetrics(SM_REMOTESESSION).
    %OS_TERMINALREMOTEADMIN = 15    'The program is running on Windows 2000 Terminal Server in Remote Administration mode or
                                    'Windows Server 2003 (or one of its successors) in Remote Desktop for Administration mode.
    %OS_WIN95_GOLD          = 16    'Windows 95 exactly.
    %OS_MEORGREATER         = 17    'The program is running on Windows Millennium Edition (Windows Me) or one of its successors.
    %OS_XPORGREATER         = 18    'The program is running on Windows XP or one of its successors.
    %OS_HOME                = 19    'The program is running on the Home Edition of Windows XP or one of its successors.
    %OS_PROFESSIONAL        = 20    'The program is running on Windows NT Workstation or Windows 2000 (or one of its successors) Professional.
    %OS_DATACENTER          = 21    'The program is running on Windows Datacenter Server or Windows Server Datacenter Edition, any version.
    %OS_ADVSERVER           = 22    'The program is running on Windows Advanced Server or Windows Server Enterprise Edition, any version.
    %OS_SERVER              = 23    'The program is running on Windows Server (Standard) or Windows Server Standard Edition, any version.
    %OS_TERMINALSERVER      = 24    'The program is running on Windows 2000 Terminal Server in Application Server mode,
                                    'or on Windows Server 2003 (or one of its successors) in Terminal Server mode.
    %OS_PERSONALTERMINALSERVER = 25 'The program is running on Windows XP (or one of its successors), Home Edition or Professional.
    %OS_FASTUSERSWITCHING   = 26    'Fast user switching is enabled.
    %OS_WELCOMELOGONUI      = 27    'The Welcome screen is used for logon.
    %OS_DOMAINMEMBER        = 28    'The computer is joined to a domain.
    %OS_ANYSERVER           = 29    'The program is running on any Windows Server product.
    %OS_WOW6432             = 30    'The program is a 32-bit program running on Microsoft Win64.
    %OS_WEBSERVER           = 31    'The program is running on Windows Server 2003, Web Edition, or one of its successors.
    %OS_SMALLBUSINESSSERVER = 32    'The program is running on Microsoft Small Business Server with restrictive client license in force.
    %OS_TABLETPC            = 33    'The program is running on Windows XP Tablet PC Edition, or one of its successors.
                                    'Equivalent to GetSystemMetrics(SM_TABLETPC).
    %OS_SERVERADMINUI       = 34    'The program should bias its defaults towards those suitable for server administrators.
    %OS_MEDIACENTER         = 35    'The program is running on Windows XP Media Center Edition, or one of its successors.
                                    'Equivalent to GetSystemMetrics(SM_MEDIACENTER).
    %OS_APPLIANCE           = 36    'The program is running on Windows Appliance Server.
    %OS_VISTA               = 37    'The program is running on Windows Vista. NOTE: that OS_VISTA is not defined by Microsoft
    
    TYPE DllVersionInfo
      cbSize            AS DWORD
      dwMajorVersion    AS DWORD
      dwMinorVersion    AS DWORD
      dwBuildNumber     AS DWORD
      dwPlatformID      AS DWORD
    END TYPE
    %DLLVER_PLATFORM_WINDOWS = 1
    %DLLVER_PLATFORM_NT      = 2  
    
    DECLARE FUNCTION DllVer(DVI AS DllVersionInfo) AS LONG
    FUNCTION DllGetVersion(LibName AS ASCIIZ, DVI AS DLLVERSIONINFO) AS LONG
      LOCAL hLib AS DWORD, pAddr AS DWORD, lResult AS LONG
      DVI.cbSize = SIZEOF(DVI)
      lResult = 1
      hLib = LoadLibrary(LibName)
      IF hLib THEN
        pAddr = GetProcAddress(hLib, "DllGetVersion")
        IF pAddr THEN CALL DWORD pAddr USING DllVer(DVI) TO lResult
        FreeLibrary hLib
      END IF
      FUNCTION = lResult
    END FUNCTION    
    
    DECLARE FUNCTION IsOS(dwOS AS LONG) AS LONG
    FUNCTION IsOS(dwOS AS LONG) AS LONG
        DIM pAddr   AS DWORD
        DIM hlib    AS DWORD
        DIM lresult AS LONG, ret AS LONG
        LOCAL DVI AS DLLVERSIONINFO
    'get shlwapi version exit if < 5 or unable to load
        Ret = DllGetVersion("ShlWApi.dll", DVI)
            IF (Ret <> %NOERROR OR DVI.dwMajorVersion < 5) THEN EXIT FUNCTION
    'load shlwapi we are ver 5 or rgeater
        hlib= LoadLibrary("shlwapi.dll")
        IF (hlib <> 0 AND DVI.dwMajorVersion >= 5) THEN
            'Exported by name on Vista try this first
            pAddr = GetProcAddress(hlib, "IsOS")
            IF pAddr = 0 THEN  'not by name see if we can get by ordinal
                pAddr = GetProcAddress(hlib, BYVAL MAKDWD(437,0))
            ELSE
                FUNCTION = %FALSE
            END IF
            IF pAddr THEN CALL DWORD pAddr USING IsOS(BYVAL MAKDWD(dwOS,0)) TO lresult
            FreeLibrary hlib
        END IF
        FUNCTION = lResult
    END FUNCTION     
    FUNCTION PBMAIN () AS LONG
           LOCAL i AS LONG
           FOR i = 0 TO 37
               IF ISTRUE IsOS(i) THEN MSGBOX STR$(i) & " = TRUE"
           NEXT i
    END FUNCTION
    Thanks
    Last edited by Ronald Robinson; 21 Feb 2009, 09:12 PM. Reason: added shlwapi version check

  • #2
    I get an undefined equate error on %NOERROR during compilation.
    Scott Slater
    Summit Computer Networks, Inc.
    www.summitcn.com

    Comment


    • #3
      30 does return True. I had to include win32api to get it running.
      Scott Slater
      Summit Computer Networks, Inc.
      www.summitcn.com

      Comment


      • #4
        Thank You Scott

        I should have mentioned this works with windows XP and above as long as SHLWAPI.DLL is version 5 or greater

        Comment

        Working...
        X