On Thu, 11 May 2000, Tony Auerbach wrote:

> Subject: BrowseForFolder trouble
> 
> I'm trying to use the use the BrowseForFolder fucntion in the 
> Tk::Win32::FileOp package and perl is crashing.  It's the usual Windows 
> "illegal operation" message and the details begin with "PERL caused an 
> invalid page fault in module SHELL32.DLL at 016f:7fd07775."
> 
> The OpenDialog fuction works fine.  Is anyone successfully using 
> BrowseForFolder?  Is it my code or a bug in the module?  Here is a sample 
> of code that will always crash.

Same problem showed up on my win98 machines when upgraded them to 2nd Edition.
I finally found this in the mail archives ( Hope the next rev comes out
sometime soon and the fix makes it into it ) and it fixed it:

>From [EMAIL PROTECTED] Fri May 05 10:13:25 2000
Date: Sun, 16 Apr 2000 17:55:43 +0400
From: Mike Blazer <[EMAIL PROTECTED]>
To: Perl-Win32-Users Mailing List <[EMAIL PROTECTED]>
Cc: Perl-Win32-Users Mailing List <[EMAIL PROTECTED]>
Subject: Re: FileOp::GetWindowHandle bug

Guys, I'm sorry - first of all, yes, SleepEx is correct, please change it - I don't 
understand how this could work in previous Perl versions.

But this is not enough. As a quick fix please find replace in your version of FileOp 
this subroutine:

sub BrowseForFolder {
#=======================
   my ($hwndOwner, $pidlRoot, $pszDisplayName,
       $lpszTitle, $nFolder, $ulFlags,
       $lpfn, $lParam, $iImage, $pszPath)
      =
      (GetWindowHandle(), "\0"x260, "\0"x260,
       shift() || "\0", shift(), shift() | 0x0000,
       0, 0, 0, "\0"x260);

   $nFolder = CSIDL_DRIVES() unless defined $nFolder;

   $Win32::FileOp::SHGetSpecialFolderLocation->Call($hwndOwner, $nFolder, $pidlRoot)
   and return undef;
   $pidlRoot = hex unpack 'H*',(join'', reverse split//, $pidlRoot);

   my $browseinfo = pack 'LLppILLI',
      ($hwndOwner, $pidlRoot, $pszDisplayName, $lpszTitle,
       $ulFlags, $lpfn, $lParam, $iImage);

   my $bool = $Win32::FileOp::SHGetPathFromIDList->Call(
               $Win32::FileOp::SHBrowseForFolder->Call($browseinfo),
               $pszPath
              );

   $pszPath =~ s/\0.*$//s;
   $bool ? $pszPath : undef;
}      


This works with older builds or 5.6 either.

This a quick fix. This would be fixed in the upcoming Win32::FileOp release.

Thanks, Steve, for pointing it out!

Steve Sherman wrote:
> 
> I found a bug in Win32::FileOp::GetWindowHandle which caused my perl script
> to crash.  After calling GetWindowHandle(), the Win95 "illegal operation"
> box popped up.  The details said "PERL caused an invalid page fault in
> module PERL56.DLL at 0137:2804f87b."
> 
> I found that changing the line:
> 
>   my $SleepEx = new Win32::API("kernel32", "Sleep", ['N','I'],'V');
> 
> to:
> 
>   my $SleepEx = new Win32::API("kernel32", "SleepEx", ['N','I'],'V');
> 
> fixed my problem.  I am using version 0.11 of FileOp, which I downloaded a
> few days ago with ppm from http://jenda.mccann.cz/perl.  I am using
> ActivePerl 5.6.  BTW, GetWindowHandle is used by FileOp::BrowseForFolder.
> 
> -- Steve Sherman

-- 
==================================
Mike Blazer
[EMAIL PROTECTED]
http://base.dux.ru/guest/fno/perl/
==================================

~=====================================================================~
~[  Eloy A. Gonzales                     Voice: (505) 844-1063       ]~
~[  Sandia National Laboratories         Fax:   (505) 844-7059       ]~
~[  Org 05743 MS 0965                    email: [EMAIL PROTECTED]   ]~
~[  Albuquerque, New Mexico 87185-0965                               ]~ 
~=====================================================================~




---
You are currently subscribed to perl-win32-users as: [archive@jab.org]
To unsubscribe, forward this message to
         [EMAIL PROTECTED]
For non-automated Mailing List support, send email to  
         [EMAIL PROTECTED]

Reply via email to