Jump to content
Sign in to follow this  
Beomagi

get affinity not working?

Recommended Posts

Beomagi

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])
Next
EndIf

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

Share this post


Link to post
Share on other sites
KaFu

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...

Share this post


Link to post
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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.