Subj : getprocessaffinitymask To : borland.public.cpp.borlandcpp From : Jeff Kish Date : Wed Oct 01 2003 10:10 am Greetings. I am trying to write a small bit of code that will ensure that an application runs on only one processor (hyperthreading not withstanding). Unfortunately my code is failing to even get the process. Can someone make a comment here? This code keeps getting executed: MessageBox( "Exit Error", "OpenProcessToken() failed", MB_OK); is PROCESS_ALL_ACCESS the problem or something else? Thanks HANDLE hToken; LUID takeOwnershipValue; TOKEN_PRIVILEGES tkp; if (!OpenProcessToken(GetCurrentProcess(), PROCESS_ALL_ACCESS, &hToken)) { MessageBox( "Exit Error", "OpenProcessToken() failed", MB_OK); return; } DWORD dwProcessAM; DWORD dwSystemAM; BOOL BResult = GetProcessAffinityMask(hToken, // handle to the process of interest &dwProcessAM, // pointer to structure to receive process affinity mask &dwSystemAM); // pointer to structure to receive system affinity mask if (BResult == 0) { MessageBox("Unable to getprocessaffinitymask","cant continue",MB_OK); return; } char szMsg[2048]; sprintf(szMsg,"system am: %d, process am: %d",dwSystemAM,dwProcessAM); MessageBox(szMsg,szMsg,MB_OK); return; Jeff Kish .