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

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

有什么办法可以获得硬盘序列号、内存条数量,每条内存的容量、频率?
那些硬件检测软件都可以很详细地检测到,.net可以吗?怎么做?
...全文
555 8 打赏 收藏 转发到动态 举报
写回复
用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
于2024年4月-2025年9月期间,研究团队在贵州习水国家级自然保护区制定39条样线,涵盖灌木林、常绿阔叶林、针叶林、常绿落叶阔叶混交林、针阔混交林等不同植被类型,每条样线分春夏秋冬4个季节采集样品,用真菌采集软件记录经纬度、海拔、采集地点、时间、生境等信息,使用佳能相机(R6 mark Ⅱ)对大型真菌进行拍照,并采集标本,标本存放于贵州省生物研究所大型真菌标本馆(HGAMF)。 通过形态学初步鉴定,结合分子生物学最终鉴定,参考已]报道的中国毒蘑菇名录开展毒蘑菇的认定。 调查到保护区内有毒真菌7目25科64种,导致中毒的主要类型有急性肾衰竭型、神经精神型和胃肠炎型。最终形成贵州习水国家级自然保护区大型有毒真菌图片数据集,它由以下2个部分组成。 (1)附件1包含78张原始照片(.JPG),照片名字包括了大型有毒真菌的拉丁名和中文名,若无中文名的直接用拉丁名。 (2)附件2是一个压缩文件,包含了2张工作表,其中一张表是大型有毒真菌39条样线的信息,另一张表是大型有毒真菌的中毒类型。 照片采用佳能相机R6 mark Ⅱ拍摄,物种鉴定通过多种文献核实,并经两位以上专家鉴定确认。该数据集可为研究地及周边的普通人识别有毒大型真菌提供参考,通过及时的图片对比,能有效避免误采误食大型有毒真菌,同时为因误食大型真菌可能引发的身体损伤进行了总结,能为患者及时治疗提供参考。

16,718

社区成员

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

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