09-22-2009, 03:37 PM
It doesn't seem to work for me.
Function SetProcessPriority2
I need to change the code for this so I can uncheck CPU 0 in the Set Affinity option but I couldn't find it in the msdn library.
Function SetProcessPriority2
;/
function hwnd priority [flags]
;Sets priority class of a process (running program).
;On failure generates error.
;hwnd - handle of some window of that process.
;flags - 1 hwnd is process id.
;priority - one of x_PRIORITY_x constants:
;;;def NORMAL_PRIORITY_CLASS 0x00000020 ;;normal, default
;;;def IDLE_PRIORITY_CLASS 0x00000040 ;;lowest
;;;def HIGH_PRIORITY_CLASS 0x00000080
;;;def REALTIME_PRIORITY_CLASS 0x00000100 ;;highest, dangerous
;;;def BELOW_NORMAL_PRIORITY_CLASS 0x00004000 ;;*
;;;def ABOVE_NORMAL_PRIORITY_CLASS 0x00008000 ;;*
;;;;* not supported on NT/98/Me
;EXAMPLES
;int hwnd=win("Notepad")
;SetProcessPriority hwnd IDLE_PRIORITY_CLASS
;;Eat all CPU time. Press Pause to stop.
;rep() int i=0
;;Try to work now in notepad...
;int pid=ProcessNameToId("notepad")
;if(!pid) end "the process is not running"
;SetProcessPriority pid BELOW_NORMAL_PRIORITY_CLASS 1
def PROCESS_SET_INFORMATION 0x0200
dll kernel32 #SetProcessAffinityMask hProcess dwPriorityClass
int pid ph ok
if(flags&1) pid=hwnd; else GetWindowThreadProcessId(hwnd &pid)
ph=OpenProcess(PROCESS_SET_INFORMATION 0 pid); if(!ph) goto g1
ok=SetProcessAffinityMask(ph priority)
;g1
if(!ok) _s.dllerror
if(ph) CloseHandle ph
if(!ok) end _s
I need to change the code for this so I can uncheck CPU 0 in the Set Affinity option but I couldn't find it in the msdn library.
;;;def NORMAL_PRIORITY_CLASS 0x00000020 ;;normal, default
;;;def IDLE_PRIORITY_CLASS 0x00000040 ;;lowest
;;;def HIGH_PRIORITY_CLASS 0x00000080
;;;def REALTIME_PRIORITY_CLASS 0x00000100 ;;highest, dangerous
;;;def BELOW_NORMAL_PRIORITY_CLASS 0x00004000 ;;*
;;;def ABOVE_NORMAL_PRIORITY_CLASS 0x00008000 ;;*
Taking on Quick Macros one day at a time