| | |
Opening a notepad file
Please support our C# advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Mar 2006
Posts: 16
Reputation:
Solved Threads: 0
This is my first attempt ever at a program in C#. Here's what I have so far:
I want this program to grab these registry keys and place them into a notepad file. Right now all it does is open a dos window and place them in there. How can I go about getting them to open notepad and place them in there?
C# Syntax (Toggle Plain Text)
using System; using Microsoft.Win32; class reg { static void Main() { RegistryKey hklm =Registry.LocalMachine; hklm=hklm.OpenSubKey("HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0"); Object obp=hklm.GetValue("Identifier"); Console.WriteLine("Processor Identifier:{0}",obp); RegistryKey hklp =Registry.LocalMachine; hklp=hklp.OpenSubKey("HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0"); Object obc=hklp.GetValue("VendorIdentifier"); Console.WriteLine("Vendor Identifier:{0}",obc); RegistryKey biosv =Registry.LocalMachine; biosv=biosv.OpenSubKey("HARDWARE\\DESCRIPTION\\System\\MultiFunctionAdapter\\4"); Object obv=biosv.GetValue("Identifier"); Console.WriteLine("Bios Status:{0}",obv); RegistryKey biosd =Registry.LocalMachine; biosd=biosd.OpenSubKey("HARDWARE\\DESCRIPTION\\System\\"); Object obd=biosd.GetValue("SystemBiosDate"); Console.WriteLine("Bios Date:{0}",obd); RegistryKey bios =Registry.LocalMachine; bios=bios.OpenSubKey("HARDWARE\\DESCRIPTION\\System\\"); Object obs=bios.GetValue("Identifier"); Console.WriteLine("System Identifer:{0}",obs); string x = Console.ReadLine(); } }
I want this program to grab these registry keys and place them into a notepad file. Right now all it does is open a dos window and place them in there. How can I go about getting them to open notepad and place them in there?
Here is a small windows application that I threw together. It is just a modification of your code. It saves each value into the text file. Then opens it in notepad.
I hope thats what you meant.
-T
C# Syntax (Toggle Plain Text)
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.Diagnostics; using System.IO; using Microsoft.Win32; namespace NP_TEST { public partial class Form1 : Form { StreamWriter sw = new StreamWriter("C:\\SysInfo"); public Form1() { InitializeComponent(); RegistryKey hklm = Registry.LocalMachine; hklm = hklm.OpenSubKey("HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0"); Object obp = hklm.GetValue("Identifier"); sw.WriteLine("Processor Identifier: " + obp); RegistryKey hklp = Registry.LocalMachine; hklp = hklp.OpenSubKey("HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0"); Object obc = hklp.GetValue("VendorIdentifier"); sw.WriteLine("Vendor Identifier: ", obc); RegistryKey biosv = Registry.LocalMachine; biosv = biosv.OpenSubKey("HARDWARE\\DESCRIPTION\\System\\MultiFunctionAdapter\\4"); Object obv = biosv.GetValue("Identifier"); sw.WriteLine("Bios Status: ", obv); RegistryKey biosd = Registry.LocalMachine; biosd = biosd.OpenSubKey("HARDWARE\\DESCRIPTION\\System\\"); Object obd = biosd.GetValue("SystemBiosDate"); sw.WriteLine("Bios Date: ", obd); RegistryKey bios = Registry.LocalMachine; bios = bios.OpenSubKey("HARDWARE\\DESCRIPTION\\System\\"); Object obs = bios.GetValue("Identifier"); sw.WriteLine("System Identifer:{0}", obs); sw.Close(); Process notePad = new Process(); notePad.StartInfo.FileName = "notepad.exe"; notePad.StartInfo.Arguments = "C:\\SysInfo"; notePad.Start(); } } }
I hope thats what you meant.
-T
Firefox
Ewido
Tune up windows
Get detailed system information
My Fixes
Member - Alliance of Security Analysis Professionals - Since 2006
Ewido
Tune up windows
Get detailed system information
My Fixes
Member - Alliance of Security Analysis Professionals - Since 2006
Then just use this code.
Thats all you need.
•
•
•
•
RegistryKey hklm = Registry.LocalMachine;
hklm = hklm.OpenSubKey("HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0");
Object obp = hklm.GetValue("Identifier");
sw.WriteLine("Processor Identifier: " + obp);
RegistryKey hklp = Registry.LocalMachine;
hklp = hklp.OpenSubKey("HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0");
Object obc = hklp.GetValue("VendorIdentifier");
sw.WriteLine("Vendor Identifier: ", obc);
RegistryKey biosv = Registry.LocalMachine;
biosv = biosv.OpenSubKey("HARDWARE\\DESCRIPTION\\System\\MultiFunctionAdapter\\4");
Object obv = biosv.GetValue("Identifier");
sw.WriteLine("Bios Status: ", obv);
RegistryKey biosd = Registry.LocalMachine;
biosd = biosd.OpenSubKey("HARDWARE\\DESCRIPTION\\System\\");
Object obd = biosd.GetValue("SystemBiosDate");
sw.WriteLine("Bios Date: ", obd);
RegistryKey bios = Registry.LocalMachine;
bios = bios.OpenSubKey("HARDWARE\\DESCRIPTION\\System\\");
Object obs = bios.GetValue("Identifier");
sw.WriteLine("System Identifer:{0}", obs);
sw.Close();
Process notePad = new Process();
notePad.StartInfo.FileName = "notepad.exe";
notePad.StartInfo.Arguments = "C:\\SysInfo";
notePad.Start();
Firefox
Ewido
Tune up windows
Get detailed system information
My Fixes
Member - Alliance of Security Analysis Professionals - Since 2006
Ewido
Tune up windows
Get detailed system information
My Fixes
Member - Alliance of Security Analysis Professionals - Since 2006
![]() |
Similar Threads
- Front Page error when opening .HTM file (HTML and CSS)
- ENCRYPTION AND DECRYPTION - How to disable the File menu in a Notepad or any file (VB.NET)
- help! applications opening on notepad (Windows NT / 2000 / XP)
- Output to text (notepad) file (HTML and CSS)
Other Threads in the C# Forum
- Previous Thread: C# Classes
- Next Thread: i need help...syntax error
| Thread Tools | Search this Thread |
.net 2007 access ado.net algorithm array barchart bitmap box broadcast buttons c# camera check checkbox client color combobox control conversion cs4 csharp custom database datagrid datagridview dataset date datetime degrees development draganddrop drawing encryption enum event eventcloseformc# excel file form format forms function gdi+ httpwebrequest image index input install java label list listbox listener listview load mandelbrot math mouseclick mysql operator path photoshop picturebox pixelinversion post programming radians regex remote remoting richtextbox search security serialization server sleep socket sql statistics stream string table text textbox thread time timer update usercontrol validation view visual visualstudio webbrowser windows winforms wordautomation wpf xml






