I hear you. But from what I can understand from the MSDN documentation the sequence of API calls required is :- Looks like there is no direct access to the thread of the PID I want, but by reading thru the whole list we can get there.
I'm no expert, but the difficulty is getting Win32::API to let me make all the calls I need to. At the moment I'm getting error code 24 (incorrect length) on Process32First. My code :-
$pid = 952; # 952 is a running job pid use threads; use threads::shared; 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"; $hProcessSnap = CreateToolhelp32Snapshot(TH32CS_SNAPTHREAD, 0); $retcode = GetLastError(); print "CreateToolhelp32Snapshot error code $retcode \n"; print "hProcessSnap = $hProcessSnap \n"; # typedef for PROCESSENTRY32 typedef Win32::API::Struct AA => qw{ DWORD dwSize; DWORD cntUsage; DWORD th32ProcessID; ULONG_PTR th32DefaultHeapID; DWORD th32ModuleID; DWORD cntThreads; DWORD th32ParentProcessID; LONG pcPriClassBase; DWORD dwFlags; TCHAR szExeFile[MAX_PATH]; }; $retcode = Win32::API->Import( 'Kernel32', q[BOOL Process32First( + HANDLE hSnapshot, LPAA lppe ) ] ); print "import process32first code $retcode \n"; $Point = Win32::API::Struct->new( 'AA' ); $Point->{dwSize}=Win32::API::Struct::sizeof( $Point ); Process32First($hProcessSnap, $Point); $retcode = GetLastError(); print "process32first error $retcode \n"; $retcode = Win32::API->Import( 'Kernel32', q[BOOL Process32Next( + HANDLE hSnapshot, LPAA lppe ) ] ); print "import process32next code $retcode \n"; until ( $Point->th32OwnerProcessID == $pid ) { Process32Next($hProcessSnap, $Point); $retcode = GetLastError(); print "process32next error code $retcode \n"; }
I get error 24 (incorrect length) on Process32First.

In reply to Re^12: 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.