在C#中获取系统信息 [英] Getting system information in c#
问题描述
<小>
制作项目及其一部分涉及到将其配置为试用版,直到用户购买了许可证.许可证密钥是在获取系统硬件并进行一些转换后生成代码之后生成的.如果有人可以帮助我展示如何使用c#代码获取唯一的标准硬件信息,我将不胜感激.我在c ++中见过一个,但是我对c ++一无所知,所以我更喜欢纯c#代码,但是如果我必须引用一些c ++类,那么只要您能带我看看,它就可以了.
Am making a project and part of it involves configuring it to be a trial version until the user has purchased the licence. The licence key is generated after getting the system hardware and generating a code after doing some conversions. I would be grateful if anyone could help show me how to get unique standard hardware information using c# code. I''ve seen one in c++ but I know nothing about c++ so i''d prefer pure c# code but if I have to reference some c++ classes then its ok as long as you pls show me around.
推荐答案
如何使用c#代码获取唯一的标准硬件信息.
好的.您需要使用WMI(Windows管理规范)
看看这篇文章:
使用C#和WMI收集硬件信息 [ ^ ]
另外,看看这个:
获取硬件信息 [ ^ ]
在VB.NET中.但是应该足以让您前进. (一个人可以使用免费的转换器轻松地将其转换为C#,并手动解决错误(如果有的话).)
how to get unique standard hardware information using c# code.
Ok. You need to use WMI (Windows Management Instrumentation)
Have a look at this article:
Collecting Hardware Information using C# and WMI[^]
Also, look at this one:
Getting Hardware Information[^]
It''s in VB.NET. But should be enough to get you going. (One can easily convert it to C# using free converters and manually resolving error if any.)
希望这对您有所帮助...
--------------------------------
I hope this may help you out...
--------------------------------
using System.Data;
using Microsoft.Win32;
private void Form1_Load(object sender, System.EventArgs e)
{
try
{
label18.Text = SystemInformation.PrimaryMonitorSize.ToString();
label2.Text = System.Environment.SystemDirectory;
label4.Text = System.Environment.MachineName;
label6.Text = System.Environment.WorkingSet.ToString();
int q = System.Environment.TickCount;
int w = (q/1000)/60;
label8.Text = w.ToString() + " Minute(s)";
label10.Text = System.Environment.OSVersion.ToString();
label12.Text = System.Environment.Version.ToString();
label14.Text = System.Environment.UserName;
label16.Text = System.Environment.UserDomainName;
RegistryKey Rkey = Registry.LocalMachine;
Rkey = Rkey.OpenSubKey("HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0");
label20.Text = (string)Rkey.GetValue("ProcessorNameString");
}
catch (Exception EX)
{
MessageBox.Show("The Following ERROR Occur ..." + EX.Message.ToString());
}
}
-------------------------------------------------- -------------------
您得到正确的结果了吗?
---------------------------------------------------------------------
Did you get the correct result?
这篇关于在C#中获取系统信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!