Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
Since the OP is wanting to distribute the code, it becomes necessary to ensure that Inline::C is installed on the target machines (or other appropriate action taken).

I would therefore probably take the code that BrowserUk provided and turn it into a standalone module - which could be distributed in either source or pre-built (binary) form.
First, create a directory ./Win32-ThreadID-0.01 and a file ./ThreadID.c; where ThreadID.c contains the following section of BrowserUk's code:
#include <windows.h> #define IS_VARS Inline_Stack_Vars #define IS_RESET Inline_Stack_Reset #define IS_PUSHIV( iv ) Inline_Stack_Push( sv_2mortal( newSViv( iv ) ) + ) #define IS_PUSHUV( uv ) Inline_Stack_Push( sv_2mortal( newSVuv( uv ) ) + ) #define IS_DONE Inline_Stack_Done void getWindowThreadProcessId( SV* hwnd ) { IS_VARS; DWORD pid; DWORD tid = GetWindowThreadProcessId( (HWND)SvUV(hwnd), &pid ); IS_RESET; IS_PUSHUV( tid ); IS_PUSHUV( pid ); IS_DONE; return; }
Then run this script:
use warnings; use strict; use InlineX::C2XS qw(c2xs); my $mod = 'Win32::ThreadID'; my $pkg = $mod; my $build_dir = './Win32-ThreadID-0.01'; c2xs($mod, $pkg, $build_dir, {WRITE_PM => 1, WRITE_MAKEFILE_PL => 1, VERSION => '0.01', MANIF => 1, SRC_LOCATION => './ThreadID.c', EXPORT_OK_ALL => 1, });
That will create a Win32-ThreadID-0.01 source distro in the Win32-ThreadID-0.01 directory - complete with, ThreadID.xs, Makefile.PL, INLINE.h and MANIFEST, where exports (upon request) the getWindowThreadProcessId function. That distro as it then stands is already buildable and installable - though there's yet no test script (which would have to be added by hand, if desired).

Hmmm .... come to think of it, an option to generate a test script (that simply tests the loadability of the module) might be a useful addition to InlineX::C2XS ...


In reply to Re^2: Using GetWindowThreadProcessId(). Want to move to AS 5.16 64bit Perl, but Win32::GUI doesn't build. Now what? by syphilis
in thread Using GetWindowThreadProcessId(). Want to move to AS 5.16 64bit Perl, but Win32::GUI doesn't build. Now what? by KalTorak

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, 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, 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.
  • Log In?

    What's my password?
    Create A New User
    and all is quiet...

    How do I use this? | Other CB clients
    Other Users?
    Others having an uproarious good time at the Monastery: (5)
    As of 2017-11-23 00:19 GMT
    Find Nodes?
      Voting Booth?
      In order to be able to say "I know Perl", you must have:

      Results (327 votes). Check out past polls.