Forum Discussion
Dmitry_Nikolaev
14 years agoStaff
Hi John,
AFAIK, this function involves calling the SetProcessAffinityMask API function to set the affinity and the OpenProcess function to obtain the target process handle. There's a problem with this - JScript/C#Script/C++Script cannot call functions that accept pointers as parameters. Such parameters should be passed by a reference, which is unsupported in JScript.
If you need to set the affinity from your JScript code, I suggest that you try using the following function:
function SetProcessAffinity(app, affinity)
{
var affinityPtr = dotNET.System.IntPtr.zctor(affinity);
var process = dotNET.System_Diagnostics.Process.GetProcessById(app.ProcessID);
process.ProcessorAffinity = affinityPtr;
}
...
var app = Sys.Process("MyApp");
SetProcessAffinity(app, 1);
...
To make this function work, you need to add the System.dll assembly to the list of available assemblies in the project's CLR Bridge property (Project Explorer | <double-click your project>| Properties | CLR Bridge).
Does this help?
Related Content
Recent Discussions
- 58 minutes agoSvetaG