CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 15 of 15
  1. #1
    Join Date
    Aug 2015
    Posts
    59

    Question how to check which systems runs x64 or x32

    This is my processor = AMD Athlon II , I considire it as AMD64, am I wrong?
    have installed Win10 on my lap, have excpect Is64bit givs me a 'true', but it doesnt.

    I ask, cause this is the way I like to proof, f it has 64bit or 32bit system.
    Code:
    bool Is64bit = string.IsNullOrEmpty(Environment.GetEnvironmentVariable("PROCESSOR_ARCHITEW6432"));
    to come finally to this point

    Code:
     if (Is64bit)
                    {
                        searcher = new ManagementObjectSearcher("select * from Win64_Processor");
                        foreach (ManagementObject share in searcher.Get())
                        {
                            // first of all, the processorid
                            strProcId += share.GetPropertyValue("ProcessorId").ToString();
                        }
                    }

  2. #2
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: how to check which systems runs x64 or x32

    In .Net 4.0 or higher call, Environment.Is64BitOperatingSystem or Environment.Is64BitProcess.

  3. #3
    Join Date
    Aug 2015
    Posts
    59

    Re: how to check which systems runs x64 or x32

    well, that works, thank you
    But why I still get the IDs on a Win64 system (ProzessorID or baseboardId) using "select * from Win32_Processor", but using "select * from Win64_Processor" throw an error?

  4. #4
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: how to check which systems runs x64 or x32

    Quote Originally Posted by pschulz View Post
    well, that works, thank you
    But why I still get the IDs on a Win64 system (ProzessorID or baseboardId) using "select * from Win32_Processor", but using "select * from Win64_Processor" throw an error?
    Catch the exception to find out the error. WMI is great, but it is slow and has a lot of initial startup overhead. If you are usind .Net 4.0 or better, prefer to use the Environment class methods I suggested previously.

  5. #5
    Join Date
    Aug 2015
    Posts
    59

    Re: how to check which systems runs x64 or x32

    well, it say no validate class, does it tell you something?
    I changed the project to "AnyCpu" , so the app is shown as a 64 within the taskmanger, but its the same

  6. #6
    Join Date
    Aug 2015
    Posts
    59

    Re: how to check which systems runs x64 or x32

    some to add
    mabe I dont know whta you ment "prefer to use the Environment class methods I suggested previously. " Enviroment just givs me the maschinname, some other things but nothing like procId or Harddrive ID, or Basboard

  7. #7
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: how to check which systems runs x64 or x32

    Quote Originally Posted by pschulz View Post
    some to add
    mabe I dont know whta you ment "prefer to use the Environment class methods I suggested previously. " Enviroment just givs me the maschinname, some other things but nothing like procId or Harddrive ID, or Basboard
    You didn't ask for that - you originally asked for detecting 64bit.

  8. #8
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: how to check which systems runs x64 or x32

    Quote Originally Posted by pschulz View Post
    well, it say no validate class, does it tell you something?
    I changed the project to "AnyCpu" , so the app is shown as a 64 within the taskmanger, but its the same
    Is Win64_Processor a valid WMI class? I'm asking because I haven't looked it up in msdn. Even if it is valid, it make not be supported on the system you are trying the code on.

  9. #9
    Join Date
    Aug 2015
    Posts
    59

    Re: how to check which systems runs x64 or x32

    it says no, but neither could find "Win32_Processor",
    this is the page where I lookd:
    https://msdn.microsoft.com/en-us/lib...(v=vs.85).aspx

    this is to me the page where it has to be, big letters "WMI Classes"

  10. #10
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: how to check which systems runs x64 or x32

    Quote Originally Posted by pschulz View Post
    it says no, but neither could find "Win32_Processor",
    this is the page where I lookd:
    https://msdn.microsoft.com/en-us/lib...(v=vs.85).aspx

    this is to me the page where it has to be, big letters "WMI Classes"
    It isn't on that page directly (actually there is a link on that page that points you to the Win32 Classes). At any rate, search by Win32_Processor and you'll find https://msdn.microsoft.com/en-us/lib...(v=vs.85).aspx

    There are no Win64_xxx WMI classes so that is why you get an invalid error when attempting to use that class.

  11. #11
    Join Date
    Aug 2015
    Posts
    59

    Re: how to check which systems runs x64 or x32

    thanks man,
    but I went through all of those links, within that page "https://msdn.microsoft.com/en-us/lib...(v=vs.85).aspx", but there wasnt any Win32 Classes.
    Can you tell which link it is.

  12. #12
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: how to check which systems runs x64 or x32

    Quote Originally Posted by pschulz View Post
    thanks man,
    but I went through all of those links, within that page "https://msdn.microsoft.com/en-us/lib...(v=vs.85).aspx", but there wasnt any Win32 Classes.
    Can you tell which link it is.
    Click on the link I gave you in post #10.

  13. #13
    Join Date
    Aug 2015
    Posts
    59

    Re: how to check which systems runs x64 or x32

    I watch that link, of course, saw it is as you said.
    Also watchd this "It isn't on that page directly (actually there is a link on that page that points you to the Win32 Classes)."
    Just have like to see what did I miss, why you found, on the same route, some I couldnt.

  14. #14
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: how to check which systems runs x64 or x32

    Quote Originally Posted by pschulz View Post
    I watch that link, of course, saw it is as you said.
    Also watchd this "It isn't on that page directly (actually there is a link on that page that points you to the Win32 Classes)."
    Just have like to see what did I miss, why you found, on the same route, some I couldnt.
    It's in the table of WMI Classes - the one with the Section and Description at the top of the page and the row with CIM Classes. Link highlighted in blue below.


    Section Description
    CIM Classes Common Information Model (CIM) schema classes. If you want to write your own WMI classes then you can inherit from one or more of these classes.
    The WMI Win32 Classes inherit from the CIM classes.

  15. #15
    Join Date
    Aug 2015
    Posts
    59

    Re: how to check which systems runs x64 or x32

    got it, thank you

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
  •  





Click Here to Expand Forum to Full Width

Featured