Hi there

I'm having a problem with win32::fileop, a program I made years ago crashes under windows 8.

Basically if I call the SaveAsDialog function once it works fine, but if I call it again a second time the script crashes.

This little script gives the same results:

#!/usr/bin/perl use strict; use warnings; use Win32::FileOp; print "Win32::API version $Win32::API::VERSION\n\n"; print "Win32::FileOp version $Win32::FileOp::VERSION\n\n"; my $file = Win32::FileOp::SaveAsDialog; print $file; #exit; $file = Win32::FileOp::SaveAsDialog; print $file;

if you exit; after the first call to saveasdialog there are no problems.

I first tried it under perl 5.8 with fileop version 0.14, but after I upgraded to the latest versions (activestate perl 5.16; Win32::API 0.75; Win32::FileOp 0.16.02) I get the exact same result.

I don't think it is a 32bit/64bit issue, as I tried it under windows 7 64 bit and the script does not crash.

I tried to contact the module's author to no avail. Also the other addresses mentioned in the perldoc bounce back.

At first I thought the problem might be related to the changes in the struct for the Openfilename structure (see http://msdn.microsoft.com/en-us/library/windows/desktop/ms646839%28v=vs.85%29.aspx)

What puzzles me is that the change should have begun with windows vista, but the snippet works fine under vista 32 bit and windows 7 64 bit.

By trial and error I thought I found a workaround, by modifying the struct in win32::fileop by adding a dword flag that can be set to 1 to hide the "places" bar in the dialog. I'm quite sure the struct I made is not correct, I'm not an expert of win32 apis and the implementation in perl is also quite difficult for me to grasp.

With this change to win32:fileop i get a simpler dialog (without the 'places'):

my $struct = pack "LLLpLLLpLpLppLIppLLpILL", ( 88, #'lStructSize' # DWORD $Handle, #'hwndOwner' # HWND 0, #'hInstance' # HINSTANCE $lpstrFilter, #'lpstrFilter' # LPCTSTR 0, 0, # $lpstrCustomFilter, #'lpstrCustomFilter' # LPTSTR # length $lpstrCustomFilter, #'nMaxCustFilter' # DWORD #I'm not able to make it work with CustomFilter $nFilterIndex, #'nFilterIndex' # D +WORD $lpstrFile, #'lpstrFile' # LPTSTR length $lpstrFile, #'nMaxFile' # DWORD $lpstrFileTitle, #'lpstrFileTitle' # LPTSTR length $lpstrFileTitle, #'nMaxFileTitle' # DWORD $lpstrInitialDir, #'lpstrInitialDir' # LPCTSTR $lpstrTitle, #'lpstrTitle' # LPCTSTR $Flags, #'Flags' # DWORD 0, #'nFileOffset' # WORD # 0, #'nFileExtension' # WORD $nFileExtension, #'nFileExtension' # WORD $lpstrDefExt, #'lpstrDefExt' # LPCTSTR 0, #'lCustData' # DWORD 0, #'lpfnHook' # LPOFNHOOKPROC $lpTemplateName #'lpTemplateName' # LPCTSTR , 0, 1 );

At first I thought it didn't crash this time. You can call it multiple times and not have any problems. But now, if you click on the folder tree dropdown and click on 'desktop' it still crashes...

I've run out of ideas, anyone has any pointer?

thanks

davide


In reply to Win32::FileOp issues by davide_c

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.