Question:
Is there a way to make my application run on one processor of a multiprocessor machine?
Answer:
Yes. Here are a couple ways you can set process affinity. The first is done while your application is running. Go into the Task Manager and click the Processes tab. Right click on your process and choose Set Affinity. Clear either CPU0 or CPU1.
The second is done in code. Here is an example of setting and getting process affinity:
procedure TForm1.Button1Click(Sender: TObject);
var
vHandle : Cardinal;
vMaskProcess, vMaskSystem : cardinal;
begin
vHandle := Form1.Handle;
SetProcessAffinityMask(vHandle, 0); // or 1
GetProcessAffinityMask(vHandle, vMaskProcess, vMaskSystem);
showmessage(inttostr(vMaskProcess));
showmessage(inttostr(vMaskSystem));
end;
Last Modified: 17-MAY-01