in reply to Re^2: Install OS2::Process on windows
in thread Install OS2::Process on windows

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.

Replies are listed 'Best First'.
Re^4: Install OS2::Process on windows
by Nalina (Monk) on Jun 14, 2005 at 11:58 UTC
    Could you please tell me how to use 'GetWindowThreadProcessId' similarly?
      GetWindowThreadProcessId translates into:
      use Win32::API; my $GetWindowThreadProcessId = Win32::API->new('user32', 'GetWindowThr +eadProcessId', ['N', 'P'], 'N'); my $process_id = pack 'V', 0; # buffer of 4 bytes my $thread_id = $GetWindowThreadProcessId->Call($hwnd, $process_id); $process_id = unpack 'V', $process_id;
      If you don't need $process_id, you can just drop the lines for it and use undef in the API call, which Win32::API will translate into a null pointer.

      Apparently these two API calls return a completely different value for $hinstance and for $process_id.

        Thank u very much. This solved my problem.