Announcement

Collapse
No announcement yet.

OpSysInfo - Includes Windows 7

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

  • OpSysInfo - Includes Windows 7

    In the past I had an INC to give me some minor details about what OS is being run. Now I have updated it to include Windows 7 (for when it is finally out). Along with detecting if Windows 32bit or 64bit. Some information as to what PB Compiler was used, the path it is loaded from, if the code is contained in a dll (and if so, what program loaded it?) along with version information gathered from a resource file in either the parent or dll (or both)

    Hope someone finds it useful

    DemoComputerInfo.bas
    Code:
    #COMPILE EXE                                                                              'Compile as executable
    #DIM ALL
    #INCLUDE "Win32Api.inc"
    #INCLUDE "OpSysInfo.inc"
    #RESOURCE "DemoOpSysInfo.pbr"
    
    FUNCTION WINMAIN(BYVAL hInstance AS DWORD, BYVAL hPrevInst AS DWORD, BYVAL lpszCmdLine AS ASCIIZ PTR, BYVAL nCmdShow AS LONG) AS LONG
         GetInfoFromInc
    END FUNCTION
    
    FUNCTION GetInfoFromInc()AS LONG
         LOCAL MyComputerInformation AS ComputerInfo
         LOCAL MyComputerInfo AS STRING
         GetWindowsOs(MyComputerInformation)
         GetCompiler(MyComputerInformation)
         GetProgram(MyComputerInformation)
         MyComputerInfo = MyComputerInfo + "OsString = " + SPACE$(5) + MyComputerInformation.OpSys.OsString + $CR
         MyComputerInfo = MyComputerInfo + "OsLong = " + SPACE$(5) + STR$(MyComputerInformation.OpSys.OsLong) + $CR
         MyComputerInfo = MyComputerInfo + SPACE$(5) + "dwMajorVersion = " + SPACE$(5) + STR$(MyComputerInformation.Os.dwMajorVersion) + $CR
         MyComputerInfo = MyComputerInfo + SPACE$(5) + "dwMinorVersion = " + SPACE$(5) + STR$(MyComputerInformation.Os.dwMinorVersion) + $CR
         MyComputerInfo = MyComputerInfo + "OsFamilyString = " + SPACE$(5) + MyComputerInformation.OpSys.OsFamilyString + $CR
         MyComputerInfo = MyComputerInfo + "OsFamilyLong = " + SPACE$(5) + STR$(MyComputerInformation.OpSys.OsFamilyLong) + $CR
         MyComputerInfo = MyComputerInfo + SPACE$(5) + "dwPlatformId = " + SPACE$(5) + STR$(MyComputerInformation.Os.dwPlatformId) + $CR
         MyComputerInfo = MyComputerInfo + $CR
         MyComputerInfo = MyComputerInfo + "dwBuildNumber = " + SPACE$(5) + STR$(MyComputerInformation.Os.dwBuildNumber) + $CR
         MyComputerInfo = MyComputerInfo + "Build Name = " + SPACE$(5) + MyComputerInformation.OpSys.BuildString + $CR
         MyComputerInfo = MyComputerInfo + "Service Pack = " + SPACE$(5) + MyComputerInformation.OpSys.ServicePack + $CR
         MyComputerInfo = MyComputerInfo + "Os Is 64 bit = " + SPACE$(5) + STR$(MyComputerInformation.OpSys.BitsCompiled)  + $CR
         MyComputerInfo = MyComputerInfo + $CR
         MyComputerInfo = MyComputerInfo + "PB Version = " + SPACE$(5) + MyComputerInformation.Compiler.CompilerString + $CR
         MyComputerInfo = MyComputerInfo + "Revision = " + SPACE$(5) + MyComputerInformation.Compiler.CompilerRevisionString + $CR
         MyComputerInfo = MyComputerInfo + "Compiled As " + SPACE$(5) + MyComputerInformation.Compiler.CompiledAsString + $CR
         MyComputerInfo = MyComputerInfo + $CR
         MyComputerInfo = MyComputerInfo + "Program Instance = " + SPACE$(5) + STR$(MyComputerInformation.Program.Instance)  + $CR
         MyComputerInfo = MyComputerInfo + "Program Path = " + SPACE$(5) + MyComputerInformation.Program.Path + $CR
         MyComputerInfo = MyComputerInfo + "Program Name = " + SPACE$(5) + MyComputerInformation.Program.Name + $CR
         MyComputerInfo = MyComputerInfo + $CR
         MyComputerInfo = MyComputerInfo + "Program PARENT Instance = " + SPACE$(5) + STR$(MyComputerInformation.Program.ParentInstance)  + $CR
         MyComputerInfo = MyComputerInfo + "Program PARENT Path = " + SPACE$(5) + MyComputerInformation.Program.ParentPath + $CR
         MyComputerInfo = MyComputerInfo + "Program PARENT Name = " + SPACE$(5) + MyComputerInformation.Program.ParentName + $CR
         MyComputerInfo = MyComputerInfo + $CR
         MyComputerInfo = MyComputerInfo + "Product Name = " + SPACE$(5) + MyComputerInformation.Resource.ProductName + $CR
         MyComputerInfo = MyComputerInfo + "Product Version = " + SPACE$(5) + MyComputerInformation.Resource.ProductVersion + $CR
         MyComputerInfo = MyComputerInfo + "Product Description = " + SPACE$(5) + MyComputerInformation.Resource.ProductDescription + $CR
         MyComputerInfo = MyComputerInfo + "FileVersion = " + SPACE$(5) + MyComputerInformation.Resource.FileVersion + $CR
         MyComputerInfo = MyComputerInfo + "Internal Name = " + SPACE$(5) + MyComputerInformation.Resource.InternalName + $CR
         MyComputerInfo = MyComputerInfo + "Company Name = " + SPACE$(5) + MyComputerInformation.Resource.CompanyName + $CR
         MyComputerInfo = MyComputerInfo + "Legal CopyRight = " + SPACE$(5) + MyComputerInformation.Resource.LegalCopyRight + $CR
         MyComputerInfo = MyComputerInfo + "Original File Name = " + SPACE$(5) + MyComputerInformation.Resource.OriginalFileName + $CR
         MyComputerInfo = MyComputerInfo + $CR
         MyComputerInfo = MyComputerInfo + "ParentProduct Name = " + SPACE$(5) + MyComputerInformation.Resource.ParentProductName + $CR
         MyComputerInfo = MyComputerInfo + "ParentProduct Version = " + SPACE$(5) + MyComputerInformation.Resource.ParentProductVersion + $CR
         MyComputerInfo = MyComputerInfo + "ParentProduct Description = " + SPACE$(5) + MyComputerInformation.Resource.ParentProductDescription + $CR
         MyComputerInfo = MyComputerInfo + "ParentFileVersion = " + SPACE$(5) + MyComputerInformation.Resource.ParentFileVersion + $CR
         MyComputerInfo = MyComputerInfo + "ParentInternal Name = " + SPACE$(5) + MyComputerInformation.Resource.ParentInternalName + $CR
         MyComputerInfo = MyComputerInfo + "ParentCompany Name = " + SPACE$(5) + MyComputerInformation.Resource.ParentCompanyName + $CR
         MyComputerInfo = MyComputerInfo + "ParentLegal CopyRight = " + SPACE$(5) + MyComputerInformation.Resource.ParentLegalCopyRight + $CR
         MyComputerInfo = MyComputerInfo + "ParentOriginal File Name = " + SPACE$(5) + MyComputerInformation.Resource.ParentOriginalFileName + $CR
    MSGBOX MyComputerInfo
    
    END FUNCTION
    OpSysInfo.inc
    Code:
    '**************************************************************************************************
    '*** Programmer: Cliff Nichols
    '*** Concept: Getting the Operating System Information
    '*** Date: 12-15-07
    '*** Last Update: 07-01-09
    '*** Compiler: PB Win 9.0.1 but should work on others
    '*** Operating System: XP / Vista but should work on 95/98/ME/NT/2K/Vista
    '*** Special Thanks:
    '**************************************************************************************************
    '*** Definitions for each of the operating systems
    'Windows < Win95
    '--------------------------------------------------------------------------------
    '
    '               Win 3.1
    'PlatformID     0
    'Major Version
    'Minor Version
    'Build
    '
    '--------------------------------------------------------------------------------
    'Windows 95/98/ME
    '--------------------------------------------------------------------------------
    '               Win     Win     Win
    '               95      98      Me
    '               ---     ---     ---
    'PlatformID     1       1       1
    'Major Version  4       4       4
    'Minor Version  0       10      90
    'Build          950*    1111    1998
    '
    '--------------------------------------------------------------------------------
    'Old Windows NT
    '--------------------------------------------------------------------------------
    '
    '               Win     Win     Win     Win
    '               NT      NT      NT      2000
    '               3.0     3.1     4
    '               ---     ---     ---     ----
    'PlatformID     2       2       2       2
    'Major Version  3       3       4       5
    'Minor Version  0       1       0       0
    'Build                          1381    2195
    '
    '--------------------------------------------------------------------------------
    'Windows NT
    '--------------------------------------------------------------------------------
    '
    '               Win     Win     Win     Win
    '               2003    XP      VISTA    7
    'PlatformID     2       2       2        2
    'Major Version  5       5       6        6
    'Minor Version  2       1       0        1
    'Build          3790    2600    TBD     TBD
    '
    '--------------------------------------------------------------------------------
    #IF NOT %DEF(%OPSYSINFO_INC)
         %OPSYSINFO_INC = 1                                                                                  'FLag for this INC
         #IF NOT %DEF(%UNKNOWN_VALUE)
               %UNKNOWN_VALUE = -1                                                                           'Unknown for when I do not know the value until runtime
         #ENDIF
    
    '*** The following equates are values I came up with to more easily determine the operating system
    '*** OpSys Branches
         %OS_PRE_WIN                        = 0
         %OS_WIN                            = 1
         %OS_WIN_NT                         = 2
    '*** OS Sub-Branches
         %OS_WIN_BRANCH_3                   = 0
         %OS_WIN_BRANCH_95_98_ME            = 4
         %OS_WIN_BRANCH_NT_2K_XP_VISTA_7    = 4
    '*** Operating Systems
         %OS_WIN_31                         = 1
         %OS_WIN_95                         = 2
         %OS_WIN_98                         = 3
         %OS_WIN_ME                         = 4
         %OS_WIN_NT_3                       = 5
         %OS_WIN_NT_31                      = 6
         %OS_WIN_NT_4                       = 7
         %OS_WIN_2000                       = 8
         %OS_WIN_XP                         = 9
         %OS_WIN_2003                       = 10
         %OS_WIN_VISTA                      = 11
         %OS_WIN_7                          = 12
    '-------------------------------------------------------------------------------------------------
    '*** Operating System Information
         TYPE OpSysInfo
              OsLong AS LONG                                                                                 'OS Number
              OsString AS ASCIIZ * %MAX_PATH                                                                 'OS Name
              OsFamilyLong AS LONG                                                                           'Family Tree for OS
              OsFamilyString AS ASCIIZ * %MAX_PATH                                                           '
              BuildLong AS LONG
              BuildString AS ASCIIZ * %MAX_PATH
              ServicePack AS ASCIIZ * %MAX_PATH
              BitsCompiled AS LONG
         END TYPE
    
         TYPE CompilerInfo
              CompilerLong AS LONG
              CompilerString AS ASCIIZ * %MAX_PATH
              CompilerRevisionLong AS LONG
              CompilerRevisionString AS ASCIIZ * %MAX_PATH
              CompiledAsLong AS LONG
              CompiledAsString AS ASCIIZ * %MAX_PATH
         END TYPE
    
         TYPE ProgramInfo
              INSTANCE AS LONG
              PATH AS ASCIIZ * %MAX_PATH
              NAME AS ASCIIZ * %MAX_PATH
              ParentInstance AS LONG
              ParentPath AS ASCIIZ * %MAX_PATH
              ParentName AS ASCIIZ * %MAX_PATH
         END TYPE
    
         TYPE ResourceInfo
              ProductName AS ASCIIZ * %MAX_PATH
              ProductVersion AS ASCIIZ * %MAX_PATH
              ProductDescription AS ASCIIZ * %MAX_PATH
              FileVersion AS ASCIIZ * %MAX_PATH
              InternalName AS ASCIIZ * %MAX_PATH
              CompanyName AS ASCIIZ * %MAX_PATH
              LegalCopyRight AS ASCIIZ * %MAX_PATH
              OriginalFileName AS ASCIIZ * %MAX_PATH
              ParentProductName AS ASCIIZ * %MAX_PATH
              ParentProductVersion AS ASCIIZ * %MAX_PATH
              ParentProductDescription AS ASCIIZ * %MAX_PATH
              ParentFileVersion AS ASCIIZ * %MAX_PATH
              ParentInternalName AS ASCIIZ * %MAX_PATH
              ParentCompanyName AS ASCIIZ * %MAX_PATH
              ParentLegalCopyRight AS ASCIIZ * %MAX_PATH
              ParentOriginalFileName AS ASCIIZ * %MAX_PATH
         END TYPE
    
         TYPE ComputerInfo
              Os AS OSVERSIONINFO
              OpSys AS OpSysInfo
              Compiler AS CompilerInfo
              Program AS ProgramInfo
              Resource AS ResourceInfo
         END TYPE
    
    '--------------------------------------- DECLARES ------------------------------------------------
         DECLARE FUNCTION GetWindowsOs ALIAS "GetWindowsOs"(ComputerInformation AS ComputerInfo) AS DWORD
         DECLARE FUNCTION WindowsOs(ComputerInformation AS ComputerInfo) AS DWORD
         DECLARE FUNCTION WindowsOsFamily(ComputerInformation AS ComputerInfo) AS DWORD
         DECLARE FUNCTION WindowsBuild(ComputerInformation AS ComputerInfo) AS DWORD
         DECLARE FUNCTION WindowsServicePack(ComputerInformation AS ComputerInfo) AS DWORD
         DECLARE FUNCTION WindowsBitsCompiledFor(ComputerInformation AS ComputerInfo) AS DWORD
         DECLARE FUNCTION ProgramCompiler(ComputerInformation AS ComputerInfo) AS DWORD
         DECLARE FUNCTION ProgramCompiledAs(ComputerInformation AS ComputerInfo) AS DWORD
    
         DECLARE FUNCTION GetModuleVersionInfo(ComputerInformation AS ComputerInfo) AS DWORD
    
    '*** Functions to be called (IF they exist, function is not guarenteed to exist)
         DECLARE FUNCTION Is64Bit(CurrentProcess AS LONG, Is64bit AS LONG) AS LONG
    '-------------------------------------------------------------------------------------------------
    
         FUNCTION GetWindowsOs ALIAS "GetWindowsOs"(ComputerInformation AS ComputerInfo) EXPORT AS DWORD     'Export in case used with DLL and need to call functions in this INC
              ComputerInformation.Os.dwOSVersionInfoSize = SIZEOF(OSVERSIONINFOEX)                           'Should be SIZEOF(OsInfoEx) not hardcoded (128) like other examples
              GetVersionEx ComputerInformation.Os
              WindowsOs ComputerInformation
              WindowsOsFamily ComputerInformation
              WindowsBuild ComputerInformation
              WindowsServicePack ComputerInformation
              WindowsBitsCompiledFor ComputerInformation
         END FUNCTION
    
         FUNCTION GetCompiler ALIAS "GetCompiler"(ComputerInformation AS ComputerInfo) EXPORT AS DWORD     'Export in case used with DLL and need to call functions in this INC
              ProgramCompiler ComputerInformation
              ProgramCompiledAs ComputerInformation
         END FUNCTION
    
         FUNCTION GetProgram ALIAS "GetProgram"(ComputerInformation AS ComputerInfo) EXPORT AS DWORD     'Export in case used with DLL and need to call functions in this INC
              ProgramInstance ComputerInformation
              ProgramPath ComputerInformation
              ProgramName ComputerInformation
              ProgramParentInstance ComputerInformation
              ProgramParentPath ComputerInformation
              ProgramParentName ComputerInformation
              GetModuleVersionInfo ComputerInformation
              GetParentModuleVersionInfo ComputerInformation
         END FUNCTION
    
         FUNCTION WindowsOs(ComputerInformation AS ComputerInfo) AS DWORD
              SELECT CASE ComputerInformation.Os.dwPlatformId
                   CASE %OS_PRE_WIN                                                                          'Platform is < Win95
                        ComputerInformation.OpSys.OsLong = %OS_WIN_31                                        'Windows 3.1
                        ComputerInformation.OpSys.OsString = "Windows 3.1"
                   CASE %OS_WIN                                                                              'Platform is Win 95/98/ME
                        SELECT CASE ComputerInformation.Os.dwMajorVersion
                             CASE %OS_WIN_BRANCH_95_98_ME                                                    'Win 95/98/ME
                                  SELECT CASE ComputerInformation.Os.dwMinorVersion
                                       CASE 0                                                                'Win 95
                                            ComputerInformation.OpSys.OsLong = %OS_WIN_95
                                            ComputerInformation.OpSys.OsString = "Windows 95"
                                       CASE 10                                                               'Win 98
                                            ComputerInformation.OpSys.OsLong = %OS_WIN_98
                                            ComputerInformation.OpSys.OsString = "Windows 98"
                                       CASE 90                                                               'Win ME
                                            ComputerInformation.OpSys.OsLong = %OS_WIN_ME
                                            ComputerInformation.OpSys.OsString = "Windows ME"
                                  END SELECT
                        END SELECT
                   CASE %OS_WIN_NT                                                                           'Platform is Win NT 3/4/5/6
                        SELECT CASE ComputerInformation.Os.dwMajorVersion
                             CASE 3                                                                          'Win NT 3
                                  SELECT CASE ComputerInformation.Os.dwMinorVersion
                                       CASE 0                                                                'Win NT 3
                                            ComputerInformation.OpSys.OsLong = %OS_WIN_NT_3
                                            ComputerInformation.OpSys.OsString = "Windows NT 3"
                                       CASE 1                                                                'Win NT 3.1
                                            ComputerInformation.OpSys.OsLong = %OS_WIN_NT_31
                                            ComputerInformation.OpSys.OsString = "Windows NT 3.1"
                                  END SELECT
                             CASE 4                                                                          'Win NT 4
                                  SELECT CASE ComputerInformation.Os.dwMinorVersion
                                       CASE 0                                                                'Win NT 4
                                            ComputerInformation.OpSys.OsLong = %OS_WIN_NT_4
                                            ComputerInformation.OpSys.OsString = "Windows NT 4"
                                  END SELECT
                             CASE 5                                                                          'Win NT 5
                                  SELECT CASE ComputerInformation.Os.dwMinorVersion
                                       CASE 0                                                                'Win 2000
                                            ComputerInformation.OpSys.OsLong = %OS_WIN_2000
                                            ComputerInformation.OpSys.OsString = "Windows 2000"
                                       CASE 1                                                                'Win XP
                                            ComputerInformation.OpSys.OsLong = %OS_WIN_XP
                                            ComputerInformation.OpSys.OsString = "Windows XP"
                                       CASE 2                                                                'Windows 2003 Server"
                                            ComputerInformation.OpSys.OsLong = %OS_WIN_2003
                                            ComputerInformation.OpSys.OsString = "Windows 2003 Server"
                                  END SELECT
                             CASE 6                                                                          'Win NT 6
                                  SELECT CASE ComputerInformation.Os.dwMinorVersion
                                       CASE 0                                                                'Win Vista
                                            ComputerInformation.OpSys.OsLong = %OS_WIN_VISTA
                                            ComputerInformation.OpSys.OsString = "Windows Vista"
                                       CASE 1                                                                'Windows7
                                            ComputerInformation.OpSys.OsLong = %OS_WIN_7
                                            ComputerInformation.OpSys.OsString = "Windows 7"
                                  END SELECT
                        END SELECT
              END SELECT
         END FUNCTION
    
         FUNCTION WindowsOsFamily(ComputerInformation AS ComputerInfo) AS DWORD
              SELECT CASE ComputerInformation.Os.dwPlatformId
                   CASE %OS_PRE_WIN                                                                          'Platform is < Win95
                        ComputerInformation.OpSys.OsFamilyLong = %OS_PRE_WIN                                        'Windows 3.1
                        ComputerInformation.OpSys.OsFamilyString = "Pre-Windows 95"
                   CASE %OS_WIN                                                                              'Platform is Win 95/98/ME
                        ComputerInformation.OpSys.OsFamilyLong = %OS_WIN                                        'Windows 3.1
                        ComputerInformation.OpSys.OsFamilyString = "Windows 95/98/ME"
                   CASE %OS_WIN_NT                                                                           'Platform is Win NT 3/4/5/6
                        ComputerInformation.OpSys.OsFamilyLong = %OS_WIN_NT                                        'Windows 3.1
                        ComputerInformation.OpSys.OsFamilyString = "Windows NT, 3 = NT 3/3.1, 4 = NT, 5 = 2000/XP/2003 Server, 6 = Vista and Windows 7"
              END SELECT
         END FUNCTION
    
         FUNCTION WindowsBuild(ComputerInformation AS ComputerInfo) AS DWORD
              ComputerInformation.OpSys.BuildLong = ComputerInformation.Os.dwBuildNumber
              SELECT CASE ComputerInformation.Os.dwBuildNumber
                   CASE 950    'Win 95
                        ComputerInformation.OpSys.BuildString = ""
                   CASE 1111   'Win 98 OSR2
                        ComputerInformation.OpSys.BuildString = "OSR2"
                   CASE 1998   'Win ME
                        ComputerInformation.OpSys.BuildString = ""
                   CASE 1381   'Win NT 4
                        ComputerInformation.OpSys.BuildString = ""
                   CASE 2195   'Win 2000
                        ComputerInformation.OpSys.BuildString = ""
                   CASE 3790   'Win 2003 Server
                        ComputerInformation.OpSys.BuildString = ""
                   CASE 2600   'Win XP
                        ComputerInformation.OpSys.BuildString = ""
              END SELECT
         END FUNCTION
    
         FUNCTION WindowsServicePack(ComputerInformation AS ComputerInfo) AS DWORD
              ComputerInformation.OpSys.ServicePack = ComputerInformation.Os.szCSDVersion
         END FUNCTION
    
    '*** ONLY VALID BECAUSE PB IS 32 BIT COMPILED, NOT 64 BIT
    '***      Returns %TRUE if 32 bit in 64 bit OS
    '***      Returns %FALSE if 64 bit in 64 bit OS
    '***      Returns %FALSE if 32 bit in 32 bit OS
    '***      No Return (essentially 0 or %FALSE) if function does not exist
         FUNCTION WindowsBitsCompiledFor(ComputerInformation AS ComputerInfo) AS DWORD
              LOCAL DoesWowExist AS LONG
              LOCAL Is64bitOs AS LONG
              SELECT CASE GetProcAddress(GetModuleHandle("kernel32"), "IsWow64Process")         'Only works because Kernel32 is part of my process
                   CASE 0
                   CASE ELSE
                        DoesWowExist = GetProcAddress(GetModuleHandle("kernel32"), "IsWow64Process")         'Only works because Kernel32 is part of my process
                        CALL DWORD DoesWowExist USING Is64Bit(GetCurrentProcess, Is64bitOs)
                        ComputerInformation.OpSys.BitsCompiled = Is64bitOs
              END SELECT
         END FUNCTION
    
         FUNCTION ProgramCompiler(ComputerInformation AS ComputerInfo) AS DWORD
              ComputerInformation.Compiler.CompilerLong = %PB_REVISION
              ComputerInformation.Compiler.CompilerString = LEFT$(HEX$(%PB_REVISION), 1) + "." + MID$(HEX$(%PB_REVISION), 2)
              ComputerInformation.Compiler.CompilerRevisionLong = %PB_REVLETTER
              ComputerInformation.Compiler.CompilerRevisionString = "&H" + TRIM$(STR$(%PB_REVLETTER))
         END FUNCTION
    
         FUNCTION ProgramCompiledAs(ComputerInformation AS ComputerInfo) AS DWORD
              ComputerInformation.Compiler.CompiledAsLong = %PB_EXE
              SELECT CASE ComputerInformation.Compiler.CompiledAsLong
                   CASE 0
                        ComputerInformation.Compiler.CompiledAsString = "DLL"
                   CASE ELSE
                        ComputerInformation.Compiler.CompiledAsString = "EXE"
              END SELECT
         END FUNCTION
    
         FUNCTION ProgramInstance(ComputerInformation AS ComputerInfo) AS DWORD
              ComputerInformation.Program.Instance = GetModuleHandle("OpSysInfo")
         END FUNCTION
    
         FUNCTION ProgramPath(ComputerInformation AS ComputerInfo) AS DWORD
              GetModuleFileName(GetModuleHandle("OpSysInfo"), ComputerInformation.Program.Path, SIZEOF(ComputerInformation.Program.Path))       'Get Exe/Dll Path and Name
              REPLACE "\" WITH "/" IN ComputerInformation.Program.Path
              ComputerInformation.Program.Path = LEFT$(ComputerInformation.Program.Path, INSTR(-1, ComputerInformation.Program.Path, ANY "\/:")) ' this is same as AppPath
         END FUNCTION
    
         FUNCTION ProgramName(ComputerInformation AS ComputerInfo) AS DWORD
              GetModuleFileName(GetModuleHandle("OpSysInfo"), ComputerInformation.Program.Path, SIZEOF(ComputerInformation.Program.Path))       'Get Exe/Dll Path and Name
              REPLACE "\" WITH "/" IN ComputerInformation.Program.Path
              ComputerInformation.Program.Path = LEFT$(ComputerInformation.Program.Path, INSTR(-1, ComputerInformation.Program.Path, ANY "\/:")) ' this is same as AppPath
              GetModuleFileName(GetModuleHandle("OpSysInfo"), ComputerInformation.Program.Name, %MAX_PATH)       'Get Exe/Dll Path and Name
              REPLACE "\" WITH "/" IN ComputerInformation.Program.Name
              REPLACE ComputerInformation.Program.Path WITH "" IN ComputerInformation.Program.Name
         END FUNCTION
    
         FUNCTION ProgramParentInstance(ComputerInformation AS ComputerInfo) AS DWORD
              ComputerInformation.Program.ParentInstance = GetModuleHandle(BYVAL %NULL)
         END FUNCTION
    
         FUNCTION ProgramParentPath(ComputerInformation AS ComputerInfo) AS DWORD
              GetModuleFileName(GetModuleHandle(BYVAL %NULL), ComputerInformation.Program.ParentPath, %MAX_PATH)       'Get Exe/Dll Path and Name
              REPLACE "\" WITH "/" IN ComputerInformation.Program.ParentPath
              ComputerInformation.Program.ParentPath = LEFT$(ComputerInformation.Program.ParentPath, INSTR(-1, ComputerInformation.Program.ParentPath, ANY "\/:")) ' this is same as AppPath
         END FUNCTION
    
         FUNCTION ProgramParentName(ComputerInformation AS ComputerInfo) AS DWORD
              GetModuleFileName(GetModuleHandle(BYVAL %NULL), ComputerInformation.Program.ParentPath, %MAX_PATH)       'Get Exe/Dll Path and Name
              REPLACE "\" WITH "/" IN ComputerInformation.Program.ParentPath
              ComputerInformation.Program.ParentPath = LEFT$(ComputerInformation.Program.ParentPath, INSTR(-1, ComputerInformation.Program.ParentPath, ANY "\/:")) ' this is same as AppPath
              GetModuleFileName(GetModuleHandle(BYVAL %NULL), ComputerInformation.Program.ParentName, %MAX_PATH)       'Get Exe/Dll Path and Name
              REPLACE "\" WITH "/" IN ComputerInformation.Program.ParentName
              REPLACE ComputerInformation.Program.ParentPath WITH "" IN ComputerInformation.Program.ParentName
         END FUNCTION
    
    '------------------------------------------------------------------------------
         FUNCTION GetModuleVersionInfo(ComputerInformation AS ComputerInfo) AS DWORD
              LOCAL FileHandle AS LONG                'Ignored in GetFileVersionInfo
              LOCAL pLang AS LONG PTR
              LOCAL sLangID AS STRING
              LOCAL BufferToHoldBlockSize AS STRING
              LOCAL BlockSize AS LONG
              LOCAL pValue AS ASCIIZ PTR
              LOCAL DummySize AS DWORD
    
    '*** Obtain the version block
              BlockSize = GetFileVersionInfoSize(BYCOPY ComputerInformation.Program.Name, DummySize)
              IF ISFALSE BlockSize THEN EXIT FUNCTION
              BufferToHoldBlockSize = SPACE$(BlockSize)
              IF ISFALSE GetFileVersionInfo(BYCOPY ComputerInformation.Program.Name, FileHandle, BlockSize, BYVAL STRPTR(BufferToHoldBlockSize)) THEN EXIT FUNCTION
    '*** Check language id - default to American English if not found
              IF ISFALSE VerQueryValue(BYVAL STRPTR(BufferToHoldBlockSize), "\VarFileInfo\Translation", pLang, DummySize) THEN
                 sLangID = "040904E4" ' American English/ANSI
              ELSE
                 sLangID = HEX$(LOWRD(@pLang), 4) + HEX$(HIWRD(@pLang), 4)
              END IF
              VerQueryValue(BYVAL STRPTR(BufferToHoldBlockSize), "\StringFileInfo\" + sLangID + "\" + "ProductName", pValue, DummySize)
              ComputerInformation.Resource.ProductName = @pValue
              VerQueryValue(BYVAL STRPTR(BufferToHoldBlockSize), "\StringFileInfo\" + sLangID + "\" + "ProductVersion", pValue, DummySize)
              ComputerInformation.Resource.ProductVersion = @pValue
              VerQueryValue(BYVAL STRPTR(BufferToHoldBlockSize), "\StringFileInfo\" + sLangID + "\" + "ProductDescription", pValue, DummySize)
              ComputerInformation.Resource.ProductDescription = @pValue
              VerQueryValue(BYVAL STRPTR(BufferToHoldBlockSize), "\StringFileInfo\" + sLangID + "\" + "FileVersion", pValue, DummySize)
              ComputerInformation.Resource.FileVersion = @pValue
              VerQueryValue(BYVAL STRPTR(BufferToHoldBlockSize), "\StringFileInfo\" + sLangID + "\" + "InternalName", pValue, DummySize)
              ComputerInformation.Resource.InternalName = @pValue
              VerQueryValue(BYVAL STRPTR(BufferToHoldBlockSize), "\StringFileInfo\" + sLangID + "\" + "CompanyName", pValue, DummySize)
              ComputerInformation.Resource.CompanyName = @pValue
              VerQueryValue(BYVAL STRPTR(BufferToHoldBlockSize), "\StringFileInfo\" + sLangID + "\" + "LegalCopyRight", pValue, DummySize)
              ComputerInformation.Resource.LegalCopyRight = @pValue
              VerQueryValue(BYVAL STRPTR(BufferToHoldBlockSize), "\StringFileInfo\" + sLangID + "\" + "OriginalFileName", pValue, DummySize)
              ComputerInformation.Resource.OriginalFileName = @pValue
         END FUNCTION
    
         FUNCTION GetParentModuleVersionInfo(ComputerInformation AS ComputerInfo) AS DWORD
              LOCAL FileHandle AS LONG                'Ignored in GetFileVersionInfo
              LOCAL pLang AS LONG PTR
              LOCAL sLangID AS STRING
              LOCAL BufferToHoldBlockSize AS STRING
              LOCAL BlockSize AS LONG
              LOCAL pValue AS ASCIIZ PTR
              LOCAL DummySize AS DWORD
    
    '*** Obtain the version block
              BlockSize = GetFileVersionInfoSize(BYCOPY ComputerInformation.Program.ParentName, DummySize)
              IF ISFALSE BlockSize THEN EXIT FUNCTION
              BufferToHoldBlockSize = SPACE$(BlockSize)
              IF ISFALSE GetFileVersionInfo(BYCOPY ComputerInformation.Program.ParentName, FileHandle, BlockSize, BYVAL STRPTR(BufferToHoldBlockSize)) THEN EXIT FUNCTION
    '*** Check language id - default to American English if not found
              IF ISFALSE VerQueryValue(BYVAL STRPTR(BufferToHoldBlockSize), "\VarFileInfo\Translation", pLang, DummySize) THEN
                 sLangID = "040904E4" ' American English/ANSI
              ELSE
                 sLangID = HEX$(LOWRD(@pLang), 4) + HEX$(HIWRD(@pLang), 4)
              END IF
              VerQueryValue(BYVAL STRPTR(BufferToHoldBlockSize), "\StringFileInfo\" + sLangID + "\" + "ProductName", pValue, DummySize)
              ComputerInformation.Resource.ParentProductName = @pValue
              VerQueryValue(BYVAL STRPTR(BufferToHoldBlockSize), "\StringFileInfo\" + sLangID + "\" + "ProductVersion", pValue, DummySize)
              ComputerInformation.Resource.ParentProductVersion = @pValue
              VerQueryValue(BYVAL STRPTR(BufferToHoldBlockSize), "\StringFileInfo\" + sLangID + "\" + "ProductDescription", pValue, DummySize)
              ComputerInformation.Resource.ParentProductDescription = @pValue
              VerQueryValue(BYVAL STRPTR(BufferToHoldBlockSize), "\StringFileInfo\" + sLangID + "\" + "FileVersion", pValue, DummySize)
              ComputerInformation.Resource.ParentFileVersion = @pValue
              VerQueryValue(BYVAL STRPTR(BufferToHoldBlockSize), "\StringFileInfo\" + sLangID + "\" + "InternalName", pValue, DummySize)
              ComputerInformation.Resource.ParentInternalName = @pValue
              VerQueryValue(BYVAL STRPTR(BufferToHoldBlockSize), "\StringFileInfo\" + sLangID + "\" + "CompanyName", pValue, DummySize)
              ComputerInformation.Resource.ParentCompanyName = @pValue
              VerQueryValue(BYVAL STRPTR(BufferToHoldBlockSize), "\StringFileInfo\" + sLangID + "\" + "LegalCopyRight", pValue, DummySize)
              ComputerInformation.Resource.ParentLegalCopyRight = @pValue
              VerQueryValue(BYVAL STRPTR(BufferToHoldBlockSize), "\StringFileInfo\" + sLangID + "\" + "OriginalFileName", pValue, DummySize)
              ComputerInformation.Resource.ParentOriginalFileName = @pValue
         END FUNCTION
    
         FUNCTION PrintComputerInformation(FileNumber AS LONG)AS LONG
              PRINT# FileNumber, DATE$ + SPACE$(5) + TIME$
              PRINT# FileNumber, $CR
              LOCAL ComputerInformation AS ComputerInfo
              GetWindowsOs(ComputerInformation)
              GetCompiler(ComputerInformation)
              GetProgram(ComputerInformation)
              PRINT# FileNumber,  "OsString = " + SPACE$(5) + ComputerInformation.OpSys.OsString + $CR
              PRINT# FileNumber,  "OsLong = " + SPACE$(5) + STR$(ComputerInformation.OpSys.OsLong) + $CR
              PRINT# FileNumber,  SPACE$(5) + "dwMajorVersion = " + SPACE$(5) + STR$(ComputerInformation.Os.dwMajorVersion) + $CR
              PRINT# FileNumber,  SPACE$(5) + "dwMinorVersion = " + SPACE$(5) + STR$(ComputerInformation.Os.dwMinorVersion) + $CR
              PRINT# FileNumber,  "OsFamilyString = " + SPACE$(5) + ComputerInformation.OpSys.OsFamilyString + $CR
              PRINT# FileNumber,  "OsFamilyLong = " + SPACE$(5) + STR$(ComputerInformation.OpSys.OsFamilyLong) + $CR
              PRINT# FileNumber,  SPACE$(5) + "dwPlatformId = " + SPACE$(5) + STR$(ComputerInformation.Os.dwPlatformId) + $CR
              PRINT# FileNumber,  $CR
              PRINT# FileNumber,  "dwBuildNumber = " + SPACE$(5) + STR$(ComputerInformation.Os.dwBuildNumber) + $CR
              PRINT# FileNumber,  "Build Name = " + SPACE$(5) + ComputerInformation.OpSys.BuildString + $CR
              PRINT# FileNumber,  "Service Pack = " + SPACE$(5) + ComputerInformation.OpSys.ServicePack + $CR
              PRINT# FileNumber,  "Os Is 64 bit = " + SPACE$(5) + STR$(ComputerInformation.OpSys.BitsCompiled)  + $CR
              PRINT# FileNumber,  $CR
              PRINT# FileNumber,  "PB Version = " + SPACE$(5) + ComputerInformation.Compiler.CompilerString + $CR
              PRINT# FileNumber,  "Revision = " + SPACE$(5) + ComputerInformation.Compiler.CompilerRevisionString + $CR
              PRINT# FileNumber,  "Compiled As " + SPACE$(5) + ComputerInformation.Compiler.CompiledAsString + $CR
              PRINT# FileNumber,  $CR
              PRINT# FileNumber,  "Program Instance = " + SPACE$(5) + STR$(ComputerInformation.Program.Instance)  + $CR
              PRINT# FileNumber,  "Program Path = " + SPACE$(5) + ComputerInformation.Program.Path + $CR
              PRINT# FileNumber,  "Program Name = " + SPACE$(5) + ComputerInformation.Program.Name + $CR
              PRINT# FileNumber,  $CR
              PRINT# FileNumber,  "Program PARENT Instance = " + SPACE$(5) + STR$(ComputerInformation.Program.ParentInstance)  + $CR
              PRINT# FileNumber,  "Program PARENT Path = " + SPACE$(5) + ComputerInformation.Program.ParentPath + $CR
              PRINT# FileNumber,  "Program PARENT Name = " + SPACE$(5) + ComputerInformation.Program.ParentName + $CR
              PRINT# FileNumber,  $CR
              PRINT# FileNumber,  "Product Name = " + SPACE$(5) + ComputerInformation.Resource.ProductName + $CR
              PRINT# FileNumber,  "Product Version = " + SPACE$(5) + ComputerInformation.Resource.ProductVersion + $CR
              PRINT# FileNumber,  "Product Description = " + SPACE$(5) + ComputerInformation.Resource.ProductDescription + $CR
              PRINT# FileNumber,  "FileVersion = " + SPACE$(5) + ComputerInformation.Resource.FileVersion + $CR
              PRINT# FileNumber,  "Internal Name = " + SPACE$(5) + ComputerInformation.Resource.InternalName + $CR
              PRINT# FileNumber,  "Company Name = " + SPACE$(5) + ComputerInformation.Resource.CompanyName + $CR
              PRINT# FileNumber,  "Legal CopyRight = " + SPACE$(5) + ComputerInformation.Resource.LegalCopyRight + $CR
              PRINT# FileNumber,  "Original File Name = " + SPACE$(5) + ComputerInformation.Resource.OriginalFileName + $CR
              PRINT# FileNumber,  $CR
              PRINT# FileNumber,  "ParentProduct Name = " + SPACE$(5) + ComputerInformation.Resource.ParentProductName + $CR
              PRINT# FileNumber,  "ParentProduct Version = " + SPACE$(5) + ComputerInformation.Resource.ParentProductVersion + $CR
              PRINT# FileNumber,  "ParentProduct Description = " + SPACE$(5) + ComputerInformation.Resource.ParentProductDescription + $CR
              PRINT# FileNumber,  "ParentFileVersion = " + SPACE$(5) + ComputerInformation.Resource.ParentFileVersion + $CR
              PRINT# FileNumber,  "ParentInternal Name = " + SPACE$(5) + ComputerInformation.Resource.ParentInternalName + $CR
              PRINT# FileNumber,  "ParentCompany Name = " + SPACE$(5) + ComputerInformation.Resource.ParentCompanyName + $CR
              PRINT# FileNumber,  "ParentLegal CopyRight = " + SPACE$(5) + ComputerInformation.Resource.ParentLegalCopyRight + $CR
              PRINT# FileNumber,  "ParentOriginal File Name = " + SPACE$(5) + ComputerInformation.Resource.ParentOriginalFileName + $CR
              PRINT# FileNumber,  $CR
         END FUNCTION
    #ENDIF
    The complete project can be downloaded in the attached zip file if needing the *.pbr files
    Attached Files
    Engineer's Motto: If it aint broke take it apart and fix it

    "If at 1st you don't succeed... call it version 1.0"

    "Half of Programming is coding"....."The other 90% is DEBUGGING"

    "Document my code????" .... "WHYYY??? do you think they call it CODE? "

  • #2
    Small goof, I posted to the wrong room. I have now put the code in the Source Code forum.

    Let me know if there is more computer information that I may not have thought of yet.
    Engineer's Motto: If it aint broke take it apart and fix it

    "If at 1st you don't succeed... call it version 1.0"

    "Half of Programming is coding"....."The other 90% is DEBUGGING"

    "Document my code????" .... "WHYYY??? do you think they call it CODE? "

    Comment

    Working...
    X