1

I want to determine via C#, using NET 2.0 framework, if my operating system is 32 bit or 64 bit.

I can't use Environment.Is64BitOperatingSystem, because is only valid on net4 and above.

Y can't use native dll windows funcions or registry properties, because this is only valid for windows.

Is there any way to check this in unix and mac?

dhalfageme
  • 1,444
  • 4
  • 21
  • 42

1 Answers1

1

Finally, that worked for Linux (Unix and Mac):

    static string GetLinuxArchitectureType()
    {
        Mono.Unix.Native.Utsname result;
        int res = Mono.Unix.Native.Syscall.uname(out result);

        if (res < 0)
            return "N/A";

        return result.machine;
    }
dhalfageme
  • 1,444
  • 4
  • 21
  • 42
  • 1
    I said I already had this code for windows, it's easy to find. I check first the OS type and use this funcion on unix and mac – dhalfageme Jan 23 '15 at 10:52
  • To check to OS type you use http://stackoverflow.com/a/9129523/2626313 and in case of `PlatformID.Unix` you branch to this function ? – xmojmr Jan 23 '15 at 11:32
  • 1
    Well, I switch in case > PlatformID.WinCE (Unix, MAC and xBox, the last doesn't make sense for me) – dhalfageme Jan 23 '15 at 12:06