Jeremy A wrote:
> Hi all,
> 
> I have a Win32 API problem.
> 
> 
> This is what I found in the MSDN:
> ----------------------------------------
> Syntax:
> DWORD GetWindowThreadProcessId(          HWND hWnd,
>     LPDWORD lpdwProcessId
> );
> 
> Parameters
> hWnd
> [in] Handle to the window.
> 
> lpdwProcessId
> [out] Pointer to a variable that receives the process identifier. If this 
> parameter is not NULL, GetWindowThreadProcessId copies the identifier of 
> the process to the variable; otherwise, it does not.
> 
> Return Value
> The return value is the identifier of the thread that created the window.
> -----------------------------------------------
> 
> i am new to using perl's Win32::API module and the Win32 API.
> 
> how do i get the lpdwProcessId in perl?
> 
> right now, i am getting blank's and funny char's.
> 
> eg, the following is my code,
> 
>               my $GetWindowThreadProcessId = new Win32::API("user32", 
> "GetWindowThreadProcessId", [N,P], 'N');
>               my $PID = $GetWindowThreadProcessId->Call($HWND,$PP);
> 
>               print $PP;

First you have to get the window handle, then use that on your next call :

use strict;
use Win32::API;

my $FindWindow = new Win32::API('USER32', 'FindWindow', [qw(P P)], 'I') or
  die "FindWindow: $!";
my $hWnd = $FindWindow->Call(0, 0);
print "hWnd=$hWnd\n";

my $GetWindowThreadProcessId = new Win32::API('user32',
  'GetWindowThreadProcessId', [qw(N P)], 'N') or
  die "GetWindowThreadProcessId: $!";

my $lpdwProcessId = pack 'L', 0;
my $ret = $GetWindowThreadProcessId->Call($hWnd, $lpdwProcessId) or
  die "GetWindowThreadProcessId->Call: $!";
my $PP = unpack 'L', $lpdwProcessId;
print "ret=$ret; PP=$PP\n";;

__END__



-- 
  ,-/-  __      _  _         $Bill Luebkert    Mailto:[EMAIL PROTECTED]
 (_/   /  )    // //       DBE Collectibles    Mailto:[EMAIL PROTECTED]
  / ) /--<  o // //      Castle of Medieval Myth & Magic http://www.todbe.com/
-/-' /___/_<_</_</_    http://dbecoll.tripod.com/ (My Perl/Lakers stuff)
_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to