Run app with a specific version.

Posted on 2006-05-16
Last Modified: 2013-11-13

How can i make my app run with a specific version of system?

Suppose the user is under Linux or Windows 2000 and i want
my app to run only with Windows xp home or professional.
Other wise my app will close.

Another example is this...
I want my app to run only with the specify version on the other program
If the other program is not the version specify in my app, Then Exit Sub.
Question by:Dazm
    LVL 19

    Expert Comment

    You cannot even make a VB executable for linux. So you dont have to worry about that. What you can do though is verify that the computer is Windows XP.

    LVL 2

    Author Comment


    BrianGEFF719: You cannot even make a VB executable for linux.
    BrianGEFF719: So you dont have to worry about that.

    I did not say that my app was for Linux.
    What i tried to say is that, what if the user try my app in a computer with Linux or
    other operate system that is not Win98, Me, xp, 2000 etc., Thats what i meant.

    I have seen many programs that when they do not find the right version
    of the other program, they continue to close itself if nothing was found.

    BrianGEFF719: What you can do though is verify that the computer is Windows XP.

    I have done this before, but i thought there was a better way to do it.
    If Text1 Not "Windows XP" Then Exit Sub

    I find this code long time ago in
    With this code i can generate something close of what i want, but not what i really need.

    Option Explicit

    Private Declare Function GetVersionEx Lib "kernel32" Alias "GetVersionExA" (ByRef lpVersionInformation As OSVERSIONINFO) As Long
    Private Type OSVERSIONINFO
    dwOSVersionInfoSize As Long
    dwMajorVersion As Long
    dwMinorVersion As Long
    dwBuildNumber As Long
    dwPlatformId As Long
    szCSDVersion As String * 128
    End Type

    Private Const VER_PLATFORM_WIN32s = 0
    Private Const VER_PLATFORM_WIN32_WINDOWS = 1
    Private Const VER_PLATFORM_WIN32_NT = 2

    ' Return the Windows version.
    Public Function WindowsVersion() As String
    Dim txt As String

    info.dwOSVersionInfoSize = Len(info)
    GetVersionEx info

    Select Case info.dwPlatformId
    txt = "Windows "
    If info.dwMajorVersion = 5 Then
    txt = "Windows 2000 "
    ElseIf info.dwMajorVersion < 4 Or _
    (info.dwMajorVersion = 4 And _
    info.dwMinorVersion = 0) _
    txt = "Windows95 "
    txt = "Windows98 "
    End If
    txt = "WindowsNT "
    End Select

    txt = txt & Format$(info.dwMajorVersion) & _
    "." & Format$(info.dwMinorVersion) & _
    vbCrLf & "Build " & Format$(info.dwBuildNumber)
    WindowsVersion = txt
    End Function

    LVL 19

    Expert Comment

    Why is that not what you need?

    If WindowsVersion <> "WindowsXP" Then
     Msgbox "You are not using the right version of windows!",16,"Error"
    End if

    LVL 2

    Author Comment


    Ok, let me explain a bit more.

    First this code doesn't work...

    > If WindowsVersion <> "WindowsXP" Then
    > MsgBox "You are not using the right version of windows!", 16, "Error"
    > End
    > End If

    I am with Windows XP and I still get the popup error message.

    Here is how i was doing it before...

    > If Text1 Not "Windows XP" Then Exit Sub

    This one works very well for me, but not yours.
    I do this with a Textbox, Label Text, or the name "Windows XP"

    But anyways i already know this code, is the one i show you before
    But like i said it, for me this is not a good method on how to do it.

    It is not about make the program unload, hide, or close
    just because the name of => "Windows XP" was not find.

    The point of my project is to check not just the name
    But the version of the assigning program to be detected.

    For example:
    I test my app in three different computer with windows xp OS
    And this is the result... my app fail on one of the computers,
    In one of the computers my app was reading => "WindowsNT" not "Windows XP"
    The three computers had windows xp accept for one with Home edition, but still
    Windows xp and i don't think it was because of the home edition version of windows.

    So i was trying to avoid my app with all those differences in version of windows.
    LVL 19

    Accepted Solution

    LVL 2

    Author Comment


    Sorry i took so long to reply to you, But i was not home : )

    Yeah this looks like a good example...
    But still have a little error reading windows.

    => Is Windows NT4 Plus ?.......True    Sorry but this is not true
    => Is Windows NT4 Server ?...True    Sorry but this is not true
    => Is Windows 2000 Plus ?......True    Sorry but this is not true

    I think the rest is ok.

    Is Windows XP ?................True
    Is Windows Plus ?..............True
    Is Windows XP Pro ?..........True

    But after all, I wonder if i can pull the right information from this code to make mine code work.
    LVL 2

    Author Comment


    Could you provide me with some example on how to make my
    project work without having to use the example that you showed to me?

    Thank you

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Find Ransomware Secrets With All-Source Analysis

    Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

    Among others, I monitor the Windows Installer zone and Installer zone. I find that many of the questions could be answered much more quickly if a Windows Installer verbose log were submitted with the question.   However, I do not always have t…
    Introduction In a recent article ( for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
    As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
    This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    9 Experts available now in Live!

    Get 1:1 Help Now