Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. 64 or 32 bit

64 or 32 bit

Scheduled Pinned Locked Moved C#
csharpcom
12 Posts 6 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    Jared Parsons
    wrote on last edited by
    #1

    How can you determine at run time in C# if you're running on a 32 or 64 bit machine Jared Parsons jaredp@beanseed.org http://jaredparsons.blogspot.com/[^]

    D J L N 5 Replies Last reply
    0
    • J Jared Parsons

      How can you determine at run time in C# if you're running on a 32 or 64 bit machine Jared Parsons jaredp@beanseed.org http://jaredparsons.blogspot.com/[^]

      D Offline
      D Offline
      Divyang Mithaiwala
      wrote on last edited by
      #2

      Hello Jared, I am not sure about this method. Becoz i have no PC of 64 bit. But you just try. Check size of 'int'. like val = sizeof(int); if it is 4 byte then 32 bit machine & if 8 byte then 64 bit machine. For my 32 bit machine it is 4. Regards, Divyang Mithaiwala

      J 1 Reply Last reply
      0
      • J Jared Parsons

        How can you determine at run time in C# if you're running on a 32 or 64 bit machine Jared Parsons jaredp@beanseed.org http://jaredparsons.blogspot.com/[^]

        J Offline
        J Offline
        Joe Woodbury
        wrote on last edited by
        #3

        Values are the same size for both 32 and 64-bit (an int is 4 bytes on both.) I don't believe there is a simple, standard way to detect this. Anyone who thinks he has a better idea of what's good for people than people do is a swine. - P.J. O'Rourke

        D 1 Reply Last reply
        0
        • J Joe Woodbury

          Values are the same size for both 32 and 64-bit (an int is 4 bytes on both.) I don't believe there is a simple, standard way to detect this. Anyone who thinks he has a better idea of what's good for people than people do is a swine. - P.J. O'Rourke

          D Offline
          D Offline
          Divyang Mithaiwala
          wrote on last edited by
          #4

          Hello Joe, Sorry for my answer. But i think that int data type is for best CPU performance. And for fix length type you have to take long & short. Regards, Divyang Mithaiwala

          G 1 Reply Last reply
          0
          • D Divyang Mithaiwala

            Hello Joe, Sorry for my answer. But i think that int data type is for best CPU performance. And for fix length type you have to take long & short. Regards, Divyang Mithaiwala

            G Offline
            G Offline
            Guffa
            wrote on last edited by
            #5

            The int data type is just an alias for System.Int32. A long is System.Int64 and short is System.Int16. MSDN: C# Built-in Types[^] --- b { font-weight: normal; }

            D 1 Reply Last reply
            0
            • J Jared Parsons

              How can you determine at run time in C# if you're running on a 32 or 64 bit machine Jared Parsons jaredp@beanseed.org http://jaredparsons.blogspot.com/[^]

              L Offline
              L Offline
              leppie
              wrote on last edited by
              #6

              sizeof(IntPtr) should give you the answer :)

              xacc.ide-0.1.2.15
              Now with a grid!

              J 1 Reply Last reply
              0
              • J Jared Parsons

                How can you determine at run time in C# if you're running on a 32 or 64 bit machine Jared Parsons jaredp@beanseed.org http://jaredparsons.blogspot.com/[^]

                D Offline
                D Offline
                Divyang Mithaiwala
                wrote on last edited by
                #7

                You can use val = IntPtr.size But it will give bit of platform not a machine. Which is some time difference. For more information click here Regards, Divyang Mithaiwala

                1 Reply Last reply
                0
                • G Guffa

                  The int data type is just an alias for System.Int32. A long is System.Int64 and short is System.Int16. MSDN: C# Built-in Types[^] --- b { font-weight: normal; }

                  D Offline
                  D Offline
                  Divyang Mithaiwala
                  wrote on last edited by
                  #8

                  Hello Guffa, Actually i am not wrong with my thing. But it will not work in C#. Please refer this. Regards, Divyang Mithaiwala.

                  G 1 Reply Last reply
                  0
                  • J Jared Parsons

                    How can you determine at run time in C# if you're running on a 32 or 64 bit machine Jared Parsons jaredp@beanseed.org http://jaredparsons.blogspot.com/[^]

                    N Offline
                    N Offline
                    Nicholas Butler
                    wrote on last edited by
                    #9

                    Hi I presume you have a 32-bit assembly and want to know if you are running on a native 32-bit machine or under WOW64 on a native 64-bit machine. There is an API method IsWow64Process you can call using pinvoke - I could not find a managed method. ---------------------------- Be excellent to each other :)

                    1 Reply Last reply
                    0
                    • D Divyang Mithaiwala

                      Hello Guffa, Actually i am not wrong with my thing. But it will not work in C#. Please refer this. Regards, Divyang Mithaiwala.

                      G Offline
                      G Offline
                      Guffa
                      wrote on last edited by
                      #10

                      Yes, you are of course right, in the same way as pigs can fly. If the pig is a bird, it can fly. This will of course not work if the pig is a pig. ;) --- b { font-weight: normal; }

                      1 Reply Last reply
                      0
                      • D Divyang Mithaiwala

                        Hello Jared, I am not sure about this method. Becoz i have no PC of 64 bit. But you just try. Check size of 'int'. like val = sizeof(int); if it is 4 byte then 32 bit machine & if 8 byte then 64 bit machine. For my 32 bit machine it is 4. Regards, Divyang Mithaiwala

                        J Offline
                        J Offline
                        Jared Parsons
                        wrote on last edited by
                        #11

                        Divyang Mithaiwala wrote:

                        if it is 4 byte then 32 bit machine & if 8 byte then 64 bit machine. For my 32 bit machine it is 4.

                        That doesn't work in C# because int is guaranteed to be 4 bytes regardless of the architecture. Jared Parsons jaredp@beanseed.org http://jaredparsons.blogspot.com/[^]

                        1 Reply Last reply
                        0
                        • L leppie

                          sizeof(IntPtr) should give you the answer :)

                          xacc.ide-0.1.2.15
                          Now with a grid!

                          J Offline
                          J Offline
                          Jared Parsons
                          wrote on last edited by
                          #12

                          Or better yet IntPtr.Size. That looks like the right approach though. Thanks! Jared Parsons jaredp@beanseed.org http://jaredparsons.blogspot.com/[^]

                          1 Reply Last reply
                          0
                          Reply
                          • Reply as topic
                          Log in to reply
                          • Oldest to Newest
                          • Newest to Oldest
                          • Most Votes


                          • Login

                          • Don't have an account? Register

                          • Login or register to search.
                          • First post
                            Last post
                          0
                          • Categories
                          • Recent
                          • Tags
                          • Popular
                          • World
                          • Users
                          • Groups