Curufin said:
Hi,
Is there a simple way for a perl process to change its own priority on Win32
?
From what I understand Win32:

rocess works only on child processes and
getpriority()/setpriority() are not available on Win32.
Win32:

rocess is the right module. Use something like this:
use Win32;
use Win32:

rocess;
my(%PVal) = (
IDLE => IDLE_PRIORITY_CLASS,
HIGH => HIGH_PRIORITY_CLASS,
NORMAL => NORMAL_PRIORITY_CLASS,
REALTIME => REALTIME_PRIORITY_CLASS,
);
sub SetOwnProcessPriority {
my($prio) = @_;
my($obj);
Win32:

rocess::Open($obj, $$, 0);
unless ($obj) {
print "error creating Win32:

rocess object",
Win32::FormatMessage(Win32::GetLastError());
return;
}
unless ( $obj->SetPriorityClass($PVal{$prio}) ) {
print "error setting process priority $prio\n",
Win32::FormatMessage(Win32::GetLastError());
return;
}
print "successfully set process priority to $prio\n";
}
then you can use:
SetOwnProcessPriority('IDLE');
somewhere in your script.
Thomas