dcsimg
Results 1 to 17 of 17

Thread: OS Version information class

  1. #1

    Thread Starter
    Member Dragokas's Avatar
    Join Date
    Aug 2015
    Location
    Ukraine
    Posts
    571

    OS Version information class

    WinAPI based.

    Can show such information, like:

    OS Name: Windows 7
    Service Pack ver.: 1
    Is Server? False
    Bitness: x64
    Is x64: True
    Edition: Ultimate
    Suite mask: SingleUserTS
    ProductType: Workstation
    PlatformID: 2 (WinNT)
    Is Domain controller: False
    OS - XP or newer? True
    OS - Vista or newer? True
    OS - 7 or newer? True
    OS - 8 or newer? False
    OS - 8.1 or newer? False
    OS - 10 or newer? False
    Major: 6
    Minor: 1
    Major + Minor: 6,1
    Major + Minor (NtDll): 6,1
    Build: 7601
    NT Dll Major.Minor.Rev: 6.1.7601
    Revision: 23964
    ReleaseId: 0
    Language in dialogues: 1049 RU Russian
    Language of OS inslallation: 1049 RU Russian
    Language for non-Unicode programs: 1049 RU Russian
    Process integrity level: Medium
    Elevated process? False
    Is Local system context? False
    User group: Administrator
    Safe boot? False (Normal)
    Secure boot? False
    OEM Codepage: 866 (c_866.nls)

    Requirements:
    Nothing.

    Compatibility
    Windows 2000 - 10 / Compiled and IDE mode.

    Warning:
    To get reliable result you have to add application manifest with compatiblity section. Details are available here. Manifest is included in example attached.
    Attached Files Attached Files
    Last edited by Dragokas; Mar 4th, 2018 at 09:24 AM. Reason: new version

  2. #2

    Thread Starter
    Member Dragokas's Avatar
    Join Date
    Aug 2015
    Location
    Ukraine
    Posts
    571

    Re: OS Version information class

    Updated to v1.4.16

    GetVersionEx replaced by RtlGetVersion.
    WMI-based code used for IDE-mode is removed.
    Added InitCommonControlsEx.
    Print info on form.

  3. #3
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    5,627

    Re: OS Version information class

    Interestingly, it seems to circumvent any compatibility shims when running compiled. However, it doesn't circumvent the shims when executing from the IDE. In other words, if you have compatibility shims set for the VB6.EXE, it'll report whatever those shims say rather than the true OS. When executing from the IDE, here's what I get (and that reflects the shims I have set):

    Name:  Image1.gif
Views: 823
Size:  30.6 KB

    However, when executing a compiled OSverInfo.exe, here's what I get, regardless of what shims are set:

    Name:  Image2.gif
Views: 2003
Size:  30.6 KB

    Best Regards,
    Elroy
    Any software I post in these forums written by me is provided “AS IS” without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. Please understand that I’ve been programming since the mid-1970s and still have some of that code. My contemporary VB6 project is approaching 1,000 modules. In addition, I have a “VB6 random code folder” that is overflowing. I’ve been at this long enough to truly not know with absolute certainty from whence every single line of my code has come, with much of it coming from programmers under my employ who signed intellectual property transfers. I have not deliberately attempted to remove any licenses and/or attributions from any software. If someone finds that I have inadvertently done so, I sincerely apologize, and, upon notice and reasonable proof, will re-attach those licenses and/or attributions. To all, peace and happiness.

  4. #4

    Thread Starter
    Member Dragokas's Avatar
    Join Date
    Aug 2015
    Location
    Ukraine
    Posts
    571

    Re: OS Version information class

    Elroy, thank you for feedback.

    Interesting. I also see that sheem alter a registry data here:
    HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion => ProductName
    Updated to 1.4.17
    Returned WMI-based checking of OS version in IDE-mode.
    Added WMI-based checking of Service Pack version in IDE-mode (forgot it).

  5. #5
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    5,627

    Re: OS Version information class

    Nice work. It works perfectly now.
    Any software I post in these forums written by me is provided “AS IS” without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. Please understand that I’ve been programming since the mid-1970s and still have some of that code. My contemporary VB6 project is approaching 1,000 modules. In addition, I have a “VB6 random code folder” that is overflowing. I’ve been at this long enough to truly not know with absolute certainty from whence every single line of my code has come, with much of it coming from programmers under my employ who signed intellectual property transfers. I have not deliberately attempted to remove any licenses and/or attributions from any software. If someone finds that I have inadvertently done so, I sincerely apologize, and, upon notice and reasonable proof, will re-attach those licenses and/or attributions. To all, peace and happiness.

  6. #6

    Thread Starter
    Member Dragokas's Avatar
    Join Date
    Aug 2015
    Location
    Ukraine
    Posts
    571

    Re: OS Version information class

    Updated to 1.5

    Added new properties:
    - MajorMinorNTDLL (single, RtlGetNtVersionNumbers)
    - NtDllVersion (string, the same, but in format Major.Minor.Build)
    - Revision
    - IsWindowsXPOrGreater
    - IsWindowsVistaOrGreater (renamed from old IsVistaOrLater)
    - IsWindows7OrGreater
    - IsWindows8OrGreater
    - IsWindows8Point1OrGreater
    - IsWindows10OrGreater
    - ReleaseId
    - IsServer
    - IsWin64
    - PlatformID (Win32S = 0, Win32Windows = 1, Win32NT = 2, WinCE = 3)
    - SecureBoot (boolean, if Secure Boot is enabled)

    Added the list of versions and service packs in code comment.
    Updated the list of SuiteMasks.
    Detailed information for Win NT 4.0 and Win95 (however, I have no opprotunity to test class on such systems).

  7. #7
    Fanatic Member
    Join Date
    Apr 2015
    Location
    Finland
    Posts
    657

    Re: OS Version information class

    Thanks Dragokas.

    How about extending this class, with user information etc. retrieved fex. set command?

    >set

    ALLUSERSPROFILE=C:\ProgramData
    APPDATA=C:\Users\USER\AppData\Roaming
    COMPUTERNAME=HP-XX
    HOMEDRIVE=C:
    HOMEPATH=\Users\USER
    LOCALAPPDATA=C:\Users\USER\AppData\Local
    LOGONSERVER=\\HP-XX
    ProgramData=C:\ProgramData
    TEMP=C:\Trash
    USERDOMAIN=HP-XX
    USERDOMAIN_ROAMINGPROFILE=HP-XX
    USERNAME=USER
    USERPROFILE=C:\Users\USER

  8. #8

    Thread Starter
    Member Dragokas's Avatar
    Join Date
    Aug 2015
    Location
    Ukraine
    Posts
    571

    Re: OS Version information class

    Hi, Tech99 !

    I don't think this is a good idea for my concrete class.
    It will be much more convenient and understandable for code readability to store env. variables in some separate class, like:

    Code:
    set Env = new clsEnvVariables
    
    debug.? Env.UserName
    Besides, this class was intended for OS version info only.
    It's my fault that I allowed myself to expand it to process specific info e.t.c.

    Personally, I am using public variables in my programs, but I think with a class it will be much faster to write env. var. names with help of IntelliSense, especially if forgot how to spell the name correctly.
    Maybe, further I'll public such class, if I don't find a similar solution in codebank.

    Best wishes,
    Alex.

  9. #9
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    5,627

    Re: OS Version information class

    Also, the "Environ Function" is pretty easy to use.
    Any software I post in these forums written by me is provided “AS IS” without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. Please understand that I’ve been programming since the mid-1970s and still have some of that code. My contemporary VB6 project is approaching 1,000 modules. In addition, I have a “VB6 random code folder” that is overflowing. I’ve been at this long enough to truly not know with absolute certainty from whence every single line of my code has come, with much of it coming from programmers under my employ who signed intellectual property transfers. I have not deliberately attempted to remove any licenses and/or attributions from any software. If someone finds that I have inadvertently done so, I sincerely apologize, and, upon notice and reasonable proof, will re-attach those licenses and/or attributions. To all, peace and happiness.

  10. #10

    Thread Starter
    Member Dragokas's Avatar
    Join Date
    Aug 2015
    Location
    Ukraine
    Posts
    571

    Re: OS Version information class

    'Environ' is affected by Wow64, so I'm always using my EnvironW from FunctionW set.

    But, for most variables, you are right, no need for class.

  11. #11
    Member
    Join Date
    Feb 2004
    Posts
    44

    Re: OS Version information class

    Dragokas - great class. thanks for your work.

    Can you explain what the purpose/need is for the initializing in your sample form?
    Code:
    Private Sub Form_Initialize()
        Dim ICC         As tagINITCOMMONCONTROLSEX
        
        With ICC
            .dwSize = Len(ICC)
            .dwICC = ICC_STANDARD_CLASSES 'http://www.geoffchappell.com/studies/windows/shell/comctl32/api/commctrl/initcommoncontrolsex.htm
        End With
        
        InitCommonControlsEx ICC
    End Sub
    /Jimboat

  12. #12

    Thread Starter
    Member Dragokas's Avatar
    Join Date
    Aug 2015
    Location
    Ukraine
    Posts
    571

    Re: OS Version information class

    Hi, Jimboat.
    It is not relevant to the class. It's leftovers for my common manifest. You can safely remove it.
    However, if you plan to remove InitCommonControlsEx, you also need to remove <dependency> section in manifest.

    Thanks for the feedback.

  13. #13
    Member
    Join Date
    Feb 2004
    Posts
    44

    Re: OS Version information class

    Quote Originally Posted by Dragokas View Post
    Hi, Jimboat.
    It is not relevant to the class. It's leftovers for my common manifest. You can safely remove it.
    However, if you plan to remove InitCommonControlsEx, you also need to remove <dependency> section in manifest.

    Thanks for the feedback.
    excellent, thanks!
    /Jimboat

  14. #14
    Member
    Join Date
    Feb 2004
    Posts
    44

    Re: OS Version information class

    Quote Originally Posted by Dragokas View Post
    Hi, Jimboat.
    It is not relevant to the class. It's leftovers for my common manifest. You can safely remove it.
    However, if you plan to remove InitCommonControlsEx, you also need to remove <dependency> section in manifest.

    Thanks for the feedback.
    OK....now i'm interested. What does 'InitCommonControlsEx' do?
    /Jimboat

  15. #15

    Thread Starter
    Member Dragokas's Avatar
    Join Date
    Aug 2015
    Location
    Ukraine
    Posts
    571

    Re: OS Version information class

    Activates "themed" controls on window by using new version of Microsoft Windows Common Controls dll.

  16. #16
    Fanatic Member
    Join Date
    May 2014
    Location
    Preveza Greece
    Posts
    948

    Re: OS Version information class

    Thanks Dragokas.
    I put it in Revision 51 (Version 9.0) of M2000 Environment (not uploading yet, I have to make some tests)

  17. #17

    Thread Starter
    Member Dragokas's Avatar
    Join Date
    Aug 2015
    Location
    Ukraine
    Posts
    571

    Re: OS Version information class

    Hi, georgekar! Re-download new version. I forgot to upload.

    1.7.
    Fixed issue, os name doesn't show for domain controller.
    1 CloseHandle is missing.
    Removed 'SetCurrentProcessPrivileges' as not needed.
    Added properties:
    - IsDomainController
    - IsLocalSystemContext

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width