----- Original Message -----
From: "Peterson, Barry (STP)" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Wednesday, October 12, 2005 12:03 AM
Subject: "require" Win32::API
Hi,
I'm writing a module that will sometimes be used on Windows, and sometimes
used on Linux.
Unfortunately, on Windows, I need to be able to get the Process ID so I
make use of Win32:API. Of course this causes a problem when the module
used on Linux.
Here's my "ALMOST works" solution:
if($^O =~ /MSWin32/i){
require Win32::API;
my $GetCurrentProcessId = Win32::API->new("kernel32", "int
GetCurrentProcessId()");
my $PID = GetCurrentProcessId();
:
:
etc.
}
By pulling Win32::API in using "require" instead of "use" it is only
evaluated on demand so Linux is happy, but because I am using "require"
instead of "use" something is not quite right with the initialization so
that on Windows perl complains:
Win32::API::parse_prototype: WARNING unknown output parameter type 'int'
at C:/perl/site/lib/Win32/API.pm line 273.
My idea only, but try it :-)
if($^O =~ /MSWin32/i) {
my $m = 'use Win32::API';
eval($m);
my $GetCurrentProcessId = Win32::API->new("kernel32", "int
GetCurrentProcessId()");
my $PID = GetCurrentProcessId();
:
:
etc.
}
Petr Vileta, Czech republic
(My server reject all messages from Yahoo and Hotmail. Send me your mail
from another non-spammer site please.)
_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs