Skip Menu |

This queue is for tickets about the Win32-OLE CPAN distribution.

Report information
The Basics
Id: 53484
Status: resolved
Priority: 0/
Queue: Win32-OLE

People
Owner: Nobody in particular
Requestors: BOLDRA [...] boldra.org
Cc:
AdminCc:

Bug Information
Severity: Unimportant
Broken in: 0.1709
Fixed in: (no value)



Subject: win32-ole breaks win32-gui-hyperlink on win64
Using 32 bit strawberry 5.10.0 on 64 bit windows the following code doesn't work:

use Win32::GUI;
use Win32::GUI::HyperLink;
use Win32::OLE;
my $win=Win32::GUI::Window->new( -size=>[200,200] );
my $hl = $win->AddHyperLink(
-text=>q{http://google.com}
,-pos=>[10,10]);

Win32::OLE->GetObject(q{./root/CIMV2/Win32_PhysicalMemory});
$hl->Launch;

This dies with the message "Failed opening http://google.com ShellExecute(5) The requested lookup key was not found in any active activation context".
Without the Win32::OLE->GetObject call, the Hyperlink->Launch call works.

I'm not having this problem with 32 bit strawberry or cygwin perl (both 5.10.0) on 32 bit windows.




Subject: Re: [rt.cpan.org #53484] win32-ole breaks win32-gui-hyperlink on win64
Date: Fri, 08 Jan 2010 16:26:42 -0800
To: bug-Win32-OLE [...] rt.cpan.org
From: Bill Luebkert <dbecoll [...] roadrunner.com>
Paul Boldra via RT wrote: Show quoted text
> Thu Jan 07 11:27:19 2010: Request 53484 was acted upon. > Transaction: Ticket created by BOLDRA > Queue: Win32-OLE > Subject: win32-ole breaks win32-gui-hyperlink on win64 > Broken in: 0.1709 > Severity: Unimportant > Owner: Nobody > Requestors: BOLDRA@boldra.org > Status: new > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=53484 > > > > Using 32 bit strawberry 5.10.0 on 64 bit windows the following code doesn't > work: > > use Win32::GUI; > use Win32::GUI::HyperLink; > use Win32::OLE; > my $win=Win32::GUI::Window->new( -size=>[200,200] ); > my $hl = $win->AddHyperLink( > -text=>q{http://google.com} > ,-pos=>[10,10]); > > Win32::OLE->GetObject(q{./root/CIMV2/Win32_PhysicalMemory}); > $hl->Launch; > > This dies with the message "Failed opening http://google.com ShellExecute(5) > The requested lookup key was not found in any active activation context". > Without the Win32::OLE->GetObject call, the Hyperlink->Launch call works.
Interesting that if you swap the last two lines (do the launch first), it works on 5.8.8 B820. Sorry I don't have 5.10 to try. Show quoted text
> I'm not having this problem with 32 bit strawberry or cygwin perl (both 5.10.0) > on 32 bit windows.
use strict; use warnings; use Win32::GUI; use Win32::GUI::HyperLink; use Win32::OLE; my $win = Win32::GUI::Window->new(-size => [200,200]); # $win->Show(); # added to see GUI my $hl = $win->AddHyperLink(-text => q{http://google.com/}, -pos => [10,10]); $hl->Launch; # moved up a line # modified and added some code just for some output my $objs = Win32::OLE->GetObject(q{WinMgmts://./root/cimv2}) or die "GetObject: " . Win32::OLE->LastError(); use Win32::OLE qw(in); my $class = 'Win32_PhysicalMemory'; foreach my $item (in $objs->InstancesOf($class)) { foreach (sort (map { $_->{Name} } in $item->{Properties_})) { print "$_: ", defined $item->{$_} ? $item->{$_} : '<undef>', "\n"; } print "\n"; } __END__
Subject: RE: [rt.cpan.org #53484] win32-ole breaks win32-gui-hyperlink on win64
Date: Thu, 14 Jan 2010 18:22:14 -0800
To: <bug-Win32-OLE [...] rt.cpan.org>
From: "Jan Dubois" <jand [...] activestate.com>
On Thu, 07 Jan 2010, Paul Boldra via RT wrote: Show quoted text
> This dies with the message "Failed opening http://google.com > ShellExecute(5) The requested lookup key was not found in any active > activation context". Without the Win32::OLE->GetObject call, the > Hyperlink->Launch call works.
This is happening because the ShellExecute() function in Windows, which is what Hyperlink->Launch() is ultimately calling, only works correctly inside a single-threaded apartment (STA). The COM threading model is determined by whoever first calls CoInitialize() in a particular thread. Win32::OLE will choose a multithreaded apartment (MTA) model by default because it avoids certain lockup problems in non-GUI Perl programs that don't process the message loop regularly. So if the first COM call made in your process is a Win32::OLE call, you end up with a threading model that is incompatible with ShellExecute(). If you call ShellExecute() first, then Win32::OLE will notice that it is already running inside a STA and not try to change the model. If you don't want to rely on the ordering in which you make these calls, then you can tell Win32::OLE explicitly to use a STA with use Win32::OLE; Win32::OLE->Initialize(Win32::OLE::COINIT_OLEINITIALIZE()); Cheers, -Jan