.net 怎样检测详细硬件信息?

shine 2008-06-29 09:52:19
wmi获取的信息不全面,比如硬盘序列号就取不到,有的只是“修订号”(HWINFO32上显示的是“revision”)。
这些都没有关系,关键是获取不了内存的详细信息。比如:内存条数量,每条内存的容量、速度。有的只是可用物理内存总数(也就是除了显存之后的物理内存总数)。

有什么办法可以获得硬盘序列号、内存条数量,每条内存的容量、频率?
那些硬件检测软件都可以很详细地检测到,.net可以吗?怎么做?
...全文
508 8 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
rainbowsoftware 2008-07-01
  • 打赏
  • 举报
回复
wmi
哈哈哈啊002 2008-06-29
  • 打赏
  • 举报
回复
建议楼主找一下win32 api的相关信息。
摘自msdn:
DnsHostnameToComputerName Converts a DNS name to a NetBIOS name.
EnumSystemFirmwareTables Enumerates all system firmware tables of the specified type.
ExpandEnvironmentStrings Replaces environment-variable strings with their defined values.
GetComputerName Retrieves the NetBIOS name of the local computer.
GetComputerNameEx Retrieves the NetBIOS or DNS name of the local computer.
GetComputerObjectName Retrieves the local computer's name in a specified format.
GetCurrentHwProfile Retrieves the current hardware profile for the local computer.
GetFirmwareEnvironmentVariable Retrieves the value of the specified firmware environment variable from NVRAM.
GetKeyboardType Retrieves information about the current keyboard.
GetNativeSystemInfo Retrieves information about the current system for an application running under WOW64.
GetSysColor Retrieves the current color of a display element.
GetSystemDirectory Retrieves the path of the system directory.
GetSystemFirmwareTable Retrieves the specified firmware table from the firmware table provider.
GetSystemFileCacheSize Retrieves the current size limits for the working set of the system cache.
GetSystemInfo Retrieves information about the current system.
GetSystemMetrics Retrieves system metrics and configuration settings.
GetSystemRegistryQuota Retrieves the current size of the registry and the maximum size that the registry is allowed to attain on the system.
GetSystemWindowsDirectory Retrieves the path of the shared Windows directory on a multi-user system.
GetSystemWow64Directory Retrieves the path of the system directory used by WOW64.
GetUserName Retrieves the user name of the current thread.
GetUserNameEx Retrieves the name of the user or other security principal associated with the calling thread. You can specify the format of the returned name.
GetVersion Retrieves the version number of the operating system.
GetVersionEx Retrieves the version of the current operating system.
GetWindowsDirectory Retrieves the path of the Windows directory.
IsProcessorFeaturePresent Determines whether a processor feature is supported by the current computer.
IsWow64Message Determines whether the last message read from the queue of the current process originated from a WOW64 process.
IsWow64Process Determines whether a process is running under WOW64.
NtQuerySystemInformation Retrieves various kinds of system information.
SetComputerName Stores a new NetBIOS name for the local computer.
SetComputerNameEx Stores a new NetBIOS or DNS name for the local computer.
SetFirmwareEnvironmentVariable Sets the value of the specified firmware environment variable in NVRAM.
SetSysColors Sets the colors for one or more display elements.
SetSystemFileCacheSize Limits the size of the working set for the file system cache.
SystemParametersInfo Queries or sets system-wide parameters.
TranslateName Converts a directory service object name from one format to another.
VerifyVersionInfo Compares a set of version requirements to the values for the current operating system.
VerSetConditionMask Builds the condition mask for the VerifyVersionInfo function.
Wow64DisableWow64FsRedirection Disables file system redirection for the calling thread.
Wow64EnableWow64FsRedirection Enables or disables file system redirection for the calling thread.

足球中国 2008-06-29
  • 打赏
  • 举报
回复
my命名空间。
my.computer吧。有一些获取硬件信息函数和类
告诉告诉你一个源码。。柳善居有这样的一个源码。还不错。
搜柳善居可以搜到。
shine 2008-06-29
  • 打赏
  • 举报
回复
至少能获得物理内存总数(含动态显存)也好啊。
yanlongwuhui 2008-06-29
  • 打赏
  • 举报
回复
硬盘序列号还是不要考虑了吧,因为不是所有硬盘都能取到序列号的,另外硬盘的序列号的长度也不相同
shine 2008-06-29
  • 打赏
  • 举报
回复
我终于搞明白了,win2000里得不出我想要的那些东西,xp里就可以。
包括硬盘序列号、内存条数量,内存条容量。
不过内存类型(如sdram\ddr\ddr2)、频率也没有。wmi规范里有说明内存类型的字段的,但是xp试过不行。
另外,我觉得可以通过模拟写/读操作来计算频率。
CathySun118 2008-06-29
  • 打赏
  • 举报
回复
在.net环境下(用VC#描述)获取机器的硬件信息,要用到一个类库(System.Management.dll),在解决方案资源管理器中添加System.Management 即可
  我们可以将该程序编译成.dll文件,便于以后调用;
  在程序代码中进行引用 using System.Management;
  具体 代码为:
  1.获取机器名:
  public string GetHostName()
   {
   return System.Net.Dns.GetHostName();
   }
  2.获取CPU编号
  public string GetCpuId()
   {
   ManagementClass mc = new ManagementClass("Win32_Processor");
   ManagementObjectCollection moc = mc.GetInstances();
  
   String strCpuID = null ;
   foreach( ManagementObject mo in moc )
   {
   strCpuID = mo.Properties["ProcessorId"].Value.ToString();
   break;
   }
   return strCpuID;
   }
  3.获取主硬盘编号
  public string GetMainHardDiskId()
  {
   ManagementObjectSearcher searcher = new ManagementObjectSearcher("SELECT * FROM Win32_PhysicalMedia");
   String strHardDiskID = null ;
   foreach(ManagementObject mo in searcher.Get())
   {
   strHardDiskID = mo["SerialNumber"].ToString().Trim();
   break;
   }
   return strHardDiskID ;
  }
  4.获取bios和mac地址,这个有点复杂,需要用到NETAPI32.DLL

16,722

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧