473,320 Members | 2,029 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

System settings through c#

GC
Hi,
How would I get various system settings through C# such as machine name,
hard drives, bytes free on hard drives, printers, etc...this is going to be
from a simple console app. Thanks!
Nov 16 '05 #1
6 3486
A lot of them are in the SystemInformation class.
Some of the others can be found in the System.Diagnostics namespace.

John Wood
Blog: http://spaces.msn.com/members/johnwood

"GC" <gc@gc.com> wrote in message
news:us****************@TK2MSFTNGP14.phx.gbl...
Hi,
How would I get various system settings through C# such as machine name,
hard drives, bytes free on hard drives, printers, etc...this is going to be from a simple console app. Thanks!

Nov 16 '05 #2
GC,

In addition to what John Wood mentioned in his post, you might want to
take a look in the System.Management namespace. It will have classes that
allow you to access the WMI classes, which will give you pretty much any
piece of information about the system that you wish.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"GC" <gc@gc.com> wrote in message
news:us****************@TK2MSFTNGP14.phx.gbl...
Hi,
How would I get various system settings through C# such as machine name,
hard drives, bytes free on hard drives, printers, etc...this is going to
be from a simple console app. Thanks!

Nov 16 '05 #3
Check the System.Windows.Forms.SystemInformation class...

"GC" <gc@gc.com> wrote in message
news:us**************@TK2MSFTNGP14.phx.gbl...
Hi,
How would I get various system settings through C# such as machine name,
hard drives, bytes free on hard drives, printers, etc...this is going to be
from a simple console app. Thanks!

Nov 16 '05 #4
Hi,

You can use all of the methods that everyone has provided plus the
System.Environment to get basic information. I have posted a sample below
that shows the System.Environment and the System.Management classes (and a
link to the WMI Properties). From these you should be able to get anything
that you need.

Hope this helps
---------------------

//link for the WMI - Win32_LogicalDisk propertie
//http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/win32_logicaldisk.asp?frame=true

//System.Environment information
String env_query = "My system drive is %PATHEXT% and my system root is
%SystemRoot%";
Console.WriteLine(Environment.ExpandEnvironmentVar iables(env_query));

//System.Management - WMI Information
String strSQL = "SELECT * FROM Win32_LogicalDisk" ;
SelectQuery mgmt_query = new SelectQuery();
mgmt_query.QueryString = strSQL;
ManagementObjectSearcher searcher = new ManagementObjectSearcher(mgmt_query);
foreach(ManagementObject mo in searcher.Get())
{
if(mo["FreeSpace"] != null)
Console.WriteLine(mo["Name"].ToString() + " " +
mo["FreeSpace"].ToString());
}
Nov 16 '05 #5
GC
Will this work in a console app?

"Shiva" <sh******@online.excite.com> wrote in message
news:uc**************@TK2MSFTNGP11.phx.gbl...
Check the System.Windows.Forms.SystemInformation class...

"GC" <gc@gc.com> wrote in message
news:us**************@TK2MSFTNGP14.phx.gbl...
Hi,
How would I get various system settings through C# such as machine name,
hard drives, bytes free on hard drives, printers, etc...this is going to
be
from a simple console app. Thanks!

Nov 16 '05 #6
GC
n/m, just answered my own question. Thanks everyone for the help!
"GC" <gc@gc.com> wrote in message
news:eM**************@TK2MSFTNGP09.phx.gbl...
Will this work in a console app?

"Shiva" <sh******@online.excite.com> wrote in message
news:uc**************@TK2MSFTNGP11.phx.gbl...
Check the System.Windows.Forms.SystemInformation class...

"GC" <gc@gc.com> wrote in message
news:us**************@TK2MSFTNGP14.phx.gbl...
Hi,
How would I get various system settings through C# such as machine name,
hard drives, bytes free on hard drives, printers, etc...this is going to
be
from a simple console app. Thanks!


Nov 16 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: RBisch | last post by:
I am finding that some of the properties off of the PrinterSettings object are misleading For example, When I test the CanDuplex on a printer I know duplexes, the property is false. Another one...
2
by: Phil Stanton | last post by:
When designing a new form or report, the Default ForeColor is often something like -2147483640 which is the colour of Windows text (possibly black) and the default backColor is -2147483643...
1
by: Billy Hart | last post by:
I am getting this error on my win 2000 server when a .net app that a programmer in my office developed. I have read other posts about the issue but the resolutions to those posts did not solve the...
3
by: Juhan | last post by:
Hi! I have a strange error in a console application that is hosted by IIS 5.0 and invokes a web service hosted on the same machine. A request form the web comes in and it is dispatched to a...
2
by: Jeff | last post by:
Hey asp.net 2.0 My asp.net 2.0 project has got a assembly load problem: Some of my web.config settings: <membership defaultProvider="AH_MembershipProvider" userIsOnlineTimeWindow="15">
4
by: adi | last post by:
Hi I'm using .NET Framework 1.1 My application needs to read the system's language settings. How to do this? Thanks.
4
by: rsdev | last post by:
Hi, I have an InvalidCastException which is completely puzzling me. I have checked all the members in the stored procedure against my data provider and seems to be ok. Also in the stack trace it...
1
by: Pedro Dinis | last post by:
i have this class library that connects to the database(see appconfig below) compiling 0 errors but when its running i amhaving this error An unhandled exception of type...
3
brclancy111
by: brclancy111 | last post by:
Hello. I've been programming for 1 year now, and never saw this coming... When I try to use File.Exists("Data/Settings.dat") it does absolutely nothing. I am trying to build a system that...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.