Retrieving system information

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • kurotsuke

    Retrieving system information

    How can I retrieve the amount of RAM installed on the system and if
    the user has the Administrator privileges?

    Thanks a lot.
  • Yunus Emre ALPÖZEN [MCSD.NET]

    #2
    Re: Retrieving system information

    Use performance counters...

    Sample code;

    System.Diagnost ics.Performance Counter pCounter = new
    System.Diagnost ics.Performance Counter();

    pCounter.Counte rName = "System Code Total Bytes";

    pCounter.Catego ryName = "Memory";

    Console.WriteLi ne( pCounter.RawVal ue.ToString() );

    pCounter.Counte rName = "Available MBytes";

    Console.WriteLi ne(pCounter.Raw Value.ToString( ));

    Console.Read();


    --

    Thanks,
    Yunus Emre ALPÖZEN
    BSc, MCSD.NET

    "kurotsuke" <kurotsuke@yaho o.it> wrote in message
    news:rek3b152lj ga4mh7re644nmpv nlh1ftolk@4ax.c om...[color=blue]
    > How can I retrieve the amount of RAM installed on the system and if
    > the user has the Administrator privileges?
    >
    > Thanks a lot.[/color]


    Comment

    • kurotsuke

      #3
      Re: Retrieving system information

      On Thu, 16 Jun 2005 22:52:15 +0300, "Yunus Emre ALPÖZEN [MCSD.NET]"
      <yemre@msakadem ik.net> wrote:
      [color=blue]
      >Use performance counters...
      >
      >Sample code;
      >
      >System.Diagnos tics.Performanc eCounter pCounter = new
      >System.Diagnos tics.Performanc eCounter();
      >
      >pCounter.Count erName = "System Code Total Bytes";
      >
      >pCounter.Categ oryName = "Memory";
      >
      >Console.WriteL ine( pCounter.RawVal ue.ToString() );
      >
      >pCounter.Count erName = "Available MBytes";
      >
      >Console.WriteL ine(pCounter.Ra wValue.ToString ());
      >
      >Console.Read() ;[/color]

      I'm getting an exception on the WriteLine. Any idea on how to fix
      that?
      Thanks.

      Comment

      • kurotsuke

        #4
        Re: Retrieving system information

        On Thu, 16 Jun 2005 22:52:15 +0300, "Yunus Emre ALPÖZEN [MCSD.NET]"
        <yemre@msakadem ik.net> wrote:
        [color=blue]
        >Use performance counters...
        >
        >Sample code;
        >
        >System.Diagnos tics.Performanc eCounter pCounter = new
        >System.Diagnos tics.Performanc eCounter();
        >
        >pCounter.Count erName = "System Code Total Bytes";
        >
        >pCounter.Categ oryName = "Memory";
        >
        >Console.WriteL ine( pCounter.RawVal ue.ToString() );
        >
        >pCounter.Count erName = "Available MBytes";
        >
        >Console.WriteL ine(pCounter.Ra wValue.ToString ());
        >
        >Console.Read() ;[/color]

        I got the message telling me that the category doesn't exist. It looks
        like the problem is with both Memory and Available MBytes

        Comment

        • Jon Skeet [C# MVP]

          #5
          Re: Retrieving system information

          kurotsuke <kurotsuke@yaho o.it> wrote:[color=blue][color=green]
          > >System.Diagnos tics.Performanc eCounter pCounter = new
          > >System.Diagnos tics.Performanc eCounter();
          > >
          > >pCounter.Count erName = "System Code Total Bytes";
          > >
          > >pCounter.Categ oryName = "Memory";
          > >
          > >Console.WriteL ine( pCounter.RawVal ue.ToString() );
          > >
          > >pCounter.Count erName = "Available MBytes";
          > >
          > >Console.WriteL ine(pCounter.Ra wValue.ToString ());
          > >
          > >Console.Read() ;[/color]
          >
          > I'm getting an exception on the WriteLine. Any idea on how to fix
          > that?[/color]

          It would help if you'd say exactly what the exception is.

          Could you post a short but complete program which demonstrates the
          problem?

          See http://www.pobox.com/~skeet/csharp/complete.html for details of
          what I mean by that.

          --
          Jon Skeet - <skeet@pobox.co m>
          Pobox has been discontinued as a separate service, and all existing customers moved to the Fastmail platform.

          If replying to the group, please do not mail me too

          Comment

          Working...