找回密码
 加入
搜索
查看: 5120|回复: 8

[系统综合] (已解决)如何控制某进程占用的cpu%

  [复制链接]
发表于 2014-9-18 16:59:44 | 显示全部楼层 |阅读模式
本帖最后由 zb7512511 于 2014-10-20 09:39 编辑

现在 a.exe 在某些时候 cpu 达到100%
可以 指定它 cpu为20% 么?
怎么实现?
发表于 2014-9-19 08:26:34 | 显示全部楼层
那你可以检测 a.exe的cpu占用情况啊 100%后关闭
发表于 2014-9-19 09:46:52 | 显示全部楼层
回复 1# zb7512511

a.exe  是你寫的嗎??  如果不是  難喔

如果可以的話~~ 那豈不是 每個人 都可以控制別人寫的程式  ~~那不是亂了套
发表于 2014-9-19 18:28:16 | 显示全部楼层
如果是也难,这个多核的话估计还好实现一些,单核的话。。。。。你懂得
发表于 2014-9-20 08:35:18 | 显示全部楼层
如果編寫的是一些小程序,CPU佔用率一般都不會很多,
如果CPU佔用率過多,請再適當位置加入如下代碼
sleep(100)
可減少CPU的佔用率
发表于 2014-9-20 21:16:36 | 显示全部楼层
不断努力优化程序
 楼主| 发表于 2014-9-24 18:56:00 | 显示全部楼层
已解决
Func _ProcessSuspend($Process)
        $processid = ProcessExists($Process)
        If $processid Then
                $ai_Handle = DllCall("kernel32.dll", 'int', 'OpenProcess', 'int', 0x1f0fff, 'int', False, 'int', $processid)
                $i_sucess = DllCall("ntdll.dll", "int", "NtSuspendProcess", "int", $ai_Handle[0])
                DllCall('kernel32.dll', 'ptr', 'CloseHandle', 'ptr', $ai_Handle)
                If IsArray($i_sucess) Then
                        Return 1
                Else
                        SetError(1)
                        Return 0
                EndIf
        Else
                SetError(2)
                Return 0
        EndIf
EndFunc   ;==>_ProcessSuspend

Func _ProcessResume($Process)
        $processid = ProcessExists($Process)
        If $processid Then
                $ai_Handle = DllCall("kernel32.dll", 'int', 'OpenProcess', 'int', 0x1f0fff, 'int', False, 'int', $processid)
                $i_sucess = DllCall("ntdll.dll", "int", "NtResumeProcess", "int", $ai_Handle[0])
                DllCall('kernel32.dll', 'ptr', 'CloseHandle', 'ptr', $ai_Handle)
                If IsArray($i_sucess) Then
                        Return 1
                Else
                        SetError(1)
                        Return 0
                EndIf
        Else
                SetError(2)
                Return 0
        EndIf
EndFunc   ;==>_ProcessResume
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-4-26 21:29 , Processed in 0.080564 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表