Nalina has asked for the wisdom of the Perl Monks concerning the following question:

Hi monks,
Can anyone kindly give me the url to install OS2::Process on windows using ppm.
Thanks in advance

Replies are listed 'Best First'.
Re: Install OS2::Process on windows
by bart (Canon) on Jun 14, 2005 at 08:55 UTC
    CPAN says it comes with Perl.

    But it didn't come with ActivePerl, that's for sure — or any other Perl for Windows that I tried.

    There's a separate package on CPAN too, a Google search for OS2-Process PPD, usually a surefire way to find some PPM distributions, comes up blank.

    I even have doubts if you can get it to compile on Windows. And I doubt its usefulness on Windows anyway. What are you trying to achieve, actually?

      I am trying to get the pid of a process.
      use Win32; use Win32::OLE qw(in with); use Win32::OLE::Const 'Microsoft Excel'; use Win32::OLE::Variant; use Win32::OLE::NLS qw(:LOCALE :DATE); use Win32::OLE; use Win32::OLE::Const; use OS2::Process; $Win32::OLE::Warn = 3; # die on errors... $Constant = Win32::OLE::Const->Load('Microsoft Excel'); $Excel = Win32::OLE->new('Excel.Application', sub {$_[0]->Quit;}) || die "Error launching MS Excel ".Win32::OLE->LastError(1); $hwnd = $Excel->{"Hwnd"}; ($pid, $tid) = WindowProcess($hwnd) ; print "\n\n $pid \n\n"; .... .... ...
      Is there any other way to find pid of a process by using Hwind? kindly help
        Ah indeed. Well, I don't think anything based on the OS2 API can work on Windows.

        I've been poking around a little in the Windows API, and I think the "application instance handle" is the value you're after. You can retrieve it from a handle using the GetWindowLong API call, with the GWL_HINSTANCE constant — its value is -6. Translating the API call to Win32::API, I get:

        use Win32::API; use constant GWL_HINSTANCE => -6; my $GetWindowLong = Win32::API->new('user32', 'GetWindowLong', ['N', ' +N'], 'N'); my $hinstance =$GetWindowLong->Call($hwnd, GWL_HINSTANCE);
        I get a number back, I just hope it agrees with you PID. I think it does.

        p.s. If you're still thinking of killing Excel when you're finished: you don't have to. You specified the sub sub {$_[0]->Quit;} to be called when the $Excel object is destroyed, which makes Excel exit. That really should suffice.

Re: Install OS2::Process on windows
by marto (Cardinal) on Jun 14, 2005 at 09:33 UTC
    Hi Nalina,

    How does this differ from your previous question Get PID of a particular instance of Excel?
    From OS2::Process
    "OS2::Process - exports constants for system() call on OS2."

    You are running M$ Windows, the module you are asking about is for OS/2.

    Martin