Lyle Kopnicky wrote:

> Hi folks,
> 
> What's the easiest way to access a Win32 function from perl, if it isn't 
> supported by some existing library?
> 
> For example, I want to use the function ProcessIdToSessionId, one of the 
> Windows Terminal Services functions, that isn't provided by Win32::Lanman.
> 
> I haven't written any XS code yet.  Is the easiest thing to write a 
> simple XS module?  Or to modify the Win32::Lanman code to add it in there?
> 
> It looks like Win32::Lanman defines an AUTOLOAD function.  It seems that 
> could be used to load almost any Win32 function, if you had a table of 
> parameter types.  I'm not well-versed enough in XS or Win32 to 
> understand how the Win32::Lanman module works yet.

Something similar to this should work:

use strict;
use warnings;
use Win32::API;

Win32::API->Import('kernel32',
  'BOOL ProcessIdToSessionId (DWORD dwProcessId, LPDWORD pSessionId)') or
  die "Import ProcessIdToSessionId: $^E";

my $dwProcessId = $$;
my $pSessionId = 0;

my $ret = ProcessIdToSessionId ($dwProcessId, $pSessionId);

printf "ret='%u'; SessionId='%u'\n", $ret, $pSessionId;

__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-Admin mailing list
Perl-Win32-Admin@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to