Jump to content

get affinity not working?


Recommended Posts

I have a process set to run on cpu 1 and 3 (out of 4 virtual 'cores').

When I run the _WinAPI_GetProcessAffinityMask, It returns successful, but mask is 0 for any process.

#include <Process.au3>
#include <WinAPI.au3>
If ProcessExists("vlc.exe") Then
$list = ProcessList("vlc.exe")
For $i = 1 To $list[0][0]
$Priority = _ProcessGetPriority($list[$i][1])
$affiity = _WinAPI_GetProcessAffinityMask($list[$i][1])
MsgBox(0, $list[$i][0]&":"&$list[$i][1], "Priority:" & $Priority & @CRLF & "Success:" & $affiity[0] & @CRLF & "Proc Mask:" & $affiity[1] & @CRLF & "Sys Mask:" & $affiity[2])

Any ideas? I'm using windows 7 pro 32bit.

Link to comment
Share on other sites

You're calling the function with the PID, but you should call it with a process handle.

#include <Process.au3>
#include <WinAPI.au3>
$Priority = _ProcessGetPriority(@AutoItPID)
$hCurrentProcess = _WinAPI_GetCurrentProcess()
$affiity = _WinAPI_GetProcessAffinityMask($hCurrentProcess)
MsgBox(0, "", "Priority:" & $Priority & @CRLF & "Success:" & $affiity[0] & @CRLF & "Proc Mask:" & $affiity[1] & @CRLF & "Sys Mask:" & $affiity[2])

Look for examples on _WinAPI_OpenProcess() to obtain a process handle for other processes...

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...