270分求这样一个小程序的编写方法
具体要求是每30秒检测一次CPU占用率如果CPU使用率低于10%则弹窗警报“CPU使用率”过低本人是编程菜鸟啦需要一个完整可编译的代码测试通过的,270分奉上...
具体要求是 每30秒检测一次CPU占用率
如果CPU使用率低于10% 则弹窗警报“CPU使用率”过低
本人是编程菜鸟啦
需要一个完整可编译的代码
测试通过的,270分奉上 展开
如果CPU使用率低于10% 则弹窗警报“CPU使用率”过低
本人是编程菜鸟啦
需要一个完整可编译的代码
测试通过的,270分奉上 展开
展开全部
窗体上放一个Timer,复制以下代码即可。
Private Declare Function PdhOpenQuery Lib "PDH.DLL" (ByVal Reserved As Long, ByVal dwUserData As Long, hQuery As Long) As PDH_STATUS
Private Declare Function PdhCloseQuery Lib "PDH.DLL" (ByVal hQuery As Long) As PDH_STATUS
Private Declare Function PdhVbAddCounter Lib "PDH.DLL" (ByVal QueryHandle As Long, ByVal CounterPath As String, CounterHandle As Long) As PDH_STATUS
Private Declare Function PdhCollectQueryData Lib "PDH.DLL" (ByVal QueryHandle As Long) As PDH_STATUS
Private Declare Function PdhVbGetDoubleCounterValue Lib "PDH.DLL" (ByVal CounterHandle As Long, CounterStatus As Long) As Double
Private Type CounterInfo
hCounter As Long
strName As String
End Type
Private Enum PERF_DETAIL
PERF_DETAIL_ADVANCED = 200
End Enum
Private Enum PDH_STATUS
PDH_CSTATUS_VALID_DATA = &H0
PDH_CSTATUS_NEW_DATA = &H1
End Enum
Dim hQuery As Long, Counters As CounterInfo, dblCounterValue As Double, PdhStatus As Long
Private Function GetCpu() As Double
PdhCollectQueryData hQuery
GetCpu = PdhVbGetDoubleCounterValue(Counters.hCounter, PdhStatus)
End Function
Private Sub Form_Load()
Dim hCounter As Long
PdhOpenQuery 0, 1, hQuery
PdhVbAddCounter hQuery, "\Processor(0)\% Processor Time", hCounter
Counters.hCounter = hCounter
Counters.strName = strCounterName
Me.Hide
Timer1.Interval = 30 * 1000 '检测周期
End Sub
Private Sub Form_Unload(Cancel As Integer)
PdhCloseQuery hQuery
End Sub
Private Sub Timer1_Timer()
If GetCpu < 10 Then '最低使用率
MsgBox "CPU使用率过低"
End If
End Sub
Private Declare Function PdhOpenQuery Lib "PDH.DLL" (ByVal Reserved As Long, ByVal dwUserData As Long, hQuery As Long) As PDH_STATUS
Private Declare Function PdhCloseQuery Lib "PDH.DLL" (ByVal hQuery As Long) As PDH_STATUS
Private Declare Function PdhVbAddCounter Lib "PDH.DLL" (ByVal QueryHandle As Long, ByVal CounterPath As String, CounterHandle As Long) As PDH_STATUS
Private Declare Function PdhCollectQueryData Lib "PDH.DLL" (ByVal QueryHandle As Long) As PDH_STATUS
Private Declare Function PdhVbGetDoubleCounterValue Lib "PDH.DLL" (ByVal CounterHandle As Long, CounterStatus As Long) As Double
Private Type CounterInfo
hCounter As Long
strName As String
End Type
Private Enum PERF_DETAIL
PERF_DETAIL_ADVANCED = 200
End Enum
Private Enum PDH_STATUS
PDH_CSTATUS_VALID_DATA = &H0
PDH_CSTATUS_NEW_DATA = &H1
End Enum
Dim hQuery As Long, Counters As CounterInfo, dblCounterValue As Double, PdhStatus As Long
Private Function GetCpu() As Double
PdhCollectQueryData hQuery
GetCpu = PdhVbGetDoubleCounterValue(Counters.hCounter, PdhStatus)
End Function
Private Sub Form_Load()
Dim hCounter As Long
PdhOpenQuery 0, 1, hQuery
PdhVbAddCounter hQuery, "\Processor(0)\% Processor Time", hCounter
Counters.hCounter = hCounter
Counters.strName = strCounterName
Me.Hide
Timer1.Interval = 30 * 1000 '检测周期
End Sub
Private Sub Form_Unload(Cancel As Integer)
PdhCloseQuery hQuery
End Sub
Private Sub Timer1_Timer()
If GetCpu < 10 Then '最低使用率
MsgBox "CPU使用率过低"
End If
End Sub
杭州一知智能科技有限公司
2022-03-17 广告
2022-03-17 广告
电话机器人主要就是用来模拟人工通话的一组程序,一般由,CRM系统,语义识别,转换文字,话术体系,这是软的部分,再加上底层软交换和通信模块一起,合并起来就是一套完整的电话机器人系统。电话机器人可以代替真人进行电话工作的,像是电话营销、售后回访...
点击进入详情页
本回答由杭州一知智能科技有限公司提供
展开全部
http://zhidao.baidu.com/question/66902243.html
把 Me.Caption = "当前CPU占用率:" & GetCPUUsage & "%"
改成
if GetCPUUsage<10 then
MsgBox "CPU使用率过低", vbCritical, "警告"
end if
直接添加不行 直接添加可能永远都不会提示
上面的代码在整段代码最下面
把 Me.Caption = "当前CPU占用率:" & GetCPUUsage & "%"
改成
if GetCPUUsage<10 then
MsgBox "CPU使用率过低", vbCritical, "警告"
end if
直接添加不行 直接添加可能永远都不会提示
上面的代码在整段代码最下面
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
看不明白,过低还需要警报.再说,这个问题虽然好解决,但在这里没人给你说的,你上编程网站去发,有可能有人免费为你写一个.
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询