davide_c has asked for the wisdom of the Perl Monks concerning the following question:
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Win32::FileOp issues
by bulk88 (Priest) on Mar 06, 2014 at 04:22 UTC | |
by davide_c (Acolyte) on Mar 19, 2014 at 14:02 UTC | |
by bulk88 (Priest) on Mar 20, 2014 at 05:37 UTC | |
by davide_c (Acolyte) on Mar 20, 2014 at 21:53 UTC | |
by bulk88 (Priest) on Mar 21, 2014 at 02:40 UTC | |
|