I did get the code to work.. seems to me that details of threads of process x can indeed be changed from within process y - code follows :-
# set first thread for $pid to $hThreadPriority my $pid = 952; my $hThreadPriority = 0; my $retcode; my $hThreadSnap; my $hThread; my $Point; use Data::Dumper; use strict; use Win32::API; Win32::API->Import( 'Kernel32', q[ DWORD GetLastError( ) ] ); $retcode = Win32::API->Import( 'Kernel32', q[ HANDLE CreateToolhelp32Snapshot ( DWORD dwFlags, DWORD th32ProcessID ) ] ); print "import CreateToolhelp32Snapshot code $retcode \n"; use constant TH32CS_SNAPTHREAD => 0x4; $hThreadSnap=CreateToolhelp32Snapshot(TH32CS_SNAPTHREAD, 0); $retcode = GetLastError(); print "CreateToolhelp32Snapshot error code $retcode \n"; print "hThreadSnap = $hThreadSnap \n"; # typedef for THREADENTRY32 typedef Win32::API::Struct TE32 => qw{ DWORD dwSize; DWORD cntUsage; DWORD th32ThreadID; DWORD th32OwnerProcessID; LONG tpBasePri; LONG tpDeltaPri; DWORD dwFlags; }; $retcode = Win32::API->Import( 'Kernel32', q[ BOOL Thread32First ( HANDLE hSnapshot, LPTE32 lpte)]); print "import thread32first code $retcode \n"; $Point = Win32::API::Struct->new( 'TE32' ); $Point->{dwSize}=28; Thread32First($hThreadSnap, $Point); $retcode = GetLastError(); print "thread32first error $retcode \n"; print "pid = $Point->{th32OwnerProcessID} \n"; $retcode = Win32::API->Import( 'Kernel32', q[ BOOL Thread32Next ( HANDLE hSnapshot, LPTE32 lpte)]); print "import threadnext code $retcode \n"; until ( $Point->{th32OwnerProcessID} == $pid ) { Thread32Next($hThreadSnap, $Point); $retcode = GetLastError(); print "thread32next error $retcode \n"; print "pid = $Point->{th32OwnerProcessID} \n"; } $retcode = Win32::API->Import( 'Kernel32', q[HANDLE OpenThread( DWORD dwDesiredAccess, BOOL bInheritHandle, DWORD dwThreadId ) ] ); print "import openthread code $retcode \n"; use constant THREAD_SET_INFORMATION => 0x0020; use constant THREAD_QUERY_INFORMATION => 0x0040; $hThread = OpenThread( THREAD_SET_INFORMATION|THREAD_QUERY_INFORMATION, 0, $Point->{th32ThreadID} ); $retcode = GetLastError(); print "openthread error code $retcode \n"; $retcode = Win32::API->Import( 'Kernel32', q[BOOL SetThreadPriority( HANDLE hThread, int nPriority ) ] ); print "import openthread code $retcode \n"; SetThreadPriority( $hThread, $hThreadPriority ); $retcode = GetLastError(); print "setthreadpriority error code $retcode \n";

In reply to Re^16: how to change process & thread priority on Win32 ? by rbutcher
in thread how to change process & thread priority on Win32 ? by rbutcher

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.