Results 1 to 14 of 14

Thread: Determining OS and Processor Problem!

Hybrid View

  1. #1

    Thread Starter
    Hyperactive Member Joye's Avatar
    Join Date
    Jul 2009
    Posts
    256

    Question Determining OS and Processor Problem!

    I made a small project which is a part of a bigger one, this project is a form of one button with two textboxes.

    This code works when user clicks on the button:

    Code:
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
            If System.Environment.Is64BitOperatingSystem = True Then
                TextBox1.Text = "64-bit Operating System"
            Else
                TextBox1.Text = "32-bit Operating System"
    
            End If
    
            If System.Environment.Is64BitProcess = True Then
                TextBox2.Text = "64-bit processor"
            Else
                TextBox2.Text = "32-bit processor"
            End If
        End Sub
    With that code I wanted to tell the user (or the bigger project) what operating system and type of processor he has on his PC?

    I tried the program on many devices and was fine until one day it showed me a x64 Operating System on a 32-bit Processor, and I know it's impossible.

    So I knew that there is a problem with determining the right Processor.

    I need to correct this code to determine and tell the exact OS and Processor type.

    Thank you

  2. #2
    PowerPoster PlausiblyDamp's Avatar
    Join Date
    Dec 2016
    Location
    Pontypool, Wales
    Posts
    2,474

    Re: Determining OS and Processor Problem!

    System.Environment.Is64BitProcess isn't telling you if the processor is 32 or 64 bit just if the current Process is. Then again if they are running on anything made in the last 10 years or so it will probably be 64bit anyway as Intel haven't made 32bit desktop cpus for over ten years and I imagine AMD are the same.
    Last edited by PlausiblyDamp; Oct 6th, 2018 at 01:15 PM.

  3. #3

    Thread Starter
    Hyperactive Member Joye's Avatar
    Join Date
    Jul 2009
    Posts
    256

    Re: Determining OS and Processor Problem!

    Quote Originally Posted by PlausiblyDamp View Post
    System.Environment.Is64BitProcess isn't telling you if the processor is 32 or 64 bit just if the current Process is.
    Then what tells?



    Then again if they are running on anything made in the last 10 years or so it will probably be 64bit anyway as Intel haven't made 32bit desktop cpus for over ten years and I imagine AMD are the same.
    I know but I have targeted users with Xp too

  4. #4
    PowerPoster PlausiblyDamp's Avatar
    Join Date
    Dec 2016
    Location
    Pontypool, Wales
    Posts
    2,474

    Re: Determining OS and Processor Problem!

    Is there a reason you need to know the CPU architecture if you know the OS architecture?

    The easiest way I can think of might be to check the environment variable PROCESSOR_ARCHITECTURE using https://docs.microsoft.com/en-us/dot...ramework-4.7.2 and see what it says, on my laptop it reports AMD64 so it is a 64 bit architecture.

  5. #5

    Thread Starter
    Hyperactive Member Joye's Avatar
    Join Date
    Jul 2009
    Posts
    256

    Re: Determining OS and Processor Problem!

    Quote Originally Posted by PlausiblyDamp View Post
    Is there a reason you need to know the CPU architecture if you know the OS architecture?

    The easiest way I can think of might be to check the environment variable PROCESSOR_ARCHITECTURE using https://docs.microsoft.com/en-us/dot...ramework-4.7.2 and see what it says, on my laptop it reports AMD64 so it is a 64 bit architecture.
    The reason is I want to determine what Active solution I should use with the user like If i should use:
    x86?
    x64?
    Any CPU (prefer 32 Checked)?
    Any CPU (prefer 32 Unchecked)?

    and then know what Microsoft.ACE.OLEDB.12.0' provider should be installed?

  6. #6
    Bad man! ident's Avatar
    Join Date
    Mar 2009
    Location
    Cambridge
    Posts
    5,398

    Re: Determining OS and Processor Problem!

    The code posted is correct. Only thing I can thinkof was a VM in play but then still....

  7. #7
    PowerPoster PlausiblyDamp's Avatar
    Join Date
    Dec 2016
    Location
    Pontypool, Wales
    Posts
    2,474

    Re: Determining OS and Processor Problem!

    Quote Originally Posted by Joye View Post
    The reason is I want to determine what Active solution I should use with the user like If i should use:
    x86?
    x64?
    Any CPU (prefer 32 Checked)?
    Any CPU (prefer 32 Unchecked)?

    and then know what Microsoft.ACE.OLEDB.12.0' provider should be installed?
    Unless you really need to run as a 64 bit process then you could go for AnyCPU prefer 32 bit. That way you will run as a 32 bit process on a 32 bit OS or a 64 bit OS that has support for 32 bit code. The only time it will run as a 64 bit process is if you are running on a 64bit OS that doesn't support 32 bit code (which is pretty unusual for a desktop these days anyway).

    The actual CPU shouldn't really make a difference, in fact neither should the OS - just check the value of System.Environment.Is64BitProcess to discover if you are running as 32bit or 64bit and act accordingly.
    Last edited by PlausiblyDamp; Oct 9th, 2018 at 02:04 PM.

  8. #8
    Bad man! ident's Avatar
    Join Date
    Mar 2009
    Location
    Cambridge
    Posts
    5,398

    Re: Determining OS and Processor Problem!

    Environment.Is64BitOperatingSystem does exactly what you ask.

  9. #9

    Thread Starter
    Hyperactive Member Joye's Avatar
    Join Date
    Jul 2009
    Posts
    256

    Re: Determining OS and Processor Problem!

    Quote Originally Posted by ident View Post
    Environment.Is64BitOperatingSystem does exactly what you ask.
    Then what Exactly I need??

  10. #10

    Thread Starter
    Hyperactive Member Joye's Avatar
    Join Date
    Jul 2009
    Posts
    256

    Re: Determining OS and Processor Problem!

    Quote Originally Posted by ident View Post
    Environment.Is64BitOperatingSystem does exactly what you ask.
    Then what Exactly I need??

  11. #11
    Bad man! ident's Avatar
    Join Date
    Mar 2009
    Location
    Cambridge
    Posts
    5,398

    Re: Determining OS and Processor Problem!

    Please everyone stop editing posts, its getting confusing replying. lol

Posting Permissions

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



Click Here to Expand Forum to Full Width