Indigo Rose Software

Professional Software Development Tools

 
+ Reply to Thread
Results 1 to 14 of 14

Thread: OS Name

  1. #1
    Join Date
    May 2008
    Location
    The Netherlands
    Posts
    109

    OS Name

    Well the problem is that i've got this code

    Code:
    OSName = System.GetOSName();
    
    if OSName ~= "Windows XP" or OSName ~= "Windows Server 2003" then
    Dialog.Message("OS", "You don't have the right os to run this program", MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
    Application.Exit()
    else
    end
    but it gives this result (see the picture)
    i don't think thats what it has to do
    can you help me with that?
    Attached Images

  2. #2
    Join Date
    May 2005
    Posts
    1,115
    Try checking for the OS version.

    Windows 2000 is 5.0, XP is 5.1, Windows 2003 Server is 5.2.
    Vista is 6.0.
    Never know what life is gonna throw at you.
    (Based on a true story.)

  3. #3
    Join Date
    May 2008
    Location
    The Netherlands
    Posts
    109
    that worked bule, thanks.

    and how do i check if its home or pro
    same question for vista

    thanks

  4. #4
    Join Date
    Apr 2005
    Location
    São Paulo, Brazil
    Posts
    2,539
    There is an error in your boolean logic in the first post. The condition will always return true.

    No text can be simultaneously equal to both strings "Windows XP" and "Windows Server 2003".

    Ulrich
    Last edited by Ulrich; 08-23-2008 at 09:08 AM.

  5. #5
    Join Date
    May 2008
    Location
    The Netherlands
    Posts
    109
    So i need to use and?
    Last edited by limboo; 08-23-2008 at 09:23 AM.

  6. #6
    Join Date
    May 2008
    Location
    The Netherlands
    Posts
    109
    but does someone know how to find out if it's XP Pro, Home, XP64bit and for vista the same thing

  7. #7
    Join Date
    Apr 2005
    Location
    São Paulo, Brazil
    Posts
    2,539
    Quote Originally Posted by limboo View Post
    So i need to use and?
    Probably. There is a simple rule for boolean comparisons, which you can use if something doesn't work as expected. Often reading the same comparison in another way makes the error more obvious. All you have to do is invert everything.

    In your case, you wrote:
    Code:
    if OSName ~= "Windows XP" or OSName ~= "Windows Server 2003" then
        Dialog.Message("OS", "You don't have the right os to run this program", MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
        Application.Exit()
    end
    This is the same as:
    Code:
    if OSName == "Windows XP" and OSName == "Windows Server 2003" then
        Dialog.Message("OS", "You don't have the right os to run this program", MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
        Application.Exit()
    end
    If after the inversion your boolean logic still makes sense to you, then it is probably right.

    You haven't said what exactly do you want, so it is quite hard to help you.

    Ulrich

  8. #8
    Join Date
    May 2008
    Location
    The Netherlands
    Posts
    109
    I've tried it with and and now it works fine at least i can access the application (haven't tried it with Windows Server 2003 yet but it will probably work)

    and to upeters what i want is to let my app check if the client has the correct os
    Last edited by limboo; 08-23-2008 at 10:11 AM.

  9. #9
    Join Date
    Mar 2005
    Location
    Indianaoplis, IN USA
    Posts
    127
    you currently have:

    not(x) or not(y)

    you need:

    not(x or y)

  10. #10
    Join Date
    May 2008
    Location
    The Netherlands
    Posts
    109
    you mean

    Code:
    if OSName ~= "Windows XP" or"Windows Server 2003" then
        Dialog.Message("OS", "You don't have the right os to run this program", MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
        Application.Exit()
    end
    nope ain't going to work
    the only thing that works is
    Code:
    if OSName ~= "Windows XP" and "Windows Server 2003" then
        Dialog.Message("OS", "You don't have the right os to run this program", MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
        Application.Exit()
    end
    but thats not my question anymore because i've solved it myself (with some help from upeters) my next question is how do i check if it's XP Pro, Home, 64bit, The same with Vista (Starter, Home Basic, Home Premium, Buisness, Enterprise, Ultimate, 32 bit, 64bit)

    thanks

  11. #11
    Join Date
    Mar 2005
    Location
    Indianaoplis, IN USA
    Posts
    127
    Code:
    if OSName ~= "Windows XP" and "Windows Server 2003" then
        Dialog.Message("OS", "You don't have the right os to run this program", MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
        Application.Exit()
    end
    That will always evaluate to true. So while it will allow you to get past that point in the code, it isn't actually doing anything useful.

    "Windows XP" and "Windows Server 2003" will always be false.
    So if you evaluate the expression, ~= false it will always return true.

    not(x or y) in your case would be

    Code:
    if not (OSName == "Windows XP" or OSName == "Windows Server 2003") then
        Dialog.Message("OS", "You don't have the right os to run this program", MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
        Application.Exit()
    end

  12. #12
    Join Date
    May 2008
    Location
    The Netherlands
    Posts
    109
    Thanks Murdock

    couldn't have thought of that in a thousand years

  13. #13
    Join Date
    Mar 2005
    Location
    Indianaoplis, IN USA
    Posts
    127
    Quote Originally Posted by limboo View Post
    my next question is how do i check if it's XP Pro, Home, 64bit, The same with Vista (Starter, Home Basic, Home Premium, Buisness, Enterprise, Ultimate, 32 bit, 64bit)

    thanks
    I would start with

    Code:
    result = Registry.GetValue(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows NT\\CurrentVersion", "ProductName", true);
    That won't work on any of the Win9x versions, but it should return the full OS Name on any of the latter versions. And you can use the System.Is64bitOS() to handle the 64bit question.

  14. #14
    Join Date
    May 2008
    Location
    The Netherlands
    Posts
    109
    nope, on my xp computer it only tells me Microsoft Windows XP

Posting Permissions

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