|
hi
I need the C# code for the following:
I am using windows OS.
1)How to get the details of a machine, if we know the machine name or IP address
Details include : BIOS version, boot time, name of user who has logged in, hard disk drive(size of each partition), model of the machine, CPU(processor details), OS Version, network cards, etc.
2)How to detect the softwares installed and their version. This means where the keys are added in the registry and how to get it back?
3)How to detect the various hardwares installed or plugged into a machine?
I know all these are related to Registry.
Please give a detailed reply, ASAP.
Thanks,
SYAMLAL
|
|
|
|
|
Hi,
1- For machine details U can get what ever information u need using WMI (Windows Management Instrumentation). For example if u want all information about the CPU here is the code :
string cpuInfo = String.Empty;
ManagementClass mc = new ManagementClass("Win32_Processor");
ManagementObjectCollection moc = mc.GetInstances();
foreach (ManagementObject mo in moc)
{
if (cpuInfo == String.Empty)
{// only return cpuInfo from first CPU
IEnumerator enumer = mo.Properties.GetEnumerator();
while (enumer.MoveNext())
PropName = ((PropertyData)enumer.Current).Name;
PropValue =((PropertyData)enumer.Current).Value;
}
}
Of course u must add a reference to System.Management namespace in ure project.
Fore more information about WMI visit this link : http://aspalliance.com/629[^]
2/ To retieve installed software here some code :
public static void GetInstalledSofts()<br />
{<br />
string uninstallKey = @"Software\Microsoft\Windows\CurrentVersion\Uninstall";<br />
RegistryKey key = Registry.LocalMachine.OpenSubKey(uninstallKey);<br />
if (key == null)<br />
{<br />
System.Console.WriteLine("Unable to open registry key {0}.", uninstallKey);<br />
return;<br />
}<br />
<br />
ArrayList list = new ArrayList();<br />
string[] subkeyNames = key.GetSubKeyNames();<br />
foreach(string subkey in subkeyNames)<br />
{<br />
RegistryKey sk = key.OpenSubKey(subkey);<br />
string prodName;<br />
string uninstallString = (string)sk.GetValue("UninstallString");<br />
string displayVersion = (string)sk.GetValue("DisplayVersion");<br />
string productCode = string.Empty;<br />
<br />
if (subkey[0] == '{')<br />
{<br />
productCode = subkey;<br />
prodName = (string)sk.GetValue("DisplayName");<br />
if (prodName == null) prodName = string.Empty;<br />
}<br />
else <br />
{<br />
prodName = subkey;<br />
}<br />
<br />
}
3- Use WMI to list hardware
HTH
|
|
|
|
|
hi Hayder Marzouk,
Thanks for the help.
Let me check the details that u have given,
I will send mails in case any more help is needed,,
Once again , thanks
SYAMLAL
|
|
|
|
|
Dear All,
How to make sure that controls on the form do not change their location when Form scroll event occurs ? I am having a form and I drag and drop a textbox in it. I enable the scroll event of the form. Now when ever I scroll up/down the textbox control is changing its location i,e. its co-ordinates X and Y.
I am writing the following code snippet in the scroll event,
private void Form1_Scroll(object sender, ScrollEventArgs e)
{
textBox1.Text = textBox1.Location.ToString();
textBox2.Text = textBox2.Location.ToString();
textBox3.Text = textBox3.Location.ToString();
}
Please help me in solving this problem.
Thanx
|
|
|
|
|
Mr Perfect wrote: textBox1.Text = textBox1.Location.ToString();
textBox2.Text = textBox2.Location.ToString();
textBox3.Text = textBox3.Location.ToString();
Here you are not changing the position of the text box. You are just assigning the location to the text property. If you want that the text box should not move even when the scroll bar is scrolled, try to change the location of the text box in the same event. Please check the ScrollEventArgs for the new value of the scroll bar, using which you can change the location of the text boxes.
"A good programmer is someone who looks both ways before crossing a one-way street." -- Doug Linder
coolestCoder
|
|
|
|
|
I want the location of the textbox to remain same(fixed), whenever the scroll event occurs.
|
|
|
|
|
Hi,
I got your point already. You dont want the text boxes to be scrolled out of the screen. correct ? Thats why you will need to change the location of the text boxes according to the new values of the scroll bar. In this way your text boxes will appear as if "Fixed"
"A good programmer is someone who looks both ways before crossing a one-way street." -- Doug Linder
coolestCoder
|
|
|
|
|
Hi,
Is it possible to change the priority of the message that is already exists in the Message Queue. Direct APIs are provided to set the priority while posting in to the MSMQ, But I couldn't find out the way to change the priority of the message that already exists in the queue.
Please help me out regarding this.
thanks,
Sree
|
|
|
|
|
Hello all,
I am using a vertical scroll bar. During the runtime, I want the form to be scrolled according to the scroll bar.
Thanks in advance.
Keshav Kamat
India
|
|
|
|
|
You might want to take a look at the AutoScroll property of the form itself as this provides the functionality you're looking for.
|
|
|
|
|
well thanks. i got it.
Keshav Kamat
India
|
|
|
|
|
i need a function like it sholud delete all special characters and spaces in the given name ony a to z and numbers 0 to 9 has to come plz help me out
suresh
Suresh.R
|
|
|
|
|
Hi,
Use the ToCharArray method of the string and check whether each of the characters is numeric, special character or something else... as simple as it sound to be.
"A good programmer is someone who looks both ways before crossing a one-way street." -- Doug Linder
coolestCoder
|
|
|
|
|
Use a regular expression -- [a-z][0-9]
only two letters away from being an asset
|
|
|
|
|
Hello,
I'm trying to write a binary file stored in Access DB (an exe) and when I'm writing it I'm getting something like "binary binary binary..." before the real file content and therefore I'm having the file corrupted.
Please help.
|
|
|
|
|
Hi,
I think somewhere in ure code u are writing ToString() with the variable containing the binary data.
Post ure code to see what's wrong.
HTH.
|
|
|
|
|
Hi,
I am using VS 2003 and create a multi file assemble dll using csc /t:library /out:mydll /addmodule:M1.netmodule,M2.netmodule
the application works fine but I can not use in my IDE namespace.classname.memberfunction
to show what libaries and memeberfunctions(arguments) I can use in the dll like in a sigle file assembly. Anyway to get around with it?
Thanks
|
|
|
|
|
Hi,
Is there any possible way to format the column headings of Dataset in C#? Formatting in the sense, making the column headings as bold or setting the column width etc? Any help in this regard is greatly appreciated.
Thanks in advance.
Meeram395
|
|
|
|
|
raja_raman wrote: column headings as bold
I think you can set datagrid properties to do this
|
|
|
|
|
Hi Rajaraman
DataSet is a class, instance of DataSet just can hold values which is different from how you are going to display.
Massaging of look and feel is purely depends on the application type (Web, Windows or others)
In web application you can use styles and in win forms either by properties or overriding paint method of the controls.
M.Sendilkumar,Thomson,Bangalore,India
|
|
|
|
|
Dear All,
I want to draw a circle generation using the center point and a radius.
Can anybody suggest a good algorithm r code to compute the values and later will convert to motion to draw in a paper.
Thanks in advance
|
|
|
|
|
You can just use trig to calculate the pixels. Why can't you just use the API that draws a circle ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
After i compute the values which generates circle i will transform into motion control signals to move the x & y motors in a circular form.
|
|
|
|
|
Hi,
I have written an Excel VBA application which has a number of sheets
with a grid of horizontal and vertical values. For example, one sheet
has 200 people horizontal cells and 300 vertical cells. Each of the
200x300 cells may have a value, which may be text, checkbox or
combobox. There a number of sheets relating to people, with the
vertical cells on each sheet relating to different categories.
I want to replicate this grid behaviour in both a WinForms and a local
ASP.NET application.
I would prefer to only use Excel when the user wants to export the
results back to a spreadsheet and not in the data updating process.
I see that there are a few spreadsheet controls out there (like
spreadsheetgear.com) that allow users to use an Excel-like control
inside a WinForms or ASP application. These controls do not allow
check boxes and combo boxes in cells.
Also, places like telerik.com sell all sorts of controls, including
grid controls which look useful.
I wanted some advice about what people think is the best way of going
about this task, preferably with examples or links. Links to
commercial controls are ok, as well as codeproject links.
Regards
excelthoughts
|
|
|
|
|
Hello All,
I need to create a template field in gridview with table of one column repeating as 5 columns. Any ideas and suggestions guys. Cheers, Shilpa.
Something like this.
ProductImage productImage productImage productImage productImage
ProductName ProductName ProductName ProductName ProductName
Price price price price price
I have tried this in templatefield of gridview but the data is showing as one column
" width="100" height="100" border="0"> | | $<%# Eval("Price") %> | | <%# Eval("ProductName") %> | |
protected
void DisplayProducts(int cid)
{
DataSet ProductList = new DataSet() ;
string cmd = "StoredprocedureName" + cid;
ProductList = a.SelectDSQuery(cmd);
GridView1.DataSource = ProductList;
GridView1.DataBind();
}
Thanks in Advance for your help. Best Regards
|
|
|
|