| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 432 人关注过本帖
标题:为什么获取CPU序列号的时候会延迟2-3秒,有办法能缩短点时间吗?
只看楼主 加入收藏
wxflw
Rank: 6Rank: 6
等 级:侠之大者
帖 子:324
专家分:435
注 册:2012-1-29
结帖率:88.24%
收藏
已结贴  问题点数:20 回复次数:2 
为什么获取CPU序列号的时候会延迟2-3秒,有办法能缩短点时间吗?
Private Type OSVERSIONINFO
                  dwOSVersionInfoSize   As Long
                  dwMajorVersion   As Long
                  dwMinorVersion   As Long
                  dwBuildNumber   As Long
                  dwPlatformId   As Long
                  szCSDVersion   As String * 128                   '     Maintenance   string   for   PSS   usage
End Type
Private Declare Function GetVersionEx Lib "kernel32" Alias "GetVersionExA" (lpVersionInformation As OSVERSIONINFO) As Long
Private Declare Function GetComputerName Lib "kernel32" Alias "GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Private Const VER_PLATFORM_WIN32_NT = 2
Private Const VER_PLATFORM_WIN32_WINDOWS = 1
Private Const VER_PLATFORM_WIN32s = 0

Private Sub Command1_Click()
Dim len5 As Long, aa       As Long
          Dim cmprName As String
          Dim osver As OSVERSIONINFO
          Dim Computer As String
          Dim CPUs As Object
         
          '取得Computer   Name
          cmprName = String(255, 0)
          len5 = 256
          aa = GetComputerName(cmprName, len5)
          cmprName = Left(cmprName, InStr(1, cmprName, Chr(0)) - 1)
         
          Text2.Text = cmprName
          Computer = cmprName                     '取得CPU端口号
          Set CPUs = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & Computer & "\root\cimv2").ExecQuery("select   *   from   Win32_Processor")
          For Each MyCpu In CPUs                   '《《《《《====在这一句上停顿的时间太长
              Text1.Text = MyCpu.ProcessorId
          Next

End Sub
搜索更多相关主题的帖子: 办法 时间 序列号 
2012-11-29 15:52
mayuebo
Rank: 9Rank: 9Rank: 9
等 级:蜘蛛侠
威 望:6
帖 子:257
专家分:1282
注 册:2005-9-8
收藏
得分:14 
要查询每个CPU,现在是多核的要等到CPU分配到时间。
建议用其它办法获取。用WMI方式就比较慢。一般是先获取(在没有使用前+反应时间)

成功贵在坚持
2012-11-30 08:40
wxflw
Rank: 6Rank: 6
等 级:侠之大者
帖 子:324
专家分:435
注 册:2012-1-29
收藏
得分:0 
有什么其他方式呢?要防止使用第三方软件模拟CPU的ID,只能直接获取可能比较保险,什么方法指点一下,给个代码吧!

学习--------------学习-------------------学习--------------------!!
2012-11-30 09:12
快速回复:为什么获取CPU序列号的时候会延迟2-3秒,有办法能缩短点时间吗?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.019944 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved